irregular line height in HTML

22 views
Skip to first unread message

Alex Jordan

unread,
Jun 15, 2026, 12:02:35 AM (6 days ago) Jun 15
to prete...@googlegroups.com
Consider the lines in the paragraphs here:

The second paragraph "If you use..." has lines spaced a certain distance apart. Namely 1.35 for line-height.

The first paragraph has lines spaced further apart. This is partly because of the MathJax n and n-1. But also there is different spacing between the first line and second line, where there is no math. In those top lines, the border of the code elements is increasing the height.

The third paragraph has even more irregular line spacing, because of the specially typeset E in LaTeX.

Maybe all this is just par for the course for reading HTML. Line height won't be regular. But it seems wrong for the "n" and "n-1", which are not actually taking more vertical space than regular letters in the sentence, to cause this disruption in the cadence of the lines. Is it possible to reduce the disruptions? Particularly for inline math that is not actually too tall for a line?


Rob Beezer

unread,
Jun 15, 2026, 9:57:14 AM (5 days ago) Jun 15
to prete...@googlegroups.com
Can't really dig in too much right now, but the MathJax config once had a scale
factor for the math. Maybe that explains the n and n-1? Have you found an
experimental solution to that situation? Some of these are unavoidable, I
think, like the dropped E in LaTeX.

Rob

On 6/14/26 21:02, Alex Jordan wrote:
> Consider the lines in the paragraphs here:
> Subsection 7.2: Displayed Mathematics <https://pretextbook.org/examples/sample-
> article/html/section-mathematics.html#section-mathematics-4>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-dev...@googlegroups.com <mailto:pretext-
> dev+uns...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/
> CA%2BR-jrf8%2BYvW40V0_1HA9jDjbkN9FwJ_7C%2B0mA8_nmn8VPiQaw%40mail.gmail.com
> <https://groups.google.com/d/msgid/pretext-dev/CA%2BR-
> jrf8%2BYvW40V0_1HA9jDjbkN9FwJ_7C%2B0mA8_nmn8VPiQaw%40mail.gmail.com?
> utm_medium=email&utm_source=footer>.

Andrew Scholer

unread,
Jun 15, 2026, 11:31:24 AM (5 days ago) Jun 15
to prete...@googlegroups.com
LaTeX looks like an easy change.


MathJax might be an easy fix... it looks like MJ3 had a line-height 0 on .mjx-container. MJ4 does not. Adding that back appears to have the desired effect. But, that is a change that was made in MathJax. Was it made to accommodate some other change? Are there situations in which setting line-height 0 would cause overlap? If someone wants to exhaustively test, just add some custom CSS with:

mjx-container {
    line-height: 0;
}


The other spacing issue is coming from the "code" blocks. The padding/border on them causes them to take up more vertical space. Forcing them not to leads to a bit of crowding when consecutive lines both contain blocks:
image.png

But that is probably better than the current behavior.


I can PR LaTeX and code blocks if desired. I can envision more ways for MathJax spacing to go wrong, so would prefer to have someone do some testing on that one and report back.

Andrew



To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAyMS5iZWV6ZXI.1781531832%40pnsh.

Alex Jordan

unread,
Jun 15, 2026, 1:31:49 PM (5 days ago) Jun 15
to prete...@googlegroups.com
Not exhaustive testing, but here is a before shot, where I put a tall inline matrix:

Screenshot 2026-06-15 at 10.25.12 AM.png


And here is an after shot (after adding that additional CSS):

Screenshot 2026-06-15 at 10.24.58 AM.png

I don't detect any difference where the matrix is. Down in the second paragraph the "2.6" bits of math make an impact, and the added CSS improves things.


FWIW, I also doctored things so that one line of the paragraph would be only inline math content. Just in case setting that CSS to zero would collapse the entire line. But it did not.


Rob Beezer

unread,
Jun 16, 2026, 7:49:52 AM (4 days ago) Jun 16
to prete...@googlegroups.com
My eye is not so tuned in to these small differences, but I can sorta see when I
look hard. It'd be good to do a careful look through some of the "paragraph
level" markup in the sample article, there are some crazy constructions.

1. Might we reduce the margin/padding around the inline #c snippets? I think
we have messed with this before. I see this presentation often other places,
but I can't say I am a huge fan - its very busy when there is a lot of it. Are
there alternatives folks like? Is just a bit of monospace not enough? (That's
the LaTeX treatment I guess.)

2. Does the math "2.6" look a bit big to anybody else? It'd be interesting to
see a "regular" 2.6 close by. Im pretty sure we had something like an 85% scale
factor in the MJ config a long time ago (its in the git history somewhere!).

Rob

On 6/15/26 10:31, Alex Jordan wrote:
> Not exhaustive testing, but here is a before shot, where I put a tall inline matrix:
>
> Screenshot 2026-06-15 at 10.25.12 AM.png
>
>
> And here is an after shot (after adding that additional CSS):
>
> Screenshot 2026-06-15 at 10.24.58 AM.png
>
> I don't detect any difference where the matrix is. Down in the second paragraph
> the "2.6" bits of math make an impact, and the added CSS improves things.
>
>
> FWIW, I also doctored things so that one line of the paragraph would be only
> inline math content. Just in case setting that CSS to zero would collapse the
> entire line. But it did not.
>
>
> On Mon, Jun 15, 2026 at 8:31 AM Andrew Scholer <asch...@chemeketa.edu
> <mailto:asch...@chemeketa.edu>> wrote:
>
> LaTeX looks like an easy change.
>
>
> MathJax might be an easy fix... it looks like MJ3 had a line-height 0
> on .mjx-container. MJ4 does not. Adding that back appears to have the
> desired effect. But, that is a change that was made in MathJax. Was it made
> to accommodate some other change? Are there situations in which setting
> line-height 0 would cause overlap? If someone wants to exhaustively test,
> just add some custom CSS with:
>
> mjx-container {
>     line-height: 0;
> }
>
>
> The other spacing issue is coming from the "code" blocks. The padding/border
> on them causes them to take up more vertical space. Forcing them not to
> leads to a bit of crowding when consecutive lines both contain blocks:
> image.png
>
> But that is probably better than the current behavior.
>
>
> I can PR LaTeX and code blocks if desired. I can envision more ways for
> MathJax spacing to go wrong, so would prefer to have someone do some testing
> on that one and report back.
>
> Andrew
>
>
>
> On Mon, Jun 15, 2026 at 6:57 AM 'Rob Beezer' via PreTeXt development
> <prete...@googlegroups.com <mailto:prete...@googlegroups.com>> wrote:
>
> Can't really dig in too much right now, but the MathJax config once had
> a scale
> factor for the math.  Maybe that explains the n and n-1?  Have you found an
> experimental solution to that situation?  Some of these are unavoidable, I
> think, like the dropped E in LaTeX.
>
> Rob
>
> On 6/14/26 21:02, Alex Jordan wrote:
> > Consider the lines in the paragraphs here:
> > Subsection 7.2: Displayed Mathematics <https://pretextbook.org/
> examples/sample- <https://pretextbook.org/examples/sample->
> dev%2Bunsu...@googlegroups.com> <mailto:pretext- <mailto:pretext->
> > dev+uns...@googlegroups.com
> <mailto:dev%2Bunsu...@googlegroups.com>>.
> > To view this discussion visit https://groups.google.com/d/msgid/
> pretext-dev/ <https://groups.google.com/d/msgid/pretext-dev/>
> > CA%2BR-
> jrf8%2BYvW40V0_1HA9jDjbkN9FwJ_7C%2B0mA8_nmn8VPiQaw%40mail.gmail.com
> <http://40mail.gmail.com>
> > <https://groups.google.com/d/msgid/pretext-dev/CA%2BR- <https://
> groups.google.com/d/msgid/pretext-dev/CA%2BR->
> > jrf8%2BYvW40V0_1HA9jDjbkN9FwJ_7C%2B0mA8_nmn8VPiQaw%40mail.gmail.com
> <http://40mail.gmail.com>?
> > utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pretext-dev...@googlegroups.com <mailto:pretext-
> dev%2Bunsu...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> dev/MTAwMDAyMS5iZWV6ZXI.1781531832%40pnsh <https://groups.google.com/d/
> msgid/pretext-dev/MTAwMDAyMS5iZWV6ZXI.1781531832%40pnsh>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> CACm44N9B45B_9QfmcoTnLOiwc35xOnWjgRiCcRd%2B2BXOYTxQmw%40mail.gmail.com
> <https://groups.google.com/d/msgid/pretext-dev/
> CACm44N9B45B_9QfmcoTnLOiwc35xOnWjgRiCcRd%2B2BXOYTxQmw%40mail.gmail.com?
> utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> CA%2BR-jrdCbHC89Tq20t1yS7vCm1pLmYz-fWkbi3HBcbO77CdC1A%40mail.gmail.com <https://
> groups.google.com/d/msgid/pretext-dev/CA%2BR-jrdCbHC89Tq20t1yS7vCm1pLmYz-
> fWkbi3HBcbO77CdC1A%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Sean Fitzpatrick

unread,
Jun 16, 2026, 8:14:34 AM (4 days ago) Jun 16
to PreTeXt development
The 2.6 does look big, and the highlight boxes around code seem taller than needed. But maybe a shorter box would cause trouble if the code had capital letters. 

Unlikely to be the solution you want, but would this go away is the regular line spacing was 1.5?

To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAwNS5iZWV6ZXI.1781610588%40pnsh.

Andrew Scholer

unread,
Jun 16, 2026, 10:55:52 AM (4 days ago) Jun 16
to prete...@googlegroups.com
Agree that we could get by with less padding within <c> elements. And the border adds a lot of visual weight that can get distracting. Trimming those out gives:
image.png

I think formatted program fragments still need a border. Compare:
image.png
To:
image.png

The size of math is coming from an inline style applied by MathJax that sets font-size to 118.7%. Changing that is outside the scope of our CSS. It should be changed by modifying the settings for MathJax. That said, inline math does appear too large. Here are 2.6s that are:
not MathJax / normal (118.7%) / 100% / 110%

image.png

To my eye, 110% would be nice.




Rob Beezer

unread,
Jun 19, 2026, 1:57:34 PM (yesterday) Jun 19
to prete...@googlegroups.com
Many (all?) of the suggestions here addressed by Andrew S (thanks, Andrew!). He
can elaborate, if necessary.

https://github.com/PreTeXtBook/pretext/pull/2931

On 6/16/26 05:14, Sean Fitzpatrick wrote:
> The 2.6 does look big, and the highlight boxes around code seem taller than
> needed. But maybe a shorter box would cause trouble if the code had capital
> letters.
>
> Unlikely to be the solution you want, but would this go away is the regular line
> spacing was 1.5?
>
> > <mailto:asch...@chemeketa.edu <mailto:asch...@chemeketa.edu>>> wrote:
> >
> >     LaTeX looks like an easy change.
> >
> >
> >     MathJax might be an easy fix... it looks like MJ3 had a line-height 0
> >     on .mjx-container. MJ4 does not. Adding that back appears to have the
> >     desired effect. But, that is a change that was made in MathJax. Was
> it made
> >     to accommodate some other change? Are there situations in which setting
> >     line-height 0 would cause overlap? If someone wants to exhaustively test,
> >     just add some custom CSS with:
> >
> >     mjx-container {
> >          line-height: 0;
> >     }
> >
> >
> >     The other spacing issue is coming from the "code" blocks. The
> padding/border
> >     on them causes them to take up more vertical space. Forcing them not to
> >     leads to a bit of crowding when consecutive lines both contain blocks:
> >     image.png
> >
> >     But that is probably better than the current behavior.
> >
> >
> >     I can PR LaTeX and code blocks if desired. I can envision more ways for
> >     MathJax spacing to go wrong, so would prefer to have someone do some
> testing
> >     on that one and report back.
> >
> >     Andrew
> >
> >
> >
> >     On Mon, Jun 15, 2026 at 6:57 AM 'Rob Beezer' via PreTeXt development
> >     <prete...@googlegroups.com <mailto:prete...@googlegroups.com>
> <mailto:prete...@googlegroups.com <mailto:prete...@googlegroups.com>>>
> wrote:
> >
> >         Can't really dig in too much right now, but the MathJax config
> once had
> >         a scale
> >         factor for the math.  Maybe that explains the n and n-1?  Have
> you found an
> >         experimental solution to that situation?  Some of these are
> unavoidable, I
> >         think, like the dropped E in LaTeX.
> >
> >         Rob
> >
> >         On 6/14/26 21:02, Alex Jordan wrote:
> >          > Consider the lines in the paragraphs here:
> >          > Subsection 7.2: Displayed Mathematics <https://
> pretextbook.org/ <https://pretextbook.org/>
> > dev%2Bunsu...@googlegroups.com
> <mailto:dev%252Buns...@googlegroups.com>> <mailto:pretext-
> <mailto:pretext-> <mailto:pretext- <mailto:pretext->>
> >          > dev+uns...@googlegroups.com
> <mailto:dev%2Bunsu...@googlegroups.com>
> >         <mailto:dev%2Bunsu...@googlegroups.com
> <mailto:dev%252Buns...@googlegroups.com>>>.
> >          > To view this discussion visit https://groups.google.com/d/
> msgid/ <https://groups.google.com/d/msgid/>
> >         pretext-dev/ <https://groups.google.com/d/msgid/pretext-dev/
> <https://groups.google.com/d/msgid/pretext-dev/>>
> >          > CA%2BR-
> >
>  jrf8%2BYvW40V0_1HA9jDjbkN9FwJ_7C%2B0mA8_nmn8VPiQaw%40mail.gmail.com
> <http://40mail.gmail.com>
> >         <http://40mail.gmail.com <http://40mail.gmail.com>>
> >          > <https://groups.google.com/d/msgid/pretext-dev/CA%2BR-
> <https://groups.google.com/d/msgid/pretext-dev/CA%2BR-> <https://
> > groups.google.com/d/msgid/pretext-dev/CA%2BR- <http://groups.google.com/
> d/msgid/pretext-dev/CA%2BR->>
> >          >
> jrf8%2BYvW40V0_1HA9jDjbkN9FwJ_7C%2B0mA8_nmn8VPiQaw%40mail.gmail.com
> <http://40mail.gmail.com>
> >         <http://40mail.gmail.com <http://40mail.gmail.com>>?
> >          > utm_medium=email&utm_source=footer>.
> >
> >         --
> >         You received this message because you are subscribed to the Google
> >         Groups "PreTeXt development" group.
> >         To unsubscribe from this group and stop receiving emails from it,
> send
> >         an email to pretext-dev...@googlegroups.com
> <mailto:pretext-dev%2Bunsu...@googlegroups.com> <mailto:pretext-
> <mailto:pretext->
> > dev%2Bunsu...@googlegroups.com
> <mailto:dev%252Buns...@googlegroups.com>>.
> >         To view this discussion visit https://groups.google.com/d/msgid/
> pretext- <https://groups.google.com/d/msgid/pretext->
> >         dev/MTAwMDAyMS5iZWV6ZXI.1781531832%40pnsh <https://
> groups.google.com/d/ <https://groups.google.com/d/>
> >         msgid/pretext-dev/MTAwMDAyMS5iZWV6ZXI.1781531832%40pnsh>.
> >
> >     --
> >     You received this message because you are subscribed to the Google Groups
> >     "PreTeXt development" group.
> >     To unsubscribe from this group and stop receiving emails from it, send an
> >     email to pretext-dev...@googlegroups.com <mailto:pretext-
>  CACm44N9B45B_9QfmcoTnLOiwc35xOnWjgRiCcRd%2B2BXOYTxQmw%40mail.gmail.com
> <http://40mail.gmail.com>
> >     <https://groups.google.com/d/msgid/pretext-dev/ <https://
> groups.google.com/d/msgid/pretext-dev/>
> >
>  CACm44N9B45B_9QfmcoTnLOiwc35xOnWjgRiCcRd%2B2BXOYTxQmw%40mail.gmail.com
> <http://40mail.gmail.com>?
> >     utm_medium=email&utm_source=footer>.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "PreTeXt development" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> email
> > to pretext-dev...@googlegroups.com <mailto:pretext-
> > CA%2BR-jrdCbHC89Tq20t1yS7vCm1pLmYz-fWkbi3HBcbO77CdC1A%40mail.gmail.com
> <http://40mail.gmail.com> <https://
> > groups.google.com/d/msgid/pretext-dev/CA%2BR-jrdCbHC89Tq20t1yS7vCm1pLmYz-
> <http://groups.google.com/d/msgid/pretext-dev/CA%2BR-
> jrdCbHC89Tq20t1yS7vCm1pLmYz->
> > fWkbi3HBcbO77CdC1A%40mail.gmail.com?utm_medium=email&utm_source=footer
> <http://40mail.gmail.com?utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pretext-dev...@googlegroups.com <mailto:pretext-
> dev%2Bunsu...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/
> MTAwMDAwNS5iZWV6ZXI.1781610588%40pnsh <https://groups.google.com/d/msgid/
> pretext-dev/MTAwMDAwNS5iZWV6ZXI.1781610588%40pnsh>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-dev...@googlegroups.com <mailto:pretext-
> dev+uns...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/
> CAH%2BNcPbriT9t2otmNDWHf2emXr5fbi2W%2BvJKdgPrUVdkVC24hg%40mail.gmail.com
> <https://groups.google.com/d/msgid/pretext-dev/
> CAH%2BNcPbriT9t2otmNDWHf2emXr5fbi2W%2BvJKdgPrUVdkVC24hg%40mail.gmail.com?
> utm_medium=email&utm_source=footer>.

Alex Jordan

unread,
Jun 19, 2026, 1:58:58 PM (yesterday) Jun 19
to prete...@googlegroups.com
Thanks Andrew!

To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-dev/MTAwMDAzNy5iZWV6ZXI.1781891850%40pnsh.
Reply all
Reply to author
Forward
0 new messages