missing displacement when leqno is used in rtl paragraph
Hello, I think that displacement of a the of a math display is missing when \leqno is used in RTL paragraph. I attached a patch. Here is a simple test code (it requires the cmr10 font): \catcode`\{=1\catcode`\}=2\catcode`\$=3 \directlua{tex.enableprimitives("",{"pardirection", "textdirection", "Umathquad"})} \tracingoutput=1\tracingonline=1 \showboxbreadth 16384 \showboxdepth 16384 \font\tenrm=cmr10 \textfont0=\tenrm \hsize=345pt\vsize=550pt\parfillskip=0.0pt plus 1.0fil \parindent=15pt\parskip=0pt plus1pt \Umathquad\textstyle=10pt \pardirection=1\textdirection=1 $$1 \leqno(1)$$ \end Udi
On Thu, Jan 30, 2025 at 6:35 PM luigi scarso
On Thu, 30 Jan 2025 at 17:29, Udicoudco
wrote: I think that displacement of a the of a math display is missing when \leqno is used in RTL paragraph.
I attached a patch.
Ok, I will check it asap.
Luigi, after testing all the branches it seems there are a couple more that should be fixed. Sorry for not checking that before. I attached a new patch (to be applied on the current master, not on top of the last one). I have tested all the branches with the following: \catcode`\{=1\catcode`\}=2\catcode`\$=3 \directlua{tex.enableprimitives("",{"Umathquad", "mathdirection", "predisplaydirection"})} \font\tenrm=cmr10 \textfont0=\tenrm \tenrm \hsize=345pt\vsize=550pt\parfillskip=0.0pt plus 1.0fil \parindent=15pt\parskip=0pt plus1pt \Umathquad\textstyle=10pt \mathdirection=0 (l)=true swapdir=true mathdir=TLT $$\predisplaydirection=-1 1 \eqno(1)$$ \mathdirection1 (l)=true swapdir=true mathdir=TRT $$\predisplaydirection=-1 1 \eqno(1)$$ \mathdirection=0 (l)=true swapdir=false mathdir=TLT $$\predisplaydirection=0 1 \leqno(1)$$ \mathdirection1 (l)=true swapdir=false mathdir=TRT $$\predisplaydirection=0 1 \leqno(1)$$ \mathdirection=0 (l)=false swapdir=true mathdir=TLT $$\predisplaydirection=-1 1 \leqno(1)$$ \mathdirection1 (l)=false swapdir=true mathdir=TRT $$\predisplaydirection=-1 1 \leqno(1)$$ \mathdirection=0 (l)=false swapdir=false mathdir=TLT $$\predisplaydirection=0 1 \eqno(1)$$ \mathdirection1 (l)=false swapdir=false mathdir=TRT $$\predisplaydirection=0 1 \eqno(1)$$ \end I also attached the results I get with the current master (display_current.pdf) and with the patch (display_fixed.pdf). Udi
On Thu, 30 Jan 2025 at 19:50, Udicoudco
On Thu, Jan 30, 2025 at 6:35 PM luigi scarso
wrote: On Thu, 30 Jan 2025 at 17:29, Udicoudco
wrote: I think that displacement of a the of a math display is missing when \leqno is used in RTL paragraph.
I attached a patch.
Ok, I will check it asap.
Luigi, after testing all the branches it seems there are a couple more that should be fixed. Sorry for not checking that before.
Ok, I will check it this weekend . -- luigi
On Fri, 31 Jan 2025 at 19:55, luigi scarso
Ok, I will check it this weekend .
commit f6a1b6bf26c4f91fecd67a0279fa2ea31f67c846 (HEAD -> master,
origin/master, origin/HEAD)
Author: Luigi Scarso
On Fri, Jan 31, 2025 at 8:56 PM luigi scarso
Luigi, after testing all the branches it seems there are a couple more that should be fixed. Sorry for not checking that before.
Ok, I will check it this weekend .
I've tested a little bit more, and unfortunately the situation is more complicated than I thought. It seems the value of \pagedirection at shipout time affects the position (but not direction) of horizontal boxes. If \pagedirection is 0 at shipout time, hboxes are left aligned with the page box, If \pagedirection is 1 at shipout time, hboxes are right aligned with the page box. This means if the equation box's (including the kern and equation number) width is less than the line width, the position of the equation will be dependent on the value of \pagedirection at shipout time. Since we can't know what will be the value of \pagedirection at shipout time in finish_displayed_math, the only solution I can think of, is to make sure the equation box has the width of a line, by padding with white (a kern) space if needed. Is this an acceptable solution?
_______________________________________________ dev-luatex mailing list -- dev-luatex@ntg.nl To unsubscribe send an email to dev-luatex-leave@ntg.nl
On 2/1/2025 11:44 AM, Udicoudco wrote:
On Fri, Jan 31, 2025 at 8:56 PM luigi scarso
wrote: Luigi, after testing all the branches it seems there are a couple more that should be fixed. Sorry for not checking that before.
Ok, I will check it this weekend .
I've tested a little bit more, and unfortunately the situation is more complicated than I thought.
It seems the value of \pagedirection at shipout time affects the position (but not direction) of horizontal boxes. If \pagedirection is 0 at shipout time, hboxes are left aligned with the page box, If \pagedirection is 1 at shipout time, hboxes are right aligned with the page box.
This means if the equation box's (including the kern and equation number) width is less than the line width, the position of the equation will be dependent on the value of \pagedirection at shipout time.
Since we can't know what will be the value of \pagedirection at shipout time in finish_displayed_math, the only solution I can think of, is to make sure the equation box has the width of a line, by padding with white (a kern) space if needed. Is this an acceptable solution?
You can best try to handle this at the macro level. Page direction can badly interfere anyway and every change we make to the diretion code will introduce another issue. Just don't use it. FWIW, in luametatex we don't even have \pagedirection any more. With r2l typesetting one needs to keep a lot in mind, because nto all bozes one can come up with need to be reflected. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Am Sat, 1 Feb 2025 14:41:57 +0100 schrieb Hans Hagen:
You can best try to handle this at the macro level. Page direction can badly interfere anyway and every change we make to the diretion code will introduce another issue. Just don't use it. FWIW, in luametatex we don't even have \pagedirection any more.
I came to the same conclusion after doing a number of tests (in https://github.com/LaTeX-Package-Repositories/geometry/issues/20#issuecommen...) where my summary was "As you want 'left margin' to mean 'left margin' imho the correct way to handle this not to set these directions at all. It looks wrong to change all reference points and then to add lots of complicated calculations to get the old behaviour back." -- Ulrike Fischer http://www.troubleshooting-tex.de/
On Sat, Feb 1, 2025 at 4:24 PM Ulrike Fischer
Am Sat, 1 Feb 2025 14:41:57 +0100 schrieb Hans Hagen:
You can best try to handle this at the macro level. Page direction can badly interfere anyway and every change we make to the diretion code will introduce another issue. Just don't use it. FWIW, in luametatex we don't even have \pagedirection any more.
I came to the same conclusion after doing a number of tests (in https://github.com/LaTeX-Package-Repositories/geometry/issues/20#issuecommen...) where my summary was "As you want 'left margin' to mean 'left margin' imho the correct way to handle this not to set these directions at all. It looks wrong to change all reference points and then to add lots of complicated calculations to get the old behaviour back."
I was probably rambling too much :) In practice there is only one bad case left, which could be fixed like the other cases: \catcode`\{=1\catcode`\}=2\catcode`\$=3 \directlua{tex.enableprimitives("",{"Umathquad", "mathdirection", "predisplaydirection", "pagedirection", "bodydirection"})} \font\tenrm=cmr10 \textfont0=\tenrm\textfont1=\tenrm \tenrm \hsize=345pt\vsize=550pt\parfillskip=0.0pt plus 1.0fil \parindent=15pt\parskip=0pt plus1pt \Umathquad\textstyle=10pt \mathdirection1 (l)=false swapdir=true mathdir=TRT $$\predisplaydirection=-1 1 \leqno(1)$$ \pagedirection=1\bodydirection=1 \end but as you suggested' I'm trying to avoid the usage of \pagedirection and \bodydirection, so I don't have a strong opinion if it should be fixed or not. I attached another patch. *Most Importantly* this patch also amends the last one, as I did not consider correctly some cases in a situation where the equation number is "too close". If you don't want to fix this last case, I'll send a patch which only fixes the last commit. Udi
On Sat, 1 Feb 2025 at 17:18, Udicoudco
On Sat, Feb 1, 2025 at 4:24 PM Ulrike Fischer
wrote: Am Sat, 1 Feb 2025 14:41:57 +0100 schrieb Hans Hagen:
You can best try to handle this at the macro level. Page direction can badly interfere anyway and every change we make to the diretion code will introduce another issue. Just don't use it. FWIW, in luametatex we don't even have \pagedirection any more.
I came to the same conclusion after doing a number of tests (in
https://github.com/LaTeX-Package-Repositories/geometry/issues/20#issuecommen... )
where my summary was "As you want 'left margin' to mean 'left margin' imho the correct way to handle this not to set these directions at all. It looks wrong to change all reference points and then to add lots of complicated calculations to get the old behaviour back."
I was probably rambling too much :) In practice there is only one bad case left, which could be fixed like the other cases:
\catcode`\{=1\catcode`\}=2\catcode`\$=3 \directlua{tex.enableprimitives("",{"Umathquad", "mathdirection", "predisplaydirection", "pagedirection", "bodydirection"})}
\font\tenrm=cmr10 \textfont0=\tenrm\textfont1=\tenrm \tenrm \hsize=345pt\vsize=550pt\parfillskip=0.0pt plus 1.0fil \parindent=15pt\parskip=0pt plus1pt \Umathquad\textstyle=10pt
\mathdirection1 (l)=false swapdir=true mathdir=TRT $$\predisplaydirection=-1 1 \leqno(1)$$
\pagedirection=1\bodydirection=1 \end
but as you suggested' I'm trying to avoid the usage of \pagedirection and \bodydirection, so I don't have a strong opinion if it should be fixed or not.
I attached another patch. *Most Importantly* this patch also amends the last one, as I did not consider correctly some cases in a situation where the equation number is "too close".
If you don't want to fix this last case, I'll send a patch which only fixes the last commit.
I apply the patch on gitlab-lisn but I wait to upload it to texlive; if there are problems we will decide the final version. -- luigi
On Sat, 1 Feb 2025 at 18:37, luigi scarso
but I wait to upload it to texlive; if there are problems we will decide the final version.
commit 421124f24a8b3e07127716cb7edd68498f359d50 (HEAD -> master,
origin/master, origin/HEAD)
Author: Luigi Scarso
On Sat, 1 Feb 2025 at 18:54, luigi scarso
On Sat, 1 Feb 2025 at 18:37, luigi scarso
wrote: I apply the patch on gitlab-lisn
but I wait to upload it to texlive; if there are problems we will decide the final version.
commit 421124f24a8b3e07127716cb7edd68498f359d50 (HEAD -> master, origin/master, origin/HEAD) Author: Luigi Scarso
Date: Sat Feb 1 18:52:46 2025 +0100 Again on missing displacement when leqno is used in rtl paragraph (thanks to udifoglle@gmail.com). LuaTeX 1.20.8
In texlive now, revision 73690. -- luigi
On Mon, 3 Feb 2025 at 14:23, Javier B
In texlive now, revision 73690.
Where can I find a binary for Windows? I’m not sure, but very likely I have to rewrite some code in babel, which was somewhat hackish to overcome the bug with \leqno and \eqno. I hope I have time.
https://gitlab.lisn.upsaclay.fr/texlive/luatex.git is the official repo of luatex. I think that WSL2 should work without problem, you can install the mingw cross-compiler if you need the exe. -- luigi
you can install the mingw cross-compiler if you need the exe.
Thanks, but I need the binary, and the version in texlive/trunk/Master/bin/windows is 2 months old. Otherwise I’ll have to wait for the first pretests of the new TeXLive with the binary already compiled and I find it difficult to have time to review it and, if necessary, fix it. Javier
On Sat, Feb 1, 2025 at 2:42 PM Hans Hagen
Page direction can badly interfere anyway and every change we make to the diretion code will introduce another issue.
Please be careful if you make any changes. Babel relies heavily on \pagedirection for bidirectional documents. Javier
participants (5)
-
Hans Hagen
-
Javier B
-
luigi scarso
-
Udicoudco
-
Ulrike Fischer