2

I am using marginpar to margin notes in a book. My problem is that if I add a \marginpar too close to the bottom of a page, the margin will overflow the bottom of the page.

For instance, using the following code, the margin not is not fully visible as it overflows (see below).

\documentclass{article}
\usepackage{lipsum}
\begin{document}

\lipsum[1-5]
\marginpar{\tiny \lipsum[1-1]}
\end{document}

Of course, I could manually modify the place of margins like this:

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1-2]
\marginpar{\tiny \lipsum[1-1]}
\lipsum[3-5]
\end{document}

But this requires moving all \marginpar each time I change a paragraph in the document. Ideally, I would prefer if latex could automatically move my marginpar up to avoid overflowing the bottom of the page.

Question: Is there a way to ask latex to place marginpar automatically? (like the arguments [t] or [h] of figure). Or should I used another package? (marginnote?)


The result that I do not want: not what I want

What I would prefer: what I want

For my document, I am using the scrbook and classicthesis but the problem also occurs with the class article.

Bernard
  • 271,350
N. Gast
  • 204
  • See also https://tex.stackexchange.com/questions/320065/marginpar-start-at-top-of-page/320077?r=SearchResults&s=2|28.5825#320077, https://tex.stackexchange.com/questions/314125/dummy-text-inside-the-marginal-note-doesnt-continue-to-next-pages/314143?r=SearchResults&s=10|13.2899#314143, and https://tex.stackexchange.com/questions/215322/multiple-marginnote-commands-on-the-same-line-in-math-environment/216037?r=SearchResults&s=20|7.6621#216037 – John Kormylo Oct 01 '19 at 13:39

2 Answers2

5

Does this code solve your problem?

\documentclass{article}
\usepackage{lipsum}
\newcommand{\bmarginpar}[1]{\marginpar{\parbox[b]{\marginparwidth}{\tiny#1}}}

\begin{document}

\lipsum[1-5]
\bmarginpar{\lipsum[1]}

\lipsum[6-10]

\end{document} 

enter image description here

Bernard
  • 271,350
  • Thanks, this works. – N. Gast Oct 01 '19 at 12:39
  • I just modified your command to make it work with the style of classithesis, which ends up: \newcommand{\bmarginpar}[1]{\marginpar[% {\parbox[b]{\marginparwidth}{\flushright\footnotesize\textit{#1}}}]{% \parbox[b]{\marginparwidth}{\flushleft\footnotesize\textit{#1}}}} – N. Gast Oct 01 '19 at 12:40
  • That's fine! Of course, you must have not too many margin notes in a page – it is not as automatic as one could hope. – Bernard Oct 01 '19 at 12:44
1

The memoir class (an extension to book, report and article classes) provides a \sidebar{<text>} macro whereby <text> is written in the margin starting near the top of the textblock. If <text> is long it may continue onto the next page(s). Several \sidebars can be used on a page, printed in order and continuing on to further pages if necessary. The manual (> texdoc memoir) has more details on how to control which margin, fonts, spacing, etc.

Peter Wilson
  • 28,066