TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

When writing papers, I like to keep track of notes, thoughts and to do's inside the documents.

I'd love to have tiny coloured multi-line marginalia. So far I used sth like


to have a red side-note, but the single-spacing does not work. How can I have this marginalia single-spaced (or less)? And is it possible to have the text with a yellow background? The \colorbox{} command doesn't seem to wrap the text.

I'd also be interested how you keep track of notes and thoughts within your documents...


share|improve this question
Can you confirm which packages you're using. It looks like setspace and some version of color, xcolor, xxcolor ... – Loop Space Aug 16 '10 at 12:41
Have you considered using the todonotes package? – Caramdir Aug 16 '10 at 12:42
sure, sorry I missed out on that: hyperref,color,graphicx,setspace,natbib,bibgerm,ulem – Phil Aug 16 '10 at 12:43
up vote 7 down vote accepted

You could use \setstretch and \parbox inside \colorbox. Here's an example, using even smaller stretch value to make the effect more visible:

\mymarginnote{Some text in the margin spanning several lines}

The output looks like:

alt text

share|improve this answer
Yup, that's it, great! ;-) Thanks, Stefan and the others! Esp. todonotes is worth a look for more complex projects! stackexchange ftw! – Phil Aug 16 '10 at 13:25

I think the real problem is this.

Wrong spacing:

\newcommand{\mymarginnote}[1]{\marginpar{\textcolor{red}{\scriptsize #1}}}

Right spacing:


Explanation: In the second version, \scriptsize is still in effect when the paragraph ends. This is the point at which Latex chooses the line spacing for the paragraph.

No need to use any extra tweaks like the "spacing" environment.

share|improve this answer

Have you considered using \linespread, e.g.,


Of course, just adjust the \linespread factor to tighten things up (note that it's tucked inside a new {...} group). To make things interesting, I've redefined \marginpar to show that you can format each side differently in twoside docs. While I was at it, I adjusted the vertical position of the margin note up a notch to better align its baseline with the body text it relates to. I omitted the \colorbox command you were interested in since Stefan's answer made its usage pretty clear.

share|improve this answer

Your Answer


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