2

I am trying to get margin notes (using scrlayer-notecolumn) to align left or right, depending on wether they appear on a odd or even page in a twoside scrbook. The following works fine so far:

\documentclass[12pt,a4paper,twoside,mpinclude=true]{scrbook}
\usepackage{lipsum}
\usepackage{changepage} 
\usepackage[left=2 cm,right=2 cm,bottom=6cm]{geometry}

\evensidemargin=4\marginparwidth
%\oddsidemargin=2cm
\setlength{\marginparwidth}{4\marginparwidth}
\setlength{\textwidth}{0.6\textwidth}
\let\oldmarginpar\marginpar

\usepackage{scrlayer-notecolumn}
\DeclareNewNoteColumn[%
    marginpar,
    width=\marginparwidth,%
    font=% 
        \checkoddpage 
        \ifoddpage \raggedright\footnotesize
        \else\raggedleft\footnotesize 
        \fi%
]%
{notes}

\usepackage[autooneside=false]{scrlayer-scrpage}

\emergencystretch=3em


\begin{document}

\lipsum[1-2]\makenote[notes]{\lipsum[1]}
\lipsum[1-4]\makenote[notes]{\lipsum[1]}
\lipsum[1-2]

\end{document}

Yet, when the notes break pages (the main reason I use scrlayer-notecolumn instead of the normal \marginpar) the text alignment stays the same.

Is there a way to make it switch automatically?

2
  • I can't see what you describe: here I get a marginnote on p. 1 on the right, which continues on p. 2 in the left margin. Other way round on p2/3. Seems ok! Maybe update your tex-installation? – Keks Dose Dec 20 '19 at 14:51
  • no, that is how it is supposed to be. the problem is the text alignment: a note on even pages (in the left margin) should be \raggedleft, when the note appears in the right margin it should instead be \raggedright. if the note, however, continues from one page to the next, it keeps its text alignment when, in fact, I want it to change according to my definition. – moritzklenk Dec 21 '19 at 13:52
0

After some try & error I guess that the marginnote is typeset (raggedright, raggedleft, whatever) completely at shipout of the page were it begins. I tried things like

\usepackage{everypage}
\AddEverypageHook{%
  \checkoddpage 
  \ifoddpage%
  \RedeclareNoteColumn[font=\RaggedRight]{notes}%
  \else\RedeclareNoteColumn[font=\RaggedLeft]{notes}\fi%
}

...but without success.

So my answer is that you can't change the layout of a marginnote at pagebreak without a hack of the internals of KOMA-script.

However, while testing I noticed that a ragged left beginning of a new line in the marginnote isn't easy to read.

So I'd suggest to print marginnotes always »ragged right«. Use the package ragged2e and its command \RaggedRight.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.