0

The MWE below demonstrates my problem.

enter image description here I suppose that somehow the marginpar is introducing something on the line and Latex is then treating the line as non empty.

%%%%%%%%%%%%%%%%%%%

\documentclass{article}

\newcommand{\mtext}{\makebox[0pt]{}\marginpar{(hello)}}

\begin{document}

\begin{enumerate}
\item \mtext%
\begin{enumerate}
    \item This is a line too low, at least the marginpar is there!
\end{enumerate}

\end{enumerate}


\begin{enumerate}
\item
\begin{enumerate}
    \item This line is fine vertically, but I can't use my marginpar!
\end{enumerate}

\end{enumerate}

\end{document}
  • 1
    Why don't you use \mtext from within the nested item? – Bernard May 26 at 20:00
  • @Bernard Thanks for the tip! It never crossed my mind to try that. I sort of prefer to have these things attached to the object of interest itemi, since I can then more freely move the itemii parts without having to keep track of things. – Geoff May 26 at 20:07
  • The thing that introduces the empty line is \makebox[0pt]{} – siracusa May 26 at 20:49
  • @siracusa You're right, but that's needed otherwise the marginpar is also not correctly aligned. – Geoff May 26 at 20:51
0

Finally, I can propose two ways of solving the problem: one I mentioned in a comment (adding the marginal note from within the nested enumerate), and another from within the outer enumerate, using the possibilities of enumitem:

\documentclass{article}
\usepackage{enumitem} 
\newcommand{\mtext}{\leavevmode\marginpar{(hello)}}

\begin{document}
%
\begin{enumerate}%
\item%
\mtext
\begin{enumerate}[before =\vspace*{-\dimexpr\baselineskip+2\topsep }]
    \item This is a line too low, at least the marginpar is there!
\end{enumerate}

\end{enumerate}

\begin{enumerate}
\item
\begin{enumerate}
    \item This line is fine vertically, but I can't use my marginpar! \mtext%
\end{enumerate}

\end{enumerate}

\end{document} 

enter image description here

0

One way to get back into vmode in the middle of a line is to use a minipage. This is certainly not the easiest solution, though.

\documentclass{article}

\newcommand{\mtext}{\leavevmode\marginpar{(hello)}}

\begin{document}

\begin{enumerate}
\item \mtext
\begin{minipage}[t]{\linewidth}
\begin{enumerate}
    \item This is a line too low, at least the marginpar is there!
\end{enumerate}
\end{minipage}
\end{enumerate}

\end{document}

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.