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}
5
  • Make a minimal example that can be used for tests. Commented Jan 31, 2019 at 14:26
  • @UlrikeFischer Done.
    – Telemachus
    Commented Jan 31, 2019 at 14:54
  • Sorry! but may be I haven't well understood the question Commented Jan 31, 2019 at 15:05
  • So you want all the notes on the left margin? Commented Jan 31, 2019 at 15:07
  • @HafidBoukhoulda Yes. That's precisely what I want.
    – Telemachus
    Commented Jan 31, 2019 at 15:08

2 Answers 2

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.

1
  • 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
    Commented Feb 1, 2019 at 18:35
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}
7
  • 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
    Commented Jan 31, 2019 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. Commented Jan 31, 2019 at 15:13
  • Ah, I see. I'll try that out and see if it has any other side effects. Thanks.
    – Telemachus
    Commented Jan 31, 2019 at 15:14
  • 1
    Sorry I have no idea what you mean. I see nothing curious in the output. Commented Jan 31, 2019 at 15:27
  • 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
    Commented Feb 1, 2019 at 23:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .