# how to control font and paragraph formatting in margins

i'm having a hard time to figure out how to control the exact appearance of margin text (such as is output by the \marginpar command). i'm using XeLaTeX with packages such as geometry, fontspec, leading and have managed to gain fine control over issues such as font faces, font sizes, paragraph indentation and line spacing, including how to set margin width and the distance of the margins from the main text.

how can i control the font and paragraph formatting of margins?

-

The LaTeX kernel uses \@marginparreset to set a fresh state in margin paragraphs. The usual definition is

\def\@marginparreset{%
\reset@font
\normalsize
\@setminipage
}


and you can modify it setting the font you prefer. I'd suggest something like

\makeatletter
\def\@marginparreset{%
\reset@font
\normalsize
\@marginparfont
\@setminipage
}
\def\@marginparfont{\normalfont\itshape} % or whatever
\makeatother


With \normalfont you go in the default state and then you can add whatever specification you wish.

-
your answer implies using \makeatletter / \makeatother to allow for command names containing @, right? –  flow Mar 29 '13 at 23:08
@flow Yes; the two commands are not necessary only in .sty or .cls files. –  egreg Mar 29 '13 at 23:21

@egreg wow that was real fast, many thanks for your suggestion. i've had an idea in the meantime and came up with this:

\newcommand{\marge}[1]{\marginpar{\fontsize{2mm}{2mm}\leading{2.5mm}#1}}


(i'm using \leading here coz \fontsize on its own would not appear to set the line height right).

so far the above seems works to my satisfaction—is anyone aware of possible ungood side effects?

-
\leading probably corrects it but \fontsize{2mm}{2mm} sets a 2mm font on the same baseline, it's unusual to use mm for font sizes but no harm in it, but normally the baselineskip should be around 20% bigger than the font size. You then need \selectfont (which \leading also does) before \fontsize has any effect. –  David Carlisle Mar 30 '13 at 1:02
the thing is that the second argument to \fontsize would not appear to have any effect at all (pending more experiments), which is why i'm using \leading at all. –  flow Mar 30 '13 at 20:59
If you follow it by \selectfont and the paragraph ends within the scope of the change then it will have an effect, the whole of LaTeX's font machinery relies on that working... –  David Carlisle Mar 30 '13 at 21:11