LaTeX forum ⇒ Generaleqref fails in local compilation, but works on Overleaf?

LaTeX specific issues not fitting into one of the other forums of this category.
Shai-Avr
Posts: 8
Joined: Tue Aug 22, 2023 11:30 am

eqref fails in local compilation, but works on Overleaf?

Postby Shai-Avr » Mon Mar 25, 2024 11:56 am

I am trying to transition from Overleaf to a local workspace and set up VSCode with the Latex Workshop extension as my Latex IDE, and I faced a weird problem. I work on Hebrew documents and I use babel and lualatex. Here's the example I was playing with:
% !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}

Compiling this example with Luatex both on overleaf and locally makes the reference above the equal sign to be out of place:
kxX9s.png
kxX9s.png (13.6 KiB) Viewed 381 times

The weird part is that this seems to happen only in the 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:
\babelsublr{
\begin{align*}
c^4 \OverSet[0.05cm]{\scriptstyle\eqref{eq:pythagoras}}{=} (a^2 + b^2)^2
\end{align*}}

EJAx7.png
EJAx7.png (13 KiB) Viewed 381 times

So it looks like the problem is solved and this is the solution I have been using until now. When I tried the same example on my local machine in VSCode, it didn't compile and it claimed it couldn't find the 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?

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
Stefan Kottwitz
Site Admin
Posts: 10159
Joined: Mon Mar 10, 2008 9:44 pm

eqref fails in local compilation, but works on Overleaf?

Postby Stefan Kottwitz » Mon Mar 25, 2024 12:26 pm

It seems that the detection and handling of digits don't work well in this combination of luatex, bidi text, and amsmath with the \eqref command. It works without the bidi option; and it works with explicitly using \babelsublr.

You can use \ref with parentheses instead, then you have the proper alignment:

c^4 \OverSet[0.05cm]{\scriptstyle(\ref{eq:pythagoras})}{=} (a^2 + b^2)^2


Stefan
LaTeX.org admin

Shai-Avr
Posts: 8
Joined: Tue Aug 22, 2023 11:30 am

eqref fails in local compilation, but works on Overleaf?

Postby Shai-Avr » Fri Mar 29, 2024 3:03 pm

I would prefer to use \eqref (It might be silly, but I like that the link is on the entire reference including the parenthesis). It doesn't explain why \eqref fails to make references inside the \babelsublr command and why it fails only locally and not on Overleaf.


Return to “General”

Who is online

Users browsing this forum: No registered users and 8 guests