inline "font-size" style for mjx-container

183 views
Skip to first unread message

Fletcher Dunn

unread,
Feb 21, 2021, 6:01:34 PM2/21/21
to MathJax Users
Hi!  Love this project, it's an absolute life saver!

I'm using offline node.js generator tex2chtml-page.

All of the mtx-containers it is emitting have an inline style of "font-size: 113.1%".  I grepped the code, but I could not for the life of me figure out where that is coming from.  I worked around it by adding a "scale: 1.0 / 1.131" entry to the chtml section of the config.  But I really wish I could understand where that scale factor is coming from to begin with.

Any ideas?

Thanks in advance,
Fletch

Davide Cervone

unread,
Feb 24, 2021, 1:46:13 PM2/24/21
to mathja...@googlegroups.com
Fletch:

Thanks for the kind works, and glad you are finding MathJax useful.

The font-size is based on the em and ex sizes that you have specified (or their defaults if you don't set them yourself).  Since MathJax in node doesn't have a browser DOM to with, it uses a very simple DOM that doesn't actually know the size of the fonts in your page, like a real browser does, so you have to specify the size my hand.  MathJax will then set the font-size so that the ex height of its fonts match the ex-height that you give it (for the page as a whole).  The formula is ex / mathjax_ex / em (where mathjax_ex is the ex-height off the MathJax font, which is .442) to get the scaling factor for the math (and multiplied by 100 to get the percentage font-size).  Since the defaults for ex and em are 8 and 16 pixel each, the result is 1.13122127, or 113.1% (to one decimal place).  Making the em-size 18 would get you 100.1%.

If you want to prevent MathJax from setting the font-size, you could set the matchFontHeight property to false for the CommonHTML output (rather than setting the scale factor or the em size).  But setting the em and ex sizes to accurately reflect the base font for your page might be the better choice.

Davide


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/fb6024d7-565e-48f4-bc23-39ceaa8be3f2n%40googlegroups.com.

Alexandros Grigoriadis

unread,
Sep 27, 2023, 9:39:37 AM9/27/23
to MathJax Users
That was a wonderful explanation Davide Cervone. Thank you for that.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages