# Unwanted spacing

The marginnote package introduces some extra spacing between the section header and the start of a paragraph (this is unwanted). How can this be corrected?

# MWE

\documentclass{extarticle}

\usepackage{lipsum}
\usepackage{marginnote}
\usepackage{titlesec}

% Shorten the spacing after section headings
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}

\begin{document}
\subsection{Normal spacing}
\lipsum[1-4]
\subsection{Unwanted spacing}
\marginnote{Something very long and interesting. Something very long and interesting.}
\lipsum[1]
\end{document}


This code with a simple \marginpar seems to improve the layout:

\documentclass{extarticle}

\usepackage{lipsum}
\usepackage{titlesec}

% Shorten the spacing after section headings
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}

\begin{document}

\subsection{Normal spacing}
\lipsum[1-4]
\subsection{Unwanted spacing}
\leavevmode\marginpar{\raggedright Something very long and interesting. Something very long and interesting.}
\lipsum[1]

\end{document}


• If I add a \leavevmode it adds a small indent at the start of the paragraph. (My real document uses \setlength{\parindent}{0mm}, and hence why I've noticed it). Can this side effect be resolved as well? – oliversm Jan 29 at 14:58
• It probably adds an interword space. See if adding \hspace*{-\fontdimen2\font (just after \leavevmode) solves your problem. – Bernard Jan 29 at 19:44

Adding the \hrule makes the spacing more obvious. Evidently \marginnote adds a \strut at the beginning instead of a simple \leavevmode.

\documentclass{extarticle}

\usepackage{lipsum}
\usepackage{marginnote}
\usepackage{titlesec}

% Shorten the spacing after section headings
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}

\begin{document}
\subsection{Normal spacing}
\lipsum[1-4]
\subsection{Unwanted spacing}
%\hrule
\smash{\marginnote{Something very long and interesting. Something very long and interesting.}}%
\lipsum[1]
\end{document}

• This adds in the space for an entire line and gets rid of the vertical alignment. – oliversm Jan 29 at 15:02
• Did you run it twice? \marginnote gets its vertical position from the previous run. – John Kormylo Jan 29 at 17:35