[Tex/LaTex] todonotes’ \listoftodos with multi-paragraph \todo{}s

paragraphstodonotes

There seems to be an issue with todonotes. I've been using \todo{}s that span multiple paragraphs for some time and never noticed any problems. Now I've tried to add a \listoftodos to my document – and failed. Here is a MWE that demonstrates the issue:

\documentclass{article}
\usepackage{todonotes}

\begin{document}
\listoftodos

\section*{Whatever}
Some text\todo{Do this.}

\todo[inline]{Do that.}

A litle more text.

\todo[inline]{%
Oh, and by the way:

Remember the milk.}

\end{document}

The second compilation run fails with

Runaway argument?
{Oh, and by the way: 
! Paragraph ended before \@dottedtocline was complete.
<to be read again> 
                   \par 
l.3 \contentsline {todo}{Oh, and by the way: \par
                                                  Remember the milk.}{1}

Is there some kind of magic that I could apply to todonotes or do I have to reformat all of my todo notes?

Best Answer

Would it be OK for you, to add one more option to every note? I think it makes sense, not to print a whole chapter in the Todo List so something like \caption[short for LoF]{long for display} would be a good solution.

Therefore you should use the caption={...} option.

For your MWE this would look like:

% arara: pdflatex
% arara: pdflatex

\documentclass{article}
\usepackage{todonotes}

\begin{document}
\listoftodos    
\section*{Whatever}
Some text\todo{Do this.}

\todo[inline]{Do that.}

A litle more text.

\todo[inline, caption={short for LoTds}]{%
Oh, and by the way:

Remember the milk.}
\end{document}