Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display math mode page break and paragraph indenting issue #2160

Open
Omikhleia opened this issue Nov 4, 2024 · 3 comments
Open

Display math mode page break and paragraph indenting issue #2160

Omikhleia opened this issue Nov 4, 2024 · 3 comments
Assignees
Labels
bug Software bug issue

Comments

@Omikhleia
Copy link
Member

Omikhleia commented Nov 4, 2024

Two related issues with SILE 0.15.5's implementation of display math mode:

  • page breaks may occur before or after a display math formula.
  • if the formula is in a paragraph, the next line is always paragraph indented

Example

We have:
\math[mode=display]{formula1}
hence:
\math[mode=display]{formula2.}

Obtained

(indent)We have:
        (potential page break here)
                     formula1
        (potential page break here)
(indent)hence:
        (potential page break here)
                     formula2
        (potential page break here)

Expected

(indent)We have:
        (no page break unless wanted)
                     formula1
        (potential page break here unless not wanted)
hence: (not indented)
        (no page break unless wanted)
                     formula2
        (potential page break here)

Main references

For reference, (La)TeX has finer control here:

  • predisplaypenalty (default 10000 = keep with previous lines)
  • postdisplaypenalty (default 0 = allow normal break; I remember tweaking it to negative for some personal preferences)
  • displaywidowpenalty (default 50)

It's less obvious than it might seem at a glance

  • In the current implementation, pre/postdisplaypenalty would be easy, but this is likely a wrong approach as....
  • ... displaywindowpenalty would required being at paragraphing (line node boxing),
  • ... and the noindent also need to know whether we are in the same paragraph or not.

Additional notes

SILE has math.displayskip.

TeX has:

  • abovedisplayskip / abovedisplayshortskip
  • belowdisplayskip / belowdisplayshortskip

These allow to have different skips before and after the equation.

More interestingly, the "short" version are used when the display equation would fit on the last paragraph line.

...hence:      formula2

Same challenge as above, this has implications on the line wrapping logic.

@Omikhleia Omikhleia added the bug Software bug issue label Nov 4, 2024
@Omikhleia Omikhleia added this to Math Nov 4, 2024
@github-project-automation github-project-automation bot moved this to To do in Math Nov 4, 2024
@Omikhleia
Copy link
Member Author

N.B. added "additional notes" to the initial description.

@Omikhleia Omikhleia self-assigned this Nov 5, 2024
@Omikhleia
Copy link
Member Author

To demonstrate the effect (though I wouldn't push the code as-is ^^)

image

Omikhleia added a commit to Omikhleia/resilient-types that referenced this issue Nov 9, 2024
See sile-typesetter#2160.
This is a conservative workaround.
Introducing the predisplay/postdisplay penalties is the right thing to
do, but a more general solution to the full issue requires a more subtle
handling of in-paragraph display math equations, which is not considered
here.
Omikhleia added a commit to Omikhleia/resilient-types that referenced this issue Nov 9, 2024
See sile-typesetter#2160.
This is a conservative workaround.
Introducing the predisplay/postdisplay penalties is the right thing to
do, but a more general solution to the full issue requires a more subtle
handling of in-paragraph display math equations, which is not considered
here.
Omikhleia added a commit to Omikhleia/resilient-types that referenced this issue Nov 9, 2024
See sile-typesetter#2160.
This is a conservative workaround.
Introducing the predisplay/postdisplay penalties is the right thing to
do, but a more general solution to the full issue requires a more subtle
handling of in-paragraph display math equations, which is not considered
here.
@Omikhleia
Copy link
Member Author

Omikhleia commented Nov 9, 2024

I am suggesting a conservative workaround in #2162, at least discouraging page breaks before display math equations and tuning breaks after them, introducing TeX's pre/post display penalties and doing the minimal things needed in our current implementation to use them adequately...

But there are various ways a finer-grain approach could be considered.
One of them, which I followed as an experiment (illustration above), is to consider display math equations as a full-line-width inline box, with the displayskip being used for leading (vs. standard leading for regular vboxes), and a parfillskip being inserted when adequate too...
This approach might sound logical (respecting paragraph boundaries, and that would be also the logical step to honor the widow setting eventually), but it requires some dedicated support in the typesetter (and in normal SILE usage, also the bidi typesetter that comes on top of the base one...), and it questions our semantic interpretation of paragraphs vs. just leaving horizontal mode vs. "initline/endline" stuff vs. class endPar() and friends, invoked each time horizontal content is pushed... etc. There are too many deep questions here for a small eventual gain at this stage, in my opinion... Though I'll certainly want to return to the topic one day: I've a feeling that SILE isn't too clear in its mind about "paragraphing" -- and the page builder too isn't that smart...

Anyhow, at least avoiding very unpleasant page breaks is satisfying workaround, and #2162 does no less (but no more either) than that.

alerque pushed a commit to Omikhleia/resilient-types that referenced this issue Nov 13, 2024
See sile-typesetter#2160.
This is a conservative workaround.
Introducing the predisplay/postdisplay penalties is the right thing to
do, but a more general solution to the full issue requires a more subtle
handling of in-paragraph display math equations, which is not considered
here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Software bug issue
Projects
Status: To do
Development

No branches or pull requests

1 participant