6

I am having a problem trying to insert come environments into inline todo notes... This MWE should demonstrate.

\documentclass{article}

\usepackage{todonotes}
\usepackage{verbatim}

\begin{document}
\noindent

\todo[inline]{%
Problem when nesting objects like enumerate, itemize, or verbatims.  Others like \textbf{BOLD} work fine.
}
\todo[inline]{%
\begin{itemize}
\item A
\item B
\item C
\end{itemize}
}

\clearpage
\end{document}

Interestingly, the pdf produced is perfectly acceptable, but errors prevent the process from completing.

Errors produced: Argument of \reserved@a has an extra }. }

Paragraph ended before \reserved@a was complete. }

Looked at todonotes and verbatim but this didn't seem to be applicable.

2 Answers 2

4

You can't have verbatim in the argument to any command, including \todo.

For itemize, this works:

\documentclass{article}

\usepackage{todonotes}
\usepackage{verbatim}

\begin{document}

\todo[inline]{%
Problem when nesting objects like enumerate, itemize, or verbatims.
 Others like \textbf{BOLD} work fine.
}
\todo[inline]{%
\unexpanded{\unexpanded{\begin{itemize}
\item A
\item B
\item C
\end{itemize}}}
}

\end{document}

Alternatively, use \protect\begin{itemize}, \protect\item and \protect\end{itemize}: the argument to \todo is a moving one, so fragile commands must be protected.

4

The todonotes manual (Page 15) suggests creating a macro using a minipage like this:

\newcommand\todoin[2][]{\todo[inline, caption={2do}, #1]{
\begin{minipage}{\textwidth-4pt}#2\end{minipage}}}

\todoin{
Some text.
\begin{align}
    \sin(\theta)^2 + \cos(\theta)^2 = 1
\end{align}
A formula and a list
\begin{itemize}
    \item An item
\end{itemize}
}

According to the manual it is important to set the caption of the \todo, so the package will not try to embed a minipage into your table of contents, which would result in an error.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .