2

I have an odd (to me) problem involving an itemize environment and \marginpar{}. The problem is illustrated in the following document:

\documentclass{article}

\newcommand{\todo}[1]{\marginpar{\small\flushleft #1}}

\begin{document}

\begin{itemize}
\item first item
\item \todo{the second item is missing} third item
\end{itemize}

\end{document}

I would have expected to get output resembling

  • first item
  • third item

together with a margin note saying "the second item is missing". Instead I get the following:

unexpected TeX output

i.e. the black dot for the second bullet point somehow ended up in the margin! The problem does not occur if I replace \todo with \marginpar in the itemized list, so the use of a macro is somehow part of this problem.

My questions:

  1. What is going wrong here?

  2. How can I fix my \todo macro to avoid this problem?

  • 1
    Don't use \flushleft. That starts a new list. Use \raggedright. – Ulrike Fischer Nov 3 '14 at 14:59
3

Your problem is \flushleft which should be used as an environment. Use \raggedright instead which is a switch.

\documentclass{article}

\newcommand{\todo}[1]{\marginpar{\raggedright\small#1}}

\begin{document}

\begin{itemize}
\item first item
\item \todo{the second item is missing} third item
\end{itemize}

\end{document}

enter image description here

I would prefer marginnote for better positioning.

\documentclass{article}
\usepackage[fulladjust]{marginnote}

\newcommand{\todo}[1]{\marginnote{\raggedright\small#1}}

\begin{document}

\begin{itemize}
\item first item
\item \todo{the second item is missing} third item
\end{itemize}

\end{document}

enter image description here

  • This indeed fixes the problem, thanks! It is still a mystery to me how the bullet made it into the margin, though; any ideas? Probably something to do with some \expandafter deep in the guts of the definition of \item? – jochen Nov 3 '14 at 15:57
  • @jochen \flushleft starts a list again, that is why the bullet in the margin. – user11232 Nov 3 '14 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.