12

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.

8

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.

  • With your example I was able to align my marginnote with my section title. I also discovered that the titlesec package was causing an issue with aligning the marginnote. Once I discovered that, I found the article Conflict between the packages titlesec and marginnote, which now makes sense. – Tim Thayer Aug 7 '14 at 16:06
7
\documentclass[openany]{book}
\usepackage{marginnote}
\renewcommand*\marginfont{\normalcolor\normalfont\small}

\begin{document}
\chapter{Chapter Heading}
\section[Section Heading]{Section Heading\marginnote{Associated text}} 
%The optional argument of \section is used for the TOC
Is it working?
\end{document}

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.