4

Consider the following MWE:

\documentclass[oneside,leqno,fleqn]{book}
\usepackage{marginnote}

\usepackage{geometry}
\geometry{%
left=70mm,
textwidth=130mm,
marginparsep=8.2mm,
marginparwidth=50mm,
showframe
}

\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\defaultfontfeatures{Scale = MatchUppercase , Ligatures =TeX}
\newfontfamily\englishfont{Latin Modern Roman}[Script=Latin,Language=English]
\newfontfamily\hebrewfont{David CLM}[Script=Hebrew]

\begin{document}
לורם איפסום דולור סיט אמט.
\marginnote{זו הערה שצריכה להופיע בשולי הדף}
\end{document}

enter image description here

Why is the marginnote text not typed in the margin paragraph area? How to fix it?

3
  • 1
    marginnote adds the note with \rlap so it has zero width and sticks out on one side, but it's getting the wrong side in rtl contexts by the look of it. Mar 29, 2022 at 13:20
  • See also the answers to this question, which solve - at least when the language engine is babel+lualatex - both the problem raised in your post, as well as the further problems caused by the hack suggested below by David Carlisle.
    – Evan Aad
    Dec 30, 2022 at 6:55
  • @EvanAad the problem in your link comes from the fact that there is no RTL support without the conditional \if@RTL, which is not the case here, as the problem happens only with xelatex+bidi. See my answer.
    – Udi Fogiel
    Mar 3 at 1:42

2 Answers 2

2

I think that the source of that deviation is from the fact that bidi changes the value of \oddsidemargin. Note that by default marginnote should be touching the right border of the marginpar part. Here is a quick patch that should solve your particular case

%!TEX TS-program = xelatex

\documentclass[oneside,leqno,fleqn]{book}
\usepackage{marginnote}
\usepackage{regexpatch}
\makeatletter
\xpatchcmd{\@mn@@@marginnote}{\else\kern\oddsidemargin}{%
    \else
    \@mn@if@RTL{%
        \kern\dimexpr\mn@pagewidth-\marginnotetextwidth-\oddsidemargin-2in\relax
    }{%
        \kern\oddsidemargin
    }%
}{}{}
\makeatother
\usepackage{geometry}
\geometry{%
    left=70mm,
    textwidth=130mm,
    marginparsep=8.2mm,
    marginparwidth=50mm,
    showframe
}

\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\defaultfontfeatures{Scale = MatchUppercase , Ligatures =TeX}
\newfontfamily\englishfont{Latin Modern Roman}[Script=Latin,Language=English]
\newfontfamily\hebrewfont{David CLM}[Script=Hebrew]

\begin{document}
    לורם איפסום דולור סיט אמט.
    \marginnote{זו הערה שצריכה להופיע בשולי הדף}
\end{document}

enter image description here

With lualatex you wont get this deviation

%!TEX TS-program = lualatex

\documentclass[oneside,leqno,fleqn]{book}
\usepackage{marginnote}

\usepackage{geometry}
\geometry{%
    right=70mm, %<-- note the change
    textwidth=130mm,
    marginparsep=8.2mm,
    marginparwidth=50mm,
    showframe
}

\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\defaultfontfeatures{Scale = MatchUppercase , Ligatures =TeX}
\newfontfamily\englishfont{Latin Modern Roman}[Script=Latin,Language=English]
\newfontfamily\hebrewfont{David CLM}[Script=Hebrew]

\begin{document}
    לורם איפסום דולור סיט אמט.
    \marginnote{זו הערה שצריכה להופיע בשולי הדף}
\end{document}
5

If you take a local copy of marginnote.sty and modify line 364 by

          \rlap{%
\kern-\marginparwidth%  added

You get

enter image description here

But not reading Hebrew or knowing the marginnote code that well, I'm not sure if this covers all the possible cases of left and right margins and oneside and twoside options, probably not.....

You must log in to answer this question.

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