Skip to content

configure mathjax to line break long display math#3026

Open
Alex-Jordan wants to merge 1 commit into
openwebwork:WeBWorK-2.21from
Alex-Jordan:mathjax-linebreak
Open

configure mathjax to line break long display math#3026
Alex-Jordan wants to merge 1 commit into
openwebwork:WeBWorK-2.21from
Alex-Jordan:mathjax-linebreak

Conversation

@Alex-Jordan

Copy link
Copy Markdown
Contributor

No description provided.

@somiaj

somiaj commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What about adding displayOverflow: 'scroll' to the output key as well? This makes it so formulas will scroll if they are longer than their container and there are no line breaks.

Comment thread htdocs/js/MathJaxConfig/mathjax-config.js Outdated
@drgrice1

Copy link
Copy Markdown
Member

The default setting for inline math is for line breaking to be enabled. So this disables line breaking for inline math. Do we really want that?

@drgrice1

Copy link
Copy Markdown
Member

Testing this with

DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl');

BEGIN_PGML
[`
    \int \frac{4x^4 + 5x^3 + 110x^2 + 128x + 175}{x^3 + 25x} \,dx
    = \int 4x + 5 + \frac{7}{x} + \frac{3x+3}{x^2 + 25} \,dx
    = \int 4x + 5 + \frac{7}{x} + \frac{3x}{x^2 + 25} + \frac{3}{x^2 + 25} \,dx
    = 2x^2 + 5x + 7\ln\left(\left|x\right|\right) + \frac{3}{2}\ln\left(x^2 + 25\right) + \frac{3}{5}\tan^{-1}\left(\frac{x}{5}\right) + C.
`]

[```
    \int \frac{4x^4 + 5x^3 + 110x^2 + 128x + 175}{x^3 + 25x} \,dx
    = \int 4x + 5 + \frac{7}{x} + \frac{3x+3}{x^2 + 25} \,dx
    = \int 4x + 5 + \frac{7}{x} + \frac{3x}{x^2 + 25} + \frac{3}{x^2 + 25} \,dx
    = 2x^2 + 5x + 7\ln\left(\left|x\right|\right) + \frac{3}{2}\ln\left(x^2 + 25\right) + \frac{3}{5}\tan^{-1}\left(\frac{x}{5}\right) + C.
```]
END_PGML

BEGIN_PGML_SOLUTION
[`
    \int \frac{4x^4 + 5x^3 + 110x^2 + 128x + 175}{x^3 + 25x} \,dx
    = \int 4x + 5 + \frac{7}{x} + \frac{3x+3}{x^2 + 25} \,dx
    = \int 4x + 5 + \frac{7}{x} + \frac{3x}{x^2 + 25} + \frac{3}{x^2 + 25} \,dx
    = 2x^2 + 5x + 7\ln\left(\left|x\right|\right) + \frac{3}{2}\ln\left(x^2 + 25\right) + \frac{3}{5}\tan^{-1}\left(\frac{x}{5}\right) + C.
`]

[```
    \int \frac{4x^4 + 5x^3 + 110x^2 + 128x + 175}{x^3 + 25x} \,dx
    = \int 4x + 5 + \frac{7}{x} + \frac{3x+3}{x^2 + 25} \,dx
    = \int 4x + 5 + \frac{7}{x} + \frac{3x}{x^2 + 25} + \frac{3}{x^2 + 25} \,dx
    = 2x^2 + 5x + 7\ln\left(\left|x\right|\right) + \frac{3}{2}\ln\left(x^2 + 25\right) + \frac{3}{5}\tan^{-1}\left(\frac{x}{5}\right) + C.
```]
END_PGML_SOLUTION

ENDDOCUMENT();

I see that the first line breaks with the current MathJax configuration, but not with this pull request. I don't think that is good.

Of course, the display mode math on the second line does not break with the current MathJax configuration, but does with this, and still does if inline: true is set.

So I think that it would be best to leave inline: true.

@Alex-Jordan

Copy link
Copy Markdown
Contributor Author

I didn't think too hard about inline: false. I have seen that when you do the same think in actual LaTeX (using a package that allows inline math to break) it can be bad. Because when reading a sentence with inline math and there is a line break, it really disrupts the readability of the sentence. But for WW exercises, that's less of a concern that expository textbook.

@drgrice1

Copy link
Copy Markdown
Member

line breaking of any sort is new with MathJax, so whatever is decided is fine. I wouldn't actually put something like that example inline, and have always used things like the aligned environment to avoid long lines in any case

@Alex-Jordan

Copy link
Copy Markdown
Contributor Author

What about adding displayOverflow: 'scroll' to the output key as well?

Yes, there is scroll, line break, and also the option to scale it down. I thought the line break for display math seemed the most pleasing to look at. We can set it to something else if it's what we want. Any of it can be changed by the user by accessing the MathJax menu.

Do you have a preference for one of those as our default? Do you, @drgrice1?

@drgrice1

Copy link
Copy Markdown
Member

I think that using line breaking is probably best, with scrolling a close second. I think scaling it down by default is probably not good.

@drgrice1 drgrice1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me as is. We can still debate on if inline math should be line broken or not, and if it is better to line break or scroll (or scale down) display math though. I will go ahead an approve it conceptually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants