2

I'm making a major change to a document, and I want to turn some quite large sections into notes using todonotes. According to the documentation, this can be done with

\todo[inline,caption={My Caption}]{
\begin{minipage}{\textwidth}

< all my stuff >

\end{minipage}
}

The trouble is that my sections include clumps of computer code, either with the verbatim environment, or with the lstlistings environment from the listings package. And each one throws an error about the brackets - the closing bracket of the todo material seems to be mishandled by the other environments, even though they're in a minipage. I can get the correct visual effect by putting all computer code into \texttt{ } but then I need to fiddle with newlines and horizontal whitespace to show indentation.

Here's a minimal non-working example:

\documentclass{article}

\usepackage{todonotes}

\begin{document}
This is a test of an inline note:

\todo[inline,caption={My caption}]{
  \begin{minipage}{\textwidth}
    A test of verbatim:
\begin{verbatim}
And this...
    ... is this!
\end{verbatim}
  \end{minipage}
}

\end{document}

The error is: Argument of \@xverbatim has an extra }. I've tried using Verbatim from the fancyvrb package, and also the listings package, with the same error.

So - how can I include a verbatim environment inside a minipage inside a todo note?

1

1 Answer 1

1

Save the verbatim in a box prior to the inline \todo and then recall it.

\documentclass{article}

\usepackage{todonotes,verbatimbox}

\begin{document}
This is a test of an inline note:

\begin{myverbbox}{\verbA}
And this#^\...
    ... is this!
\end{myverbbox}

\todo[inline,caption={My caption}]{
  \begin{minipage}{\textwidth}
    A test of verbatim:\strut\\
\verbA
  \end{minipage}
}

\end{document}

enter image description here

0

You must log in to answer this question.

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