On Wednesday, August 5th, 2026 at 7:35 PM, Richard Kimberly Heck via lyx-users 
<[email protected]> wrote:

> There is
> additional space above the displayed equation in the latter case. I take
> it that this is in the inter-paragraph spacing. Please correct me if the
> additional space is coming from somewhere else. But I get the same in
> the latter case as if I'd written:
>
> test
>
> ~
> $$x=y$$
>

You can trace what happens from the LuaTeX source (this is similar in other 
engines).

When LuaTeX encounters a $ in vertical mode during the main control loop
it runs run_new_graf(): 
https://gitlab.lisn.upsaclay.fr/texlive/luatex/-/blob/master/source/texk/web2c/luatexdir/tex/maincontrol.c#L860
which backs up one token, then runs new_graph(true):
https://gitlab.lisn.upsaclay.fr/texlive/luatex/-/blob/master/source/texk/web2c/luatexdir/tex/maincontrol.c#L473

new_graph(true) create a new *indented* paragraph, and switch the mode to 
horizontal.
https://gitlab.lisn.upsaclay.fr/texlive/luatex/-/blob/master/source/texk/web2c/luatexdir/tex/maincontrol.c#L1831

Since run_new_graf() backed up one token, back in the main control loop we 
encounter the same $ again but in horizontal mode:
https://gitlab.lisn.upsaclay.fr/texlive/luatex/-/blob/master/source/texk/web2c/luatexdir/tex/maincontrol.c#L904

Now init_math() check the next token and if it is another math shift token we 
start a display equation:
https://gitlab.lisn.upsaclay.fr/texlive/luatex/-/blob/master/source/texk/web2c/luatexdir/tex/texmath.c#L986

When LuaTeX start a display equation, it first checks the current paragraph. If 
it is empty (head==tail) it flushes it:
https://gitlab.lisn.upsaclay.fr/texlive/luatex/-/blob/master/source/texk/web2c/luatexdir/tex/texmath.c#L1120
(LuateX specifically check more stuff here, such as local_par and direction 
nodes, these are LuaTeX specific).
If it is not empty, It breaks it into lines and will add it to the vertical 
list eventually.


Since you used $ in vertical mode, LuaTeX started an indented paragraph, i.e. a 
paragraph with a hbox node,
so LuaTeX does not discard it, but it is visually empty and might seem like a 
vertical space.

You can see the difference with \noindent $$x=y$$. In this case there is no 
indent box in the paragraph, so
LuaTeX will discard it.

Udi
-- 
lyx-users mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-users

Reply via email to