On Sat, Feb 1, 2025 at 4:24 PM Ulrike Fischer <[email protected]> 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#issuecomment-2154455298)
> 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
diff --git a/source/texk/web2c/luatexdir/tex/texmath.c b/source/texk/web2c/luatexdir/tex/texmath.c
index e1f100c60..4b34c1723 100644
--- a/source/texk/web2c/luatexdir/tex/texmath.c
+++ b/source/texk/web2c/luatexdir/tex/texmath.c
@@ -2564,20 +2564,22 @@ 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);
                 } else {
                     /*tex TLT + TRT + \eqno: (swap_dir=true,  math_direction_par=TRT, l=true) */
+                    s = new_kern(d);
                 }
-                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(d);
                 }
-                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);
@@ -2588,15 +2590,13 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
                 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);
+                    s = new_kern(width(r) + eqno_w);
                 }
+                try_couple_nodes(s,eq_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) */
@@ -2608,8 +2608,8 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
                 try_couple_nodes(s,eq_box);
                 try_couple_nodes(eq_box,r);
                 try_couple_nodes(r,eqno_box);
-                eq_box = s;
             }
+            eq_box = s;
         }
         eq_box = hpack(eq_box, 0, additional, -1);
         subtype(eq_box) = equation_list; /* new */
_______________________________________________
dev-luatex mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to