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...


  • Can you confirm which packages you're using. It looks like setspace and some version of color, xcolor, xxcolor ... Aug 16, 2010 at 12:41
  • 6
    Have you considered using the todonotes package?
    – Caramdir
    Aug 16, 2010 at 12:42
  • sure, sorry I missed out on that: hyperref,color,graphicx,setspace,natbib,bibgerm,ulem
    – Phil
    Aug 16, 2010 at 12:43

3 Answers 3


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

  • 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, 2010 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.


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy