Problems with LaTeX in Pressbooks PDF Export

Hello everyone,
I have equations written in LaTeX in a book built in Pressbooks that are causing problems. The equations display correctly in the web book, but don’t display correctly in the exported PDFs. It’s only a few equations, not all. I am a LaTeX novice, and I’m hoping someone might be able to help me identify what the source of the problems are. Here’s a link to a chapter in the web book that has the equations formatted correctly. One example is the very last equation at the end of the chapter. in the exported PDF it shows up as the raw LaTeX code minus the [LaTeX] brackets at the beginning and end. Here’s the equation written in LaTeX:

[latex]\frac{1.75\times10^{-4}\text{ moles Ca(OH)}_2}{80\text{ mL Ca(OH)}_2}\times\frac{1000\text{ mL Ca(OH)}_2}{1\text{ L Ca(OH)}_2}=\frac{2.19\times10^{-3}\text{ moles Ca(OH)}_2}{\text{L}}\text{ or }2.19\times10^{-3}\text{ M Ca(OH)}_2[/latex]

Hi Colby, this looks like a well-formed LaTeX expression – it’s a good sign that MathJax is able to render it correctly in the webbook. I did a quick test with this expression and saw the same thing you were seeing. When I isolated the expression and pasted it on its own in another book/chapter, however, the expression was produced successfully. I was able to fix it in your book by simply taking the expression that you included above, going into the text editor in Pressbooks and pasting that equation (without formatting) and reproducing the export. I can’t explain what was different between the two expressions, but it seemed to work for me. My suggestion is to take any of the latex expressions that work in the webbook but not in the PDF, copy them, and then paste without formatting in the text editor and see if that cleans them up somehow. I’m baffled as to why, but it seems to work???

1 Like

Thanks a bunch, Steel. I’ll give that a try.

This is working for me now, Steel. Thanks again! It’s much appreciated. Also, I’ve added your name to the list of minor contributors to the Soils Laboratory Manual, which includes anyone who identifies typos or other issues with the lab manual.

2 Likes

Steel’s solution for this issue also resolved some issues that occurred with LaTeX equations in the EPUB export. There were equations that rendered correctly in the web book and the PDFs, but not the EPUB. This solution resolved that issue the same as it did for the PDF exports.