# Preventing a marginpar from falling off the page

I sometimes put longer texts in a \marginpar{...}-command and if the text where the \marginpar{...}-command is located is at the end of a page the text falls off the page instead of being placed on the next page or moves up to line up with the regular text block:

\documentclass[a4paper,11pt]{memoir}

\usepackage{lipsum}

\begin{document}
\lipsum[1]
\lipsum[1]
\lipsum[1]
\marginpar{\lipsum[1]}
\pagebreak
\lipsum[1]
\end{document}


How can I prevent this from happening besides of putting the \marginpar{...} elsewhere in the text?

• Try with \marginpar{\parbox[b]{\marginparwidth}{\lipsum[1]}}. Oct 9, 2019 at 13:53
• @Bernard that works, if you write it as an answer I will accept it. Oct 9, 2019 at 14:07

Surprisingly, there doesn't seem to be any vertical placement key for the placement of marginboxes in one of the dedicated packages. As a workaround, you can put its contents in a \parbox using one of these keys:

\documentclass[a4paper,11pt]{memoir}
\usepackage{xcolor, lipsum}

\begin{document}

\color{blue}
\lipsum[1-3]
\marginpar{\parbox[b]{\marginparwidth}{\color{red}\lipsum[11]}}

\color{black}
\lipsum[4-10]

\end{document}}


The memoir class provides several means of placing text in the margin.

\marginpar Text put in the margin level with where the macro is called but vertical space is applied between sequential notes if they would overlap.

\sidepar Text put in the margin level where the macro is called but does not float like \marginpar so texts may overlap.

\sidebar Like \marginpar but the text starts near the top of the page and may continue onto later pages if it is too long for the current page. Multiple \sidebar are set one after the other.

Perhaps you should consider using \sidebar instead of \marginpar.