I use the marginnote
package to create, well, margin notes. However, I observe some unwanted behavior when adding a note directly after a section heading, or between section headings. It seems like the command creates an empty paragraph, which is undesired, since it leads to extra whitespace or indentation.
MWE:
\documentclass{article}
\usepackage{marginnote}
\begin{document}
\section{Testsection}
\marginnote{Oops! Some extra whitespace.}
\subsection{Testsubsection}
But at least no indentation.
\section{Testsection2}
\subsection{Testsubsection2}
\marginnote{hi there!}Some extra indentation
\section{Testsection3}
\subsection{Testsubsection3}
Nothing \marginnote{Move along.} to see here.
\section{Testsection4}
\subsection{Testsubsection4}
\leavevmode\marginnote{Move along.}This also works.
\end{document}
Creates
I have read \marginnote leads to paragraph indentation, so I know about the \leavevmode
solution. However, this does not fix the first case (adding extra whitespace when between section headings).
Is there a way to define a command that will always keep marginnote
from creating extra paragraphs, so I can use it where I want without thinking about it?
\section[Testsection]{Testsection\protect\marginnote{\normalsize\mdseries No extra whitespace.}}