A demonstration of the problem via a minimal working example
I saved the following LaTeX code in ~/Test.tex
.
\documentclass{article}
\usepackage[bidi=basic,hebrew,provide=*,layout=graphics]{babel}
\babelfont{rm}[Renderer=HarfBuzz]{FreeSans}
\usepackage{marginnote}
\usepackage{xcolor}
\begin{document}
מכל אלה שהתהלכתי אתם פעם בעיר מולדתי יקרה לי ביחוד%
\marginnote{\textcolor{blue}{%
שלום רב שובך, ציפורה נחמדת, מארצות החום אל חלוני.%
}} %LTR
בת שכננו מינה, אשר קראו לה גם בשם הגנאי ה’ברודה',%
\marginnote{\textcolor{red}{%
אל קולך כי ערב מה-נפשי כלתה בחורף בעוזבך מעוני.
}}% LTR
והיא נערה מנומרת בכתמי שמש שלא חוננה אמנם ביופי, אבל הן כבר ידוע המשפט של כלי החרס אשר בהם ישומר היין הטוב, וראינו גם אשר דברי אלהים חיים נכתבים על גויל פשוט.
\end{document}
The code creates a document of class article
, sets its main (and only) language to Hebrew, and, in the document's body, writes a paragraph of Hebrew text, in which two marginnote
s of Hebrew text are embedded in two locations. The text of the first marginnote
is colored blue, whereas that of the second one is colored red.
Before compiling the code, I took preemptive steps to avoid a known issue concerning marginnote
s in Hebrew documents, by implementing a variation on David Carlisle's hack: I made a local copy of marginnote.sty
(originally in /usr/local/texlive/2022/texmf-dist/tex/latex/marginnote/
), and replaced its line no. 363 with: \rlap{\kern-2.7\marginparwidth%
.see footnote
I then executed the following commands in the Terminal.
> cd ~
> lualatex Test
> lualatex Test
The compilation completed successfully with no warnings in ~/Test.log
; in particular, no warnings suggesting to rerun the compilation.
As a result of the compilation, the file ~/Test.pdf
was created. When this file was opened in a PDF viewer, it displayed as follows. (I screenshot only the relevant part of the display.)
As can be seen, the first (blue) marginnote
is positioned correctly in the margin, but the second (red) marginnote
is superimposed on the main text.
Questions
- Why is the second margin note superimposed on the main text?
- What can I do to fix the position of the second (and any other) margin note, while preserving the now correct position of the first margin note?
Footnote
It was Udi Fogiel, in a comment to a previous post of mine now deleted (due to being a duplicate of this question), who made me aware of the hack, and suggested the variation necessary to adapt it to the babel
+lualatex
combo that I use.