# marginnote always on right side of the page

My documentclass is book, so I've got an even and odd sides. I like that the equation number are always aligned on the right side - independent of the page (even/odd). I started using marginnotes. I wanted to do the same, that the notes are always on the right side of the page? How do I do that?

-
I know, you asked for the standard class book and Gonzalo Medina has already presented a brilliant answer, but with the KOMA-script class scrbookit would be a simple class option: \documentclass[twoside=semi]{scrbook}. I don’t know the class memoir, but I wouldn’t be surprised, when there were a similar option. In general both in KOMA-script and in memoir there are a lot of settings available as simple options or commands, which need massive redefinition in a standard class, cf. Gonzalo’s answer. – Speravir Aug 31 '12 at 22:08

Here's one possible solution patching (with the help of the etoolbox package) the LaTeX kernel command \@addmarginpar:

\documentclass[twoside]{book}
\usepackage[centering,marginparwidth=2.5cm]{geometry}
\usepackage{etoolbox}
\usepackage{lipsum}

\makeatletter
\makeatother
\reversemarginpar

\begin{document}

\chapter{Test Chapter One}
\section{Test Section}
\lipsum[2]\marginpar{test marginnote one}
\lipsum[2-4]\marginpar{test marginnote two}
\lipsum[2-4]\marginpar{test marginnote three}
\lipsum[4-5]]\marginpar{test marginnote three}
\lipsum[6]

\end{document}


With this layout for marginnotes, it's convenient to activate the centering option for the geometry package; further adjustments might be needed so that marginnotes on even pages can be correctly displayed on a printed document.

The above code provides a solution for the standard LaTeX \marginpar command; if \marginnote (from the marginnote package) is used instead of \marginpar to produce the margin notes, then the internal macro \@mn@@@marginnote will have to be redefined:

\documentclass[twoside]{book}
\usepackage[centering,marginparwidth=2.5cm]{geometry}
\usepackage{marginnote}
\usepackage{lipsum}

\makeatletter
\long\def\@mn@@@marginnote[#1]#2[#3]{%
\begingroup
\if@inlabel\leavevmode\fi
\fi
\@tempa{%
\vbox to\z@{%
\vss
\@mn@margintest
\if@reversemargin\if@tempswa
\@tempswafalse
\else
\@tempswatrue
\fi\fi
\rlap{%
\ifx\@mn@currxpos\relax
\if@mn@verbose
\PackageInfo{marginnote}{%
xpos not known,\MessageBreak
\fi
\else\ifx\@mn@currxpos\@empty
\if@mn@verbose
\PackageInfo{marginnote}{%
xpos not known,\MessageBreak
\fi
\else
\if@mn@verbose
\PackageInfo{marginnote}{%
xpos seems to be \@mn@currxpos,\MessageBreak
\space ignored}%
\fi
\begingroup
\setlength{\@tempdima}{\@mn@currxpos}%
\kern-\@tempdima
\if@twoside\ifodd\@mn@currpage\relax
\kern\oddsidemargin
\else
\kern\evensidemargin
\fi
\else
\kern\oddsidemargin
\fi
\kern 1in
\endgroup
\fi
\fi
\kern\marginnotetextwidth\kern\marginparsep
\vbox to\z@{%
\hsize\marginparwidth
\linewidth\hsize
\kern-\parskip
\marginfont\raggedrightmarginnote\strut\hspace{\z@}%
\ignorespaces#2\endgraf
\vss}%
\vss}%
}%
}%
}%
\endgroup
}
\makeatother

\begin{document}

\chapter{Test Chapter One}
\section{Test Section}
\lipsum[2]\marginnote{test marginnote one}
\lipsum[2-4]\marginnote{test marginnote two}
\lipsum[2-4]\marginnote{test marginnote three}
\lipsum[4-5]\marginnote{test marginnote three}
\lipsum[6]

\end{document}


-