# Line numbers collide with marginnotes on even pages in a book

I am having a bit of a problem with margin notes colliding with line numbers on the even pages of a book. I would like to adjust the margins so that the notes can stay where they are. I think this means I need to increase the outer margin and the marginparsep on even pages.

A minimal working example is included below:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{lineno}
\usepackage{geometry}
\usepackage{marginnote}

\title{lineNumbersAndMarginNotes}

\begin{document}
\begin{linenumbers*}

Here is some text that has line numbers, the text is not important, but it needs to have a few lines otherwise it won't demonstrate the issue I would like to figure out. I don't just want a plug in solution\marginpar{\fbox{\parbox{10ex}{Here is a margin note, I think}}}, I'd really like to understand how to get the \texttt{geometry} package to act differently on odd and even pages.

\newpage

Here is some text that has line numbers, the text is not important, but it needs to have a few lines otherwise it won't demonstrate the issue I would like to figure out. I don't just want a plug in solution\marginnote{\fbox{\parbox{10ex}{Here is a margin note, I think}}}, I'd really like to understand how to get the \texttt{geometry} package to act differently on odd and even pages.

\end{linenumbers*}

\end{document}


I'm mostly interested in how to affect geometry on the even-sided pages. Thanks,

• You probably do not want the margins not to match, right? That would look very strange. The outer margin should be the same on odd an even pages else a 2-page spread will be lopsided. You do, however, need a sufficiently wide marginpar width to accommodate the notes. This won't completely solve the problem because the notes will still overlap the line numbers, though. – cfr Feb 17 '15 at 2:33

There are 2 problems here:

1. The marginpar width is smaller than it needs to be to accommodate the margin notes. This can be fixed by setting the width using geometry.
2. The line numbers and the notes are competing for the same territory.

There are 2 obvious solutions. One is to flip the page numbers so that they are opposite from the margin notes:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[switch*]{lineno}
\usepackage[marginparwidth=12.5ex]{geometry}
\usepackage{marginnote}

\title{lineNumbersAndMarginNotes}

\begin{document}
\begin{linenumbers*}

Here is some text that has line numbers, the text is not important, but it needs to have a few lines otherwise it won't demonstrate the issue I would like to figure out. I don't just want a plug in solution\marginpar{\fbox{\parbox{10ex}{Here is a margin note, I think}}}, I'd really like to understand how to get the \texttt{geometry} package to act differently on odd and even pages.
\vfill
\newpage

Here is some text that has line numbers, the text is not important, but it needs to have a few lines otherwise it won't demonstrate the issue I would like to figure out. I don't just want a plug in solution\marginnote{\fbox{\parbox{10ex}{Here is a margin note, I think}}}, I'd really like to understand how to get the \texttt{geometry} package to act differently on odd and even pages.

\end{linenumbers*}

\end{document}


This has the advantage of symmetry.

Alternatively, you can alter the alignment of the margin notes, further increasing the size of marginpar to accommodate the line numbers and the notes when needed:

\usepackage{lineno}
\usepackage[marginparwidth=15ex]{geometry}
\usepackage{marginnote}
\renewcommand*{\raggedleftmarginnote}{\raggedright}
\renewcommand*{\raggedrightmarginnote}{\raggedleft}


I would also recommend not justifying the text inside the notes as this is not going to work well with such narrow width. Using ragged2e might also help.

• I do not want to flip the line numbers for certain technical reasons, but increasing the marginparsep is an option. Thank you – Zool Feb 23 '15 at 15:19

You can increase the marginparsep using geometry package:

\usepackage[marginparsep=7mm]{geometry}   %% adjust 7mm at will


Code:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{lineno}
\usepackage[marginparsep=7mm]{geometry}
\usepackage{marginnote}

\title{lineNumbersAndMarginNotes}

\begin{document}
\begin{linenumbers*}

Here is some text that has line numbers, the text is not important, but it needs to have a few lines otherwise it won't demonstrate the issue I would like to figure out. I don't just want a plug in solution\marginpar{\fbox{\parbox{10ex}{Here is a margin note, I think}}}, I'd really like to understand how to get the \texttt{geometry} package to act differently on odd and even pages.

\newpage

Here is some text that has line numbers, the text is not important, but it needs to have a few lines otherwise it won't demonstrate the issue I would like to figure out. I don't just want a plug in solution\marginnote{\fbox{\parbox{10ex}{Here is a margin note, I think}}}, I'd really like to understand how to get the \texttt{geometry} package to act differently on odd and even pages.

\end{linenumbers*}

\end{document}


You may want to put \raggedright inside the \parbox and adjust the marginparwidth too for your convenience.

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{lineno}
\usepackage[marginparwidth=12ex,marginparsep=7mm]{geometry}
\usepackage{marginnote}

\title{lineNumbersAndMarginNotes}

\begin{document}
\begin{linenumbers*}

Here is some text that has line numbers, the text is not important, but it needs to have a few lines otherwise it won't demonstrate the issue I would like to figure out. I don't just want a plug in solution\marginpar{\fbox{\parbox{10ex}{\raggedright Here is a margin note, I think}}}, I'd really like to understand how to get the \texttt{geometry} package to act differently on odd and even pages.

\newpage

Here is some text that has line numbers, the text is not important, but it needs to have a few lines otherwise it won't demonstrate the issue I would like to figure out. I don't just want a plug in solution\marginnote{\fbox{\parbox{10ex}{\raggedright Here is a margin note, I think}}}, I'd really like to understand how to get the \texttt{geometry} package to act differently on odd and even pages.

\end{linenumbers*}

\end{document}