MathJax Issues

Hello, hivemind!

After the exciting announcement about MathJax yesterday, I have been working on changing over the math in a version of OpenStax University Physics that the Iowa State team is working on right now (since OpenStax has MathML, this update has made copying a lot easier). However, I have run into a strange issue that I’m unsure how to fix:

Most equations are displaying correctly in the book (example),
image
but some are displaying with the fonts much smaller than the surrounding text. Do you know what might be causing this? There is nothing inherently different about the equations that are displaying incorrectly.

Incorrect%20display

I look forward to hearing your hypotheses and potential fixes!

-Abbey Elder

Abbey could you post the HTML (or a link to the chapter with the problems)?

No problem, here is the chapter I’ve already fixed the code (from $ $ around equations to $latex $ around equations) for example: https://iastate.pressbooks.pub/universityphysics2/chapter/1-2-thermometers-and-temperature-scales/

(The book is set to public for now, but I will have to set it to private after this since it is definitely not finished.)

On closer inspection, it looks like when the equation is in a box or table it renders properly, but in the main text is becomes small. It might be something fixable in the theme?

In which output are you finding the problem? Web, pdf, or epub?

Good question!

I had only been checking in Web so far, as this was my first try at cleaning up the equations with new formatting. After a quick export, it appears that everything is displaying at the correct size in pdf and epub (though some of the equations aren’t rendering at all anymore- I’ll need to look into that).

If I weren’t already 11 chapters into the book, I’d consider starting over and doing it all in MathML, but…

Abby,

Thanks for doing this important work. Importing OpenStax books are not easy, and lots of work to do the cleaning and adding back metadata.

There are quite a few organizations that are doing this kind of work. We should make sure we all know who each other are and that we aren’t duplicating each others labor. @allisonbrown has done quite a few of these in SUNY. Just a thought. Thanks for your work.

Ed

1 Like

Thanks, Ed,

This is the first OpenStax book we’ve worked on, since it’s one of the few not already in Pressbooks.
I checked ahead of time and it looks like no one had done University Physics Vol 2 yet, but I’ll be sure to share out the news when we’ve got our import into Pressbooks done, to avoid extra duplication!

I will also 100% be importing the back matter from University Physics Vol I in the SUNY catalog. Thanks for the information!

Abbey

1 Like

Update for anyone following this thread. @mcgratay wrote offline to @Abbey_Elder:

The theory we’re working with right now is that MathJax equation sizing is relative to the size of the text. If you’ll notice, the text within the textbox has a different font and font size than that of the body.

Abbey replied that when she changed the theme to one that uses a larger font, the anomalously small equations were rendering more in line with her expectations. For others seeing math expressions smaller than they expect, our advice for now is to check the font size of the surrounding text and/or CSS rules for the active theme.

1 Like

Hi all. I am in a similar, but slightly different, boat with MathJax. We are also creating a localized version of the OS Physics textbook and having a MathJax issue with the LaTeX.

The webbook appears to display them fine, [despite the fact that the MathJax settings page has the ‘PB_MATHJAX_URL is not configured’ message], but the PDF (using mPDF) does not. It only displays the markup. (see attachment).

Any ideas how to “configure” MathJax or what this issue could be?

I don’t think we at Pressbooks will be able to offer much help, as mPDF is a third party plugin (that is no longer maintained by its creator: https://github.com/BCcampus/pressbooks-mpdf). Best I can do is to ask whether you’ve installed and configured this microservice for your network? https://github.com/pressbooks/pb-mathjax. That’s what we use to generate LaTeX with MathJax in our hosted networks.

This was a change introduced in Pressbooks 5.9.0, FWIW: https://github.com/pressbooks/pressbooks/releases/tag/5.9.0

Thanks Steel. I will investigate the microservice idea with our systems person.

I know about mPDF no longer being supported. You think it could be an mPDF issue?

Not sure – I think the LaTeX microservice is more likely, but since you mentioned it being a problem with PDF exports and that you’re using mPDF, I thought I should mention it.

@jlsmith

I think you need to start with the microservice first. MathJax typically runs in the end users browser, and it converts what is in the HTML code to display on the website. If you right click on any equation, you have a whole menu with display options. You could choose for math to be rendered in HTML+CSS or you could choose for it to be rendered as an SVG. The changes you make only effect what is displayed in your browser, and another user can change for themselves. This version of MathJax only works in the web version of the book.

Pressbooks has integrated the MathJax microservice in a way that when you download an HTML version (or the PDF , EPUB or MOBI files that are built from that HTML version) it switches out what the creator put in for an image of the equation (removing the dependency of a browser that works with MathJax and making sure the equation is embedded into the PDF.)

I’m afraid that even if you install the microservice it will just not work with mPDF. I have a Pressbooks server with both mPDF and PrinceXML installed and equations only render when you use Prince. Many people in the open community chose mPDF because it was completely open source, but Prince is going to work better in the long run and is the only PDF option that Pressbooks directly supports. The mPDF plugin really was only a viable option when BC Campus invested in it by assigning a developer to keep up with changes and when things broke. Look into Prince’s non-commercial license and decide whether your OER use can fit in their guidelines for free use. My opinion is that it does.

Using Prince also has other advantages, like the PDFs you export for digital distribution will pass accessibility checkers and tests, which the mPDF export would fail.

1 Like

Thanks Ed. This is good advice and I think moving over to the Prince NCL is the way to go.

1 Like