8

I would like to be able to use marginnote in a two-sided book, but have all notes appear on the left margin. There is an older solution to this problem here, and there's a parallel older answer that puts all notes on the right margin here. Neither of those solutions work any longer, however, because of updates to marginnote.

There is a working solution for putting all notes on the right margin here, but I'm unfortunately not capable of adapting it to the left margin by myself.

Small example

\documentclass[twoside]{book}
\usepackage{marginnote}
\usepackage{lipsum}

\begin{document}

\lipsum[1]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]

\end{document}

2 Answers2

9

As there are tests for twoside everywhere in the code (and it affects spacing and other things), it is imho the best to locally set twoside to false:

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

\makeatletter
\patchcmd{\@mn@@@marginnote}{\begingroup}{\begingroup\@twosidefalse}{}{\fail}
\reversemarginpar
\makeatother

\begin{document}

\lipsum[1]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]

\end{document}
Ulrike Fischer
  • 327,261
  • That would affect the overall layout of that section of the book in many other ways, no? (The example document is one thing, but the actual code needs to run in part of one chapter of a long book.) – Telemachus Jan 31 '19 at 15:10
  • I don't think that it affects the layout - the change is locally in the marginnote, and unless you need a twoside test there, it it will not be seen by the rest of the document. – Ulrike Fischer Jan 31 '19 at 15:13
  • Ah, I see. I'll try that out and see if it has any other side effects. Thanks. – Telemachus Jan 31 '19 at 15:14
  • It does have an odd side effect: even-numbered pages end up with an extra indentation after the margin note. (I.e., the rest of the content starts oddly far to the right.) – Telemachus Jan 31 '19 at 15:19
  • 1
    Sorry I have no idea what you mean. I see nothing curious in the output. – Ulrike Fischer Jan 31 '19 at 15:27
  • Okay. I'll wait to see if other answers appear. Thanks for your suggestion. – Telemachus Jan 31 '19 at 15:45
  • 1
    I see the issue now: your version has this line \usepackage[centering,marginparwidth=2.5cm,paperheight=10cm]{geometry}. That line was briefly in my sample code, which I took from another question here, but it is not in my document and I quickly removed it from the MWE above. If you run the MWE without it, you'll see that the marginal comments for odd pages are fine, but those for even pages are oddly far to the left. I didn't describe what I was seeing very clearly, and I'm sorry for that. Thanks for your suggestion. – Telemachus Feb 01 '19 at 23:21
2

Per this answer, there is an analogous cludge to the marginnote package to put everything on the left, obtained by preserving the other case from the code defining \@mn@@@marginnote. This is given below.

\documentclass[twoside]{book}
\usepackage{marginnote}
\usepackage{lipsum}
%
%
\makeatletter
\long\def\@mn@@@marginnote[#1]#2[#3]{%
  \begingroup
    \ifmmode\mn@strut\let\@tempa\mn@vadjust\else
      \if@inlabel\leavevmode\fi
      \ifhmode\mn@strut\let\@tempa\mn@vadjust\else\let\@tempa\mn@vlap\fi
    \fi
    \@tempa{%
      \vbox to\z@{%
        \vss
        \@mn@margintest
        \if@reversemargin\if@tempswa
            \@tempswafalse
          \else
            \@tempswatrue
        \fi\fi

          \llap{%
            \vbox to\z@{\kern\marginnotevadjust\kern #3
              \vbox to\z@{%
                \hsize\marginparwidth
                \linewidth\hsize
                \kern-\parskip
                %\mn@parboxrestore
                \marginfont\raggedleftmarginnote\strut\hspace{\z@}%
                \ignorespaces#1\endgraf
                \vss
              }%
              \vss
            }%
            \if@mn@verbose
              \PackageInfo{marginnote}{xpos seems to be \@mn@currxpos}%
            \fi
            \begingroup
              \ifx\@mn@currxpos\relax\else\ifx\@mn@currpos\@empty\else
                  \kern\@mn@currxpos
              \fi\fi
              \ifx\@mn@currpage\relax
                \let\@mn@currpage\@ne
              \fi
              \if@twoside\ifodd\@mn@currpage\relax
                  \kern-\oddsidemargin
                \else
                  \kern-\evensidemargin
                \fi
              \else
                \kern-\oddsidemargin
              \fi
              \kern-1in
            \endgroup
            \kern\marginparsep
          }%
      }%
    }%
  \endgroup
}
\makeatother
%
\begin{document}

\lipsum[1]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]\marginnote{test test test test test}
\lipsum[1-2]

\end{document}

Note that there is a line %\mn@parboxrestore which I have commented out (because it didn't work on my system with it not commented out). This is almost surely because the version of marginnote in my system is not the most recent, but this snippet of code is taken from marginnote.sty, which can be found (for example) at this URL. It would be worth trying this on your system with this line uncommented.

rbrignall
  • 1,564
  • This works perfectly for me with the line commented out. Thank you for taking the time to rewrite your answer for the opposite situation. – Telemachus Feb 01 '19 at 18:35