This is the current test for deciding not to use shortskip

((d + line_s <= pre_display_size_par) || ((! dir_math_save && l) ||
(dir_math_save && ! l)))

It has two problems:

* if eqno_box is null then l (the leqno bool) is always false, so for
short unnumbered equations
   the test is reduced to the value of dir_math_save which is based on
\textdirection
   and \mathdirection, but in this case shortskip should always be used.

*  dir_math_save is correlated to \textdirection, but the shortskip
detection should be
   based on the position of the equation number, and parfillskip, none
of which \textdirection
   controls. I think \pardirection should be tested here.

Here is a faulty example, where shortskip should be used but it is not

\matheqdirmode=1\pardirection=1\textdirection=1
Test
$$
Test
$$
Test
\bye

In fact if I change \textdirection in this example shortskip is used,
which kind of demonstrates the second point.

For a better example of the second point you can test

\matheqdirmode=1\textdirection=1
Test
$$
Test\leqno(1)
$$
Test
\bye

Whereas \textdirection and \mathdirection are opposites  dir_math_save is true
and leqno bool is false, hence short skp is used but the output
clearly shows it should not be, as the equation number is right below
the text.

Note that I also tested with LuaTeX 1.18.0 to make sure this is not
the fault of recent changes.

I attached a patch.

Udi
diff --git a/source/texk/web2c/luatexdir/tex/texmath.c b/source/texk/web2c/luatexdir/tex/texmath.c
index 3c069a5d6..32b675aae 100644
--- a/source/texk/web2c/luatexdir/tex/texmath.c
+++ b/source/texk/web2c/luatexdir/tex/texmath.c
@@ -2542,7 +2542,10 @@ static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
         g2 = below_display_short_skip_code;
        }
     } else {
-      if ((d + line_s <= pre_display_size_par) || ((! dir_math_save && l) || (dir_math_save && ! l))) {
+      boolean math_and_par_reversed = math_and_text_reversed_p();
+      if ((d + line_s <= pre_display_size_par) || (eqno_box != null
+              && (! math_and_par_reversed && l)
+              || (math_and_par_reversed && ! l))) {
         /*tex not enough clearance */
         g1 = above_display_skip_code;
         g2 = below_display_skip_code;
_______________________________________________
dev-luatex mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to