2

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?

Example

enter image description here enter image description here

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}

2 Answers 2

3

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}

enter image description here

2
  • 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, 2019 at 14:58
  • It probably adds an interword space. See if adding \hspace*{-\fontdimen2\font (just after \leavevmode) solves your problem.
    – Bernard
    Jan 29, 2019 at 19:44
0

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}
2
  • This adds in the space for an entire line and gets rid of the vertical alignment.
    – oliversm
    Jan 29, 2019 at 15:02
  • Did you run it twice? \marginnote gets its vertical position from the previous run. Jan 29, 2019 at 17:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .