LaTeX todonotes for printing

The LaTeX package <code>todonotes</code> is nice for added todo-notes to documents. The problem is the default settings (orange colored background) will waste printer ressources if you print intermediate versions of the document.

I have found a nice way around it by using the “Optional Content Group” feature of PDFs. The following command generates two todos on top of each other, one with the orange background which will not be printed, and another with white background for printing.

It is quite a dirty hack, but it works well for me. The only problem I found so far is that it will not work in captions.

\PrintTODOtrue % comment this line to omit todos
        \savebox\todoboxa{\begin{ocg}[printocg=never]{ToDo screen}{todo4screen}{1}
        \savebox\todoboxb{\begin{ocg}[printocg=always]{ToDo print}{todo4print}{0}
        \todo[#1,bordercolor=\@todonotes@currentlinecolor, backgroundcolor=white, inline, nolist]{#2}


Update: Added the possibility to pass additional arguments. Also the border color in print will match the background color on screen.