# marginpar in a macro steal the bullet of itemized list

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:

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?

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

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}


I would prefer marginnote for better positioning.

\documentclass{article}

\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}


• 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