On 10/27/2026 6:04 PM, via ntg-context wrote:
Hi Hans,

I found a line-breaking problem in LuaMetaTeX (2026.10.25): a line break can 
occur immediately after inline math, even when the following glue has the 
noautobreak option set.

Here is a minimal ConTeXt example:

\starttext
\startframedtext[width=67mm]
Das digitale Geraet hat ein \math{3\frac{1}{2}}~stelliges Display und einen 
Fehler.
\stopframedtext
\stoptext

The line can break between the fraction and "stelliges", although ~ should keep 
them together.

I traced this to the two end_inline_math branches in texlinebreak.c. They can 
introduce a math-related breakpoint without checking the noautobreak option of 
the following glue.

I propose the following changes.

In the first branch, replace the glue check with:

halfword penalty = math_penalty(current);
halfword next = node_next(current);

if (next && node_type(next) == glue_node
     && (penalty <= -10000
         || !tex_has_glue_option(next, glue_option_no_auto_break))) {
     /* existing code */
}

In the second branch, replace the existing tex_aux_valid_glue_break(current) 
condition with:

halfword penalty = math_penalty(current);
halfword next = node_next(current);

if (tex_aux_valid_glue_break(current)
     && !(penalty > -10000 && next
          && node_type(next) == glue_node
          && tex_has_glue_option(next, glue_option_no_auto_break))) {
     /* existing code */
}

The important distinction is that noautobreak should suppress automatic 
breakpoints, but not an explicitly forced math break (penalty -10000).

Are you sure about that -10000? I suppose nobreak means nobreak.
For example, this must still allow the forced break:

\postinlinepenalty=-10000
\math{12345}~stelliges

I initially overlooked this interaction, but caught it through further testing 
and adjusted the fix accordingly.

I have now run extensive regression tests covering different glue options, math 
penalties, short and regular inline math, mathsurround, and directly 
constructed glue nodes. All tests pass with the revised fix, while ordinary 
breakpoints retain their previous behavior.

I can provide the complete patch and test suite if you are interested.

patch means: mail me the whole file

The test suite: Mikael S and I need to see adn discuss it before we decide so mail us a zip. Sometimes things like these become configurable options. In fact, some tests might be candidates for the test suite (so name then like nobreak-001.tex etc. (they go under math).

Thanks

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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to