TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Similar situation as in Align marginpar with beginning of paragraph.

Basically I need to align the margin note to the beginning of the paragraph, and I'm putting the \marginpar command before the first word of the paragraph. This can be done by adding a \hspace{0pt} before the \marginpar command.

However, I'm also setting \parindent to 0pt, and this will produce a space at the beginning of the paragraph. Currently I'm using something like \hspace{-0.15cm} as a hack to fixed this problem, but it's not very pretty, any better solutions?

(I have tried the marginnote package, but there are still a few problems. It automatically aligns the margin note to the first line of the paragraph, except when there is a page break and the margin note will appear on the previous page. The longer margin notes will also overlap.)

share|improve this question
up vote 6 down vote accepted

If you never need the optional argument to \marginpar you can use \initmarginpar defined as


Otherwise always remember to protect the end of line with a comment character:

\marginpar{Margin note}%
Start of the paragraph...

I believe that \leavevmode (or even more \quitvmode) is much better than \hspace{0pt}.

share|improve this answer
Thanks, both the command \ignorespaces and the comment character, or even starting the text immediately after the closing brace of \marginpar solves the problem. I try to make the source more readable by using spaces and empty lines a lot, but maybe I shouldn't after all... – sxu May 23 '11 at 16:34

I don't see a problem:

\hspace{0pt}\marginpar{blub}Some text

Some Text
share|improve this answer
I think the problem was that I started a new line after the \marginpar (leaving a space after the closing brace also cause the same problem), putting a comment at the end of the line, as suggested in the other answer also solve the problem. Perhaps it has something to do with the way LaTeX parse things, I definitely need to learn more about how LaTeX works... – sxu May 23 '11 at 16:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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