I use todonotes, especially in the coordination of bigger projects.
Especially in the drafting and quick brainstorming phase I'd love to be able to just use markdown inside todonotes to not waste time with nesting itemize etc.
Sadly, i can't seem to make it work:
my many attempts to put a markdown env inside a todonote like this
\todo[...]{\begin{markdown}...\end{markdown}}
have failed with many errors (mostly seems to be runaway arg) sounding something like this:
Argument of ^^M has an extra }.
Any ideas / help / pointers?
MCVE:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{markdown}
\usepackage{todonotes}
\begin{document}
% normal markdown works:
\begin{markdown}
* woah
* bullets
\end{markdown}
% todonotes work
\todo[inline,prepend,caption={WOAH}]{yay}
% todonotes with itemize work
\todo[inline,prepend,caption={WOAH}]{yay
\begin{itemize}
\item woah
\item complicated bullets
\end{itemize}
}
% todonotes with markdown break
\todo[inline,prepend,caption={WOAH}]{nay
\begin{markdown}
* woah
* bullets easy
* boom
\end{markdown}
}
\end{document}
Best Answer
In this case,
markdown
is a verbatim environment so it cannot be used inside the argument of most commands.See https://texfaq.org/FAQ-verbwithin for more details.
A fix that does not involve much code change uses
cprotect
. Note the extra brace group around\todo[inline,prepend,caption={WOAH}]
.For explanation, see the documentation of
cprotect
package.Note that
\cprotect[om]\todo[inline, ...]{nay ...}
does not work because the optional argument must not be protected (the details what protect means is quite complex, see my answer for more details.)Alternatively it's possible to redefine
\todo
like thiscprotect
documentation for whyicprotect
should be used.\NewCommandCopy
is required because internally\todo
uses some mechanism to protect it (prevent it from being expanded in expand-only context).