babel
and lualatex. Here's the example I was playing with:
Code: Select all
% !TEX lualatex
\documentclass{article}
\PassOptionsToPackage{no-math}{fontspec}
\usepackage[bidi=basic, layout=tabular]{babel}
\babelprovide[main, import, alph=letters, Alph=letters]{hebrew}
\babelprovide[import]{english}
% Font setup
\babelfont[hebrew]{rm}[Renderer=HarfBuzz]{David CLM}
\babelfont[hebrew]{sf}[Renderer=HarfBuzz]{Miriam CLM}
\babelfont[hebrew]{tt}[Renderer=HarfBuzz]{Miriam Mono CLM}
\babelfont{david}[Renderer=HarfBuzz]{David CLM}
\usepackage{amsmath}
\usepackage{xparse}
\NewDocumentCommand{\OverSet}{ O{0cm} m m }{
\overset{\raise #1 \hbox{\(#2\)}}{#3}
}
\begin{document}
\begin{equation}\label{eq:pythagoras}
a^2 + b^2 = c^2
\end{equation}
לפי משוואה
\eqref{eq:pythagoras}
נסיק כי
\begin{align*}
c^4 \OverSet[0.05cm]{\scriptstyle\eqref{eq:pythagoras}}{=} (a^2 + b^2)^2
\end{align*}
נמשיך
\end{document}
align
and gather
environments. Using an equation
environment (or simply \[ \]
) doesn't cause this problem. I found that wrapping the align
environment in the \babelsublr{}
command fixes this issue:
Code: Select all
\babelsublr{
\begin{align*}
c^4 \OverSet[0.05cm]{\scriptstyle\eqref{eq:pythagoras}}{=} (a^2 + b^2)^2
\end{align*}}
eq:pythagoras
reference. Removing the \babelsublr{}
command made it compile, but the problem of the reference not being centered has returned. Another weird result I found is that if I comment out the remainder of the code (The line "נמשיך" in the above example) and end the document with this align
environment wrapped inside \babelsublr{}
, then it compiles successfully, and the result is correct.I am very confused by this. I thought that using
\babelsublr{}
solves this issue and it always worked for me on Overleaf, but when I try it locally, it doesn't work unless it's the end of the document. On my machine, I use TexLive 2023, and I compile using the default "latexmk (lualatex)" recipe of the Latex Workshop extension.Can somebody explain why the solution of
\babelsublr{}
works on Overleaf, but not locally? Alternatively, can somebody suggest a better solution that works both locally and on Overleaf?