# Display of mathjax equations in PDF

Hi!

I am working on a book that is using Latex + Mathjax, and I have two formatting problems I am trying to find workarounds for (You can find the book here: https://pressbooks.bccampus.ca/mark/) :

1. The authors want the equations to display by default quite a bit larger than the rest of the text. In the webbook, I’ve accomplished this by adding class="big" to the latex equations in the editor, which I’ve set in the CSS to be:

.big {
font-size: 175%
}

However, this does not work when the equations are displayed in the PDF. Is there a way to increase the size of equations in the PDF also? I’ve tried img.mathjax { max-width: 175%;} with no success.

1. There are a few cases where I want fractions to appear inline. This works in the webbook, but in the PDF, the equations are always centred (See screenshots below). Is there a way to get latex equations to display inline in the PDF?
Display of inline latex equations in webbook

Display of inline latex equations in PDF
1 Like

Hi Josie! Are you using the native MathJax tool or the WP Quick LaTeX plugin? Quick LaTeX should have a font size option. I thought there was a way to specify size with LaTeX shortcode native solution as well, but can’t remember what it is right now … maybe @mcgratay will remember?

We are using Mathjax for this book!

1 Like

When you’re in Custom Styles, at the top there is a drop-down where you can select PDF. See if the same class=“big” CSS approach will work for the PDF output.

Yes I have tried that. In the PDF that CSS only works on text, not equations created with Latex.

Hi Josie, we’re actually facing a similar problem with a logic text, with the MathJax tool, so I wanted to follow along this thread.

In our book, the sizing of equations in the webbook is perfect, however they appear to be too big in PDF, and too small in the EPUB file. A volunteer on the Logic book also observed that with the EPUB, the images are rendered as PNG images. He notes “However, the img tags lack appropriate CSS to adjust font-size and baseline alignment individually (just some blanket styles by class). I’m guessing the same holds true for the PNG, albeit with different effects.” (see the project thread for the full conversation)

For the PDF — I did have some progress controlling the size by adjusting the image height, but found that the changes in size were not very consistent (some equations rendered much smaller than others):

img.mathjax {
max-height: 0.9em;
width: auto; }


Based on the the MathJax documentation, it seems like the best way to adjust font-size is when configuring the plugin itself, so maybe the Pressbooks team can look into this? We’ve had a very helpful volunteer from MathJax look into some of the issues we’ve found in our book, and have connected them with the Pressbooks team. Hopefully, we’ll hear an update about these sizing and display questions once they’ve been able to chat.

1 Like

Hey, y’all. I’m recalling that with a similar issue escalated to us previously it helped to use latex size commands, which you can see described here: https://www.sascha-frank.com/latex-font-size.html

I haven’t tested this comprehensively, so I’m not sure if this solution will fit the context of this particular problem, but hope you find it useful!

1 Like

Thanks @mcgratay! That looks like the best solution. I am removing my CSS and adding \LARGE to the beginning of all Latex equations. That works in both web and PDF.

If anyone finds a solution to equations not displaying inline that would be wonderful.

2 Likes