On Thu, Jan 30, 2025 at 6:35 PM luigi scarso <[email protected]> wrote:
>
>
>
> On Thu, 30 Jan 2025 at 17:29, Udicoudco <[email protected]> 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

Attachment: display_fixed.pdf
Description: Adobe PDF document

diff --git a/source/texk/web2c/luatexdir/tex/texmath.c b/source/texk/web2c/luatexdir/tex/texmath.c
index 8b6138e7c..e1f100c60 100644
--- a/source/texk/web2c/luatexdir/tex/texmath.c
+++ b/source/texk/web2c/luatexdir/tex/texmath.c
@@ -2564,23 +2564,20 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
             if (swap_dir) {
                 if (math_direction_par==dir_TLT) {
                     /*tex TRT + TLT + \eqno: (swap_dir=true,  math_direction_par=TLT, l=true) */
-                    s = new_kern(width(r) + eqno_w);
-                    try_couple_nodes(eqno_box,r);
-                    try_couple_nodes(r,eq_box);
-                    try_couple_nodes(eq_box,s);
                 } else {
                     /*tex TLT + TRT + \eqno: (swap_dir=true,  math_direction_par=TRT, l=true) */
-                    try_couple_nodes(eqno_box,r);
-                    try_couple_nodes(r,eq_box);
                 }
+                s = new_kern(width(r) + eqno_w);
+                try_couple_nodes(eqno_box,r);
+                try_couple_nodes(r,eq_box);
+                try_couple_nodes(eq_box,s);
             } else {
                 if (math_direction_par==dir_TLT) {
                     /*tex TLT + TLT + \leqno: (swap_dir=false, math_direction_par=TLT, l=true) */
-                    s = new_kern(width(r) + eqno_w);
                 } else {
                     /*tex TRT + TRT + \leqno: (swap_dir=false, math_direction_par=TRT, l=true) */
-                    s = new_kern(width(r));
                 }
+                s = new_kern(width(r) + eqno_w);
                 try_couple_nodes(eqno_box,r);
                 try_couple_nodes(r,eq_box);
                 try_couple_nodes(eq_box,s);
@@ -2590,11 +2587,16 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
             if (swap_dir) {
                 if (math_direction_par==dir_TLT) {
                     /*tex TRT + TLT + \leqno: (swap_dir=true,  math_direction_par=TLT, l=false) */
+                    s = new_kern(d);
+                    try_couple_nodes(s,eq_box);
+                    try_couple_nodes(eq_box,r);
+                    try_couple_nodes(r,eqno_box);
+                    eq_box = s;
                 } else {
                     /*tex TLT + TRT + \leqno: (swap_dir=true,  math_direction_par=TRT, l=false) */
+                    try_couple_nodes(eq_box,r);
+                    try_couple_nodes(r,eqno_box);
                 }
-                try_couple_nodes(eq_box,r);
-                try_couple_nodes(r,eqno_box);
             } else {
                 if (math_direction_par==dir_TLT) {
                     /*tex TLT + TLT + \eqno: (swap_dir=false, math_direction_par=TLT, l=false) */

Attachment: display_current.pdf
Description: Adobe PDF document

_______________________________________________
dev-luatex mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to