Spacing in <men> environment

30 views
Skip to first unread message

Russell Howell

unread,
Nov 11, 2025, 5:27:37 PMNov 11
to PreTeXt support
Greetings,

I'm wondering why spacing for a long equation in the <men> environment isn't adjusted to the left so that the equation number aligns with the "normal" right boundary of text. If you look at Equation 10.5.4 in the web link


you''ll see an illustration of what I mean. I can fix that issue by adding 14 negative thin spaces (\!) at the start of the equation, and I've done so with the similar Equation 10.5.5 just below the figure that follows Equation 10.5.4.

This issue occurs in several places of the text, so it would be nice if spacing could be automatically adjusted.

Regards,

Russ Howell

Rob Beezer

unread,
Nov 11, 2025, 8:11:10 PMNov 11
to pretext...@googlegroups.com
Dear Russ,

Thanks for the careful report. I don't see anything wrong with your source, when not using the negative space.

I wonder if some of our CSS is interfering with MathJax?

Rob

Andrew Scholer

unread,
Nov 11, 2025, 8:38:44 PMNov 11
to pretext...@googlegroups.com
Russ - 

Do you have a link to your source document? That would be very useful for diagnosing what is going on.

This looks like MathJax code is setting a width and margin on the equation itself that add up to more than 600 pixels (pics below).

Given that there is more than 600 pixels of content, PTX CSS allows it to overflow. The only alternative on our end would be to cut it off or make it scroll. (There may be some 

Your workaround reduces the amount of space that MathJax believes it needs. Making that general would involve figuring out why MathJax thinks it needs to have that margin and how to change its mind.

image.png

image.png

image.png

Andrew

--
You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/MTAwMDAxNS5iZWV6ZXI.1762909867%40pnsh.

Russell Howell

unread,
Nov 11, 2025, 9:10:41 PMNov 11
to pretext...@googlegroups.com
Andrew and Rob,

The source can be found at


See lines 37-42 (with no negative space) and 47-53 (with 14 negative thin spaces).

Thanks for your replies,

Russ

You received this message because you are subscribed to a topic in the Google Groups "PreTeXt support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-support/FvcRCp26AYw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/CACm44N-GT3SWEAOvCWopUwVU5gLya4MkrzLq%2BbQJcO1dEeNLWA%40mail.gmail.com.

Rob Beezer

unread,
Nov 11, 2025, 10:33:35 PMNov 11
to pretext...@googlegroups.com
Source looks beautiful! If you don't look too close at the negative spaces.

Ball in your court, Andrew. Thanks for digging into this one.
>> <https://groups.google.com/d/msgid/pretext-support/CACm44N-GT3SWEAOvCWopUwVU5gLya4MkrzLq%2BbQJcO1dEeNLWA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>

Andrew Scholer

unread,
Nov 12, 2025, 12:11:28 PMNov 12
to pretext...@googlegroups.com
I don't think there is an easy fix here.

PreTeXt produces something like this:

\begin{equation}
-K\left[\frac{T_x(x+\Delta x, \, y) - T_x(x,y)}{\Delta x}\right] \Delta
x \Delta y \approx -KT_{xx}(x,y) \Delta x \Delta y \tag{2}
\end{equation}

When \tag{X} is present, MathJax adds margin to either side of the equation based on its calculations of the size of the number produced by that.

So say the equation is 500 pixels and MathJax decides that the number (10.5.4) takes 60 pixels. It renders a 620px wide box for the equation. There is "dead" space on the left because it is trying to make sure there is space for the number on the right but the equation itself remains centered.

If what MathJax produces is too wide, none of our options are great:
* Current behavior - overflow
* Cut off the right side and make it scroll

There is not going to be a reliable way to override the spacing MathJax produces internally.

Other options:
* Rewrite the source so that equation takes up less space.
* Force a smaller font size for the math.
* Rewrite the math logic so it does not insert the number as a tag in the text MathJax will process. Instead, set up something like side by side divs, one with the equation and one with a number. Then try to write layout code that keeps the numbers lined up and forces just the equation box to scroll.


Andrew

Russell Howell

unread,
Nov 12, 2025, 12:36:19 PMNov 12
to pretext...@googlegroups.com
Thanks for digging into this issue, Andrew.

It seems weird that "There is "dead" space on the left because it is trying to make sure there is space for the number on the right but the equation itself remains centered" because that dead space is the culprit, no?

You didn't mention adding a bunch of negative thin spaces as an option. That seemed to work initially for this equation (before I removed it for the support post). Can I go back to that procedure and fix the (10.5.4) equation so that the number lines up on the right margin, or do you still need the version that is present now to remain there for possible future analysis?

Regards,

Russ

Andrew Scholer

unread,
Nov 12, 2025, 2:49:00 PMNov 12
to pretext...@googlegroups.com
I agree that relaxing the constraint to center the equation and removing some left deadspace would be preferable in this case. But that decision-making is all in MathJax's domain.

In an even more extreme case, the equation + number alone might be a problem.

I don't think there is much else to learn on the PreTeXt side. No need to preserve the source for that sample. If someone did want to completely reengineer numbering to take it out of MathJax's hands, any long equation with a number would work as a test case.

Andrew


Russell Howell

unread,
Nov 12, 2025, 2:52:47 PMNov 12
to pretext...@googlegroups.com
Dear Andrew,

Okay, and thanks again for your prompt replies.

Russ

Rob Beezer

unread,
Nov 12, 2025, 7:50:50 PMNov 12
to pretext...@googlegroups.com
On 11/12/25 09:35, 'Russell Howell' via PreTeXt support wrote:
> You didn't mention adding a bunch of negative thin spaces as an option.

Whatever LaTeX you put into an #men element, it is going to get placed into the
LaTeX-precursor of your PDF output, so it will now likely be aligned now too far
to the left?

Rob

Rob Beezer

unread,
Nov 12, 2025, 7:59:42 PMNov 12
to pretext...@googlegroups.com
Eventually this comes down to there must be an upper-limit on how long a line of
math can be. If not for HTML, for PDF. We are not magicians.

Of course, Russ' negative-space experiment suggests there is more room available
for HTML. I think trying to outsmart MathJax and manage tag placement ourselves
will be a continuing headache.

My own list of suggestions:

1. We restore Russ' great example and ask the MathJax folks what gives.
(Beyond Andrew's great sleuthing.)

2. Go with a horizontal scroll bar, which may just encourage sticking with
source material that will not behave elsewhere, like in EPUB.

3. Investigate numbered equations with numbers to the left. Disclaimer: I
think this is just too *weird*! I believe MathJax supports this option, and
LaTeX must also. So we make a publisher switch for this, and maybe HTML (with
horizontal scroll) is an OK compromise.

Rob

Russell Howell

unread,
Nov 12, 2025, 10:54:02 PMNov 12
to pretext...@googlegroups.com

--
You received this message because you are subscribed to a topic in the Google Groups "PreTeXt support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-support/FvcRCp26AYw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-suppo...@googlegroups.com.

Rob Beezer

unread,
Nov 15, 2025, 3:24:36 PMNov 15
to pretext...@googlegroups.com
On 11/12/25 19:53, 'Russell Howell' via PreTeXt support wrote:
> Rob, FYI (and regarding the negative thin space problem you pointed out), I have
> a separate LaTeX source file that I use to generate the PDF. Down the road, of
> course, it would be nice to do everything via PreTeXt.

Yes, a "static" PDF is a great trial-run for EPUB or braille (also both "static"
formats).

> David Farmer has a script
> that he used to get my LaTeX to PreTeXt in the first place. It saved an
> incredible amount of work, but there was (and still is) a lot of clean-up to do
> for a variety of issues.

Yes, David's conversions have been a great service!

> Speaking as an outsider, a horizontal scroll bar would be great, and given all
> the issues Andrew pointed out, that seems to me to be the way to go. But I don't
> know enough to make any firm judgments on this question.

You are not an outsider! ;-)

With your permission, I'd like to copy your "problem" equation into the sample
article and have the MathJax folks give it a look. That way you don't have to
sully your (great looking) project again just for testing purposes. Would that
be OK?

Thanks,
Rob

Russell Howell

unread,
Nov 15, 2025, 4:31:54 PMNov 15
to pretext...@googlegroups.com
Rob,

Sure, you are welcome to share the issue with the MathJax folks. I've already redone that part with negative thin spaces. Do you want me to change it back temporarily?

Russ

--
You received this message because you are subscribed to a topic in the Google Groups "PreTeXt support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-support/FvcRCp26AYw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-suppo...@googlegroups.com.

Rob Beezer

unread,
Nov 15, 2025, 6:44:28 PMNov 15
to pretext...@googlegroups.com
On 11/15/25 13:31, 'Russell Howell' via PreTeXt support wrote:
> Do you want me to change it back temporarily?
No, thanks, you've done enough already. I will make a copy in our "sample
article" testing document and we can always checkup on it, in addition to making
it available to MathJax now.

Thanks,
Rob


Reply all
Reply to author
Forward
0 new messages