Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\leqno is broken in r2l paragraphs. #259

Open
Udi-Fogiel opened this issue Aug 22, 2023 · 3 comments
Open

\leqno is broken in r2l paragraphs. #259

Udi-Fogiel opened this issue Aug 22, 2023 · 3 comments

Comments

@Udi-Fogiel
Copy link
Contributor

This is more a bug in the LuaTeX engine, but babel need to be aware of that (and maybe to find a workaround if it won't be fixed).
Here is a small example

\pardirection=1
$$1+2=3 \leqno(1)$$
\bye

This break files that use r2l script as a second language.
Here is an example using babel

\documentclass{article}

\usepackage[hebrew,english,provide*=*,bidi=basic]{babel}

\begin{document}
\selectlanguage{hebrew}
\begin{equation}
1+2=3
\end{equation}
\end{document}

I've sent an email to luatex-dev, I'll update if and when I'll get an answer.

@jbezos
Copy link
Contributor

jbezos commented Aug 29, 2023

This wouldn’t be the first workaround to fix some issue in luatex math. Currently there is a dirty hack related to \[ ... \] (search the dtx for the string ‘YA luatex bug?’), which seems to do the job and I haven't had time to investigate further.

@Udi-Fogiel
Copy link
Contributor Author

The only idea I have for a fix is to use \eqno, fix the horizontal placing by translating the box, and then fix the vertical spacing with the aid of the pre_append_to_vlist_filter callback (which is not a part of the kernel yet I believe, the lua-ul package defines it in a lua module).

Do you think it is too involved for such a small thing?

@jbezos
Copy link
Contributor

jbezos commented Aug 16, 2024

@Udi-Fogiel Any answer from luatex-dev? I've devised a pure TeX solution, somewhat ad hoc and hackish, which seems to work, at least in simple cases:

\AddBabelHook[hebrew]{equation}{afterextras}{%
  \def\beforeequation{%
    \vskip-\baselineskip\vskip\abovedisplayskip
    \begin{otherlanguage*}{english}\pardir TLT
    \def\afterequation{\end{otherlanguage*}}}}
    
\let\afterequation\relax
\AddBabelHook[english]{equation}{afterextras}{%
  \let\beforeequation\relax}
  
\AddToHook{env/equation/before}{\beforeequation}
\AddToHook{env/equation/after}{\afterequation}

Although there are some workarounds in babel for a few luatex ‘oddities’, they are more or less simple, and necessary even in very basic documents. I don’t think that’s also the case, so I would say this bug should be fixed at the engine level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants