8

In the following example, the main paragraph gets typeset as 3 lines of text, with the paragraph ending on the third line before it reaches the margin. However, when un-commenting the line with the \marginpar command, the paragraph is reformatted so that the third line extends all the way to the margin, and a blank fourth line is inserted. What is the \marginpar inserting into the main text that doesn't "fit" into the third line, and why?

\documentclass{amsart}
\begin{document}

\noindent
Suppose furthermore that abcde is a regular cardinal such thati abcdefghiji
The collection abcdefg is called a 
nice collection of elementary submodels of $H(\theta)$ indexed by $T$ if,
in addition to being a nice collection of sets as above, we have:  Bake
%\marginpar{Bake a cake.}

Next paragraph.
\end{document}

(Note: The \noindent and the choice of document class are probably not essential to the problem, but I couldn't quite get the spacing right when trying to reproduce the problem without them.)

I realize that the practical workaround is to remove the inter-word space before the \marginpar command. However, it is not clear to me why this should be necessary. Furthermore, I discovered this problem when using the \todo command of the todonotes package, which relies on \marginpar. It seems that \todo intentionally gobbles the space following its argument, meaning that it is designed so that one should (in general) leave a space before it, but this case then becomes an exception.

9

The end of paragraph command (from \par or a blank line) attempts to remove any space at the end of the paragraph (before it does the linebreaking) by doing an \unskip operation. However the insert node for the marginpar protects the interword space so it doesn't get removed. If you are unlucky you get a linebreak and the last line of the paragraph only has the insert node, so gets filled with \parfillskip glue and has the appearance of a blank line. Put a % at the end of the line above and things work better. (You see the same with \footnote or \index)

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.