Latex color change causes "Formula Does Not Parse" in PDF Export

I am working on an instructor copy of a lab manual in Pressbooks. I am making all completed answers in the instructor copy be blue. Normal Latex equations format fine in all exports. However, I realized today that in the PDF export for digital distribution, Latex formulas that have been formatted blue using the \color{blue} command result in a notification in the PDF export of “Formula Does Not Parse”. It exports fine in the Web Book, but not in the PDF exports. Is this a CSS issue? I had a similar sort of problem with TablePress.
Latex code:

I’ll put other pictures in replies below due to the rule that new users can only post one media file per post.

Formula Does Not Parse error in the exported PDF:

The formula working fine in the web book:

Two questions:

  1. what method are you using for rendering LaTeX in this book? MathJax or WP QuickLaTeX?
  2. can you share the book’s URL and an example chapter where you’re having problems in the PDF export?
  1. I’m actually not sure. I add the Latex code directly to the text for each chapter.
  2. The book is here: The chapter I’m having issues with is not publicly available, but is titled “Instructor Copy of Chapter 10 - Soil Water Measurement and Movement”

I will piggy-back on this one, if that is OK.

My PDF’s are not displaying LaTeX equations ([…]); instead they are displaying the LaTeX code. They display fine in web form. I am using MathJax. Here are a couple of examples:

Another example (outside of textbox):

@ColbyDigsSoil it looks like your book is using MathJax. I don’t see the LaTeX expressions you’re having trouble with in that chapter. I’d recommend sending an email to our premium support address which includes the specific equations that aren’t parsing and a chapter where they can be found and/or a PDF file where the output isn’t being included.

@Ana your issue looks different to me. I’m not sure why initial expressions are rendering correctly in the PDF but later ones aren’t. To debug, I’d need to see the book where you’re having problems or the full contents of the text editor for the chapter in question. Can you share a URL?

1 Like

@Ana before you share the URL, you should check to make sure that the expressions that aren’t rendering in your export files are in fact wrapped in [latex] [/latex] shortcodes. Most of the time we find that PDF errors like the ones I see in your example are the result of missing shortcodes. At present our export routines need the [latex] shortcode flags to know that they should convert the content in between them into images rendered with LaTeX for our EPUB and PDF exports, which can’t use the MathJax javascript library to render the math like our webbooks can.

@SteelWagstaff, what is the premium support email address? I can’t seem to find it on any Pressbooks websites.

We don’t share it on the public web because it’s reserved for network managers, but I sent you a DM with the address.

1 Like

I’m replying here to document the solution that I received from Thomas from Pressbooks. The original code I used was like this:


However, I needed to add curly brackets around the code that is to be colored in blue, like this:


Here is the excellent explanation from Thomas:

The distinction between the two is that the former syntax is a declaration of a color change, while the latter is a command form that takes the text to be colored as an argument. It’s not clear to me why the PDF is able to parse the latter and not the former, but this should solve the issue without affecting the appearance of the web book.

This worked for my exports and does in fact still look great in the web book. Thanks Thomas, Steel, and Pressbooks for the help.