[Tex/LaTex] marginnote vertical alignment

marginnotevertical alignment

I've run into a problem using the marginnote package; the vertical position changes if the note is wider than the margin. An MWE:

\documentclass{article}
\usepackage{lipsum,marginnote}
\setlength{\marginparwidth}{0.5in}
\begin{document}

\leavevmode%
\marginnote{Overlong}%
\lipsum[1]

\leavevmode%
\marginnote{Not Overlong}%
\lipsum[1]

\end{document}

The first note, wider than the margin, is set about half a line lower than the second. Using vanilla \marginpar instead sets both margin notes at the correct vertical position.

How can I get the vertical position to be set consistently using \marginnote? At this point, I'm using \parboxes, but then I lose the left/right justification.

Best Answer

The difference is that \marginnote issues \hspace{0pt} before starting to typeset the text of the note, which inserts a legitimate break point; so TeX will use it and the oversized rule will go to the second line; if you try with \unskip before the oversized rule, it will go in the first line. With \marginpar the \hspace is not issued.

Without a realistic example it's difficult to say more; an oversized rule will necessarily produce an overfull box and seems to be a little unsensical.

Related Question