A description of the problem by way of a minimal working example
I saved the following LaTeX code in the file ~/Test.tex.
\documentclass{article}
\usepackage[hmarginratio=1:4]{geometry}
\usepackage[bidi=basic,hebrew,provide=*]{babel}
\usepackage{marginnote}
\makeatletter
\newif\if@RTL \@RTLtrue
\makeatother
\begin{document}
\[
x + y = z\marginnote{Hello, world!}
\]
\end{document}
The code creates a document of class article, and adjusts the relative width of the article's left and right margins. It then establishes Hebrew as the document's main, and only language via the babel package. Then, after loading the marginnote package, it implements a hack suggested by Javier Bezos to resolve an issue arising when the marginnote package interacts with Hebrew documents managed by babel. Then, in the document's body, an equation, in which a margin note is embedded, is written in display mode.
Then I executed the following commands in the Terminal.
> cd ~
> lualatex Test
> lualatex Test
The compilation completed successfully, with no warning in ~/Test.log; in particular, no warning suggesting to rerun lualatex. As a consequence of the compilation, the file ~/Test.pdf was created. When opened in a PDF viewer the file displayed as follows. (I screenshot only the relevant part of the display.)
As can be seen, there's no margin note on the page.
Questions
- Why wasn't the margin note printed out?
- What can I do to make the margin note appear without giving up on the elements that make up the preamble: the
geometrypackage with adjusted margins, thebabelpackage with Hebrew as the main language, and Javier Bezos' hack. (Actually, the hack can be done away with, as long as it is replaced by another solution to this problem, but I'd prefer it if Bezos' elegant hack could be retained.)



\@RTLtruehack. That is clearly meant for compatibility with the bidi package and so for xelatex but the bidi models of xelatex and lualatex are different. – Ulrike Fischer Dec 30 '22 at 21:49\let\mymarginnote\marginnoteafter\usepackage{marginnote}but before your patch, and use\mymarginnoteinside the equation instead of\marginnote, I get the same erroneous result. – Evan Aad Dec 30 '22 at 22:17\@RTLfalsebefore the equation. But imho you will have to properly test and adapt marginnote. That mean make a copy, e.g. bidi-marginnote, and then study the code and test changes. – Ulrike Fischer Dec 30 '22 at 23:32