Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. –  Martin Schröder Aug 7 at 15:23

2 Answers 2

up vote 8 down vote accepted

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.

share|improve this answer
    
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 at 16:06
\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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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