[Tex/LaTex] How to align a marginpar with a section title

marginparvertical alignment

I wish to have brief information in a marginpar (or other solution) that aligns with the corresponding section (not section*) heading. So far the margin information is above or below the section title.

When run, the following MWE generates the margin text below the section title.

\documentclass[openany]{book}
\begin{document}
\chapter{Chapter Heading}
\section{Section Heading}\marginpar{\normalfont\normalsize Associated text}
Is it working?
\end{document}

I've searched the interwebs for help. I found Vertical alignment of marginnote and section heading, but this article deals with section*. Alas, perhaps it can't be done…

But I hope that it can.

Best Answer

Move the \marginpar inside the argument for \section:

\documentclass[openany]{book}
\begin{document}
\chapter{Chapter Heading}
\section[Section Heading]{Section Heading\protect\marginpar{\normalfont\normalsize Associated text}}
Is it working?
\end{document}

enter image description here

As an alternative, you can use \marginnote from the marginnote package instead and move the \marginnote command inside the argument for \section:

\documentclass[openany]{book}
\usepackage{marginnote}
\begin{document}
\chapter{Chapter Heading}
\section{Section Heading\protect\marginnote{\normalfont\normalsize Associated text}}
Is it working?
\end{document}

enter image description here

The optional argument was used so the marginal note won't be in the ToC so \protect is not really needed; if the optional argument is not used, it is necessary to \protect the command.

Related Question