# Single-spaced multi-line marginalia

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

\newcommand{\mymarginnote}[1]{\marginpar{\begin{spacing}{0.8}\textcolor{red}{\scriptsize{#1}}\end{spacing}}}


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

Thanks!

-
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

## 3 Answers

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

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[svgnames]{xcolor}
\usepackage[doublespacing]{setspace}
\newcommand{\mymarginnote}[1]{%
\marginpar{\colorbox{yellow}{\parbox{\marginparwidth}{%
\setstretch{0.5}\textcolor{red}{\scriptsize{#1}}}}}}
\begin{document}
\blindtext
\mymarginnote{Some text in the margin spanning several lines}
\blindtext
\end{document}


The output looks like:

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

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


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

\let\oldmarginpar\marginpar
\renewcommand\marginpar[1]{%
{\linespread{0.85}\normalfont\scriptsize%
\oldmarginpar[\vspace{-1.5ex}\raggedright\scriptsize\color{red}\textsf{#1}]%
{\vspace{-1.5ex}\raggedright\scriptsize\color{green}\textsf{#1}}%
}%
}


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.

-