LaTeX Questions Answered

55 Why won’t my LaTeX render properly in the PDF export of my book when it works fine in the web book?

Last update: Mar 17/21


PDFs in general can be finicky, and LaTeX is no exception to this. If your LaTeX is not displaying properly in a PDF, but renders just fine in the web book, one possible cause is excess spaces between commands: PDFs will often not display LaTeX formulas that are written with more than one space in a row. (Note that this is only the case with LaTeX rendered with MathJax, not QuickLaTeX.)

For example, the equation [latex]A = \dfrac{1}{2} b h[/latex] looks fine in the web book:

[latex]A = \dfrac{1}{2} b h[/latex]

But here’s a screenshot of what it looks like in the PDF:


You are not required to put spaces between LaTeX commands in order for them to be rendered in a readable way: equations are appropriately spaced automatically. However, it is common to insert spaces to make equations more readable for humans working in the back end. If you choose to add single spaces between commands for your own readability as a LaTeX writer, be sure to search for excess spaces using the Find feature in your browser and delete them.

Another possible reason for LaTeX not rendering properly in a PDF export is the delimiters used to distinguish LaTeX from regular text.

There are two kinds of delimiters that can be used to mark the boundaries between LaTeX and and regular text: [latex]…[/latex] and $$…$$. The former delimiters can be used for in-line equations (i.e., those that appear in the middle of a sentence), and the latter can be used for standalone equations that appear centred on their own line.

Unfortunately, equations written using $$…$$ delimiters do not render in PDFs. Any LaTeX formulas you write using these delimiters may appear in the web book, but they will appear in the PDF exactly as they appear in editor view in Pressbooks.

To demonstrate, this equation has been written using [latex]…[/latex] delimiters:


This equation has been written using $$…$$ delimiters:


And here is a screenshot of a similar section of code in a PDF export:


For this reason, it is best practice to only use [latex]…[/latex] delimiters. If you would like your equation to appear centred and on its own line, simply write the equation in a new paragraph and manually centre it using the “Align centre” button or the shortcut Shift + Alt + C.


Icon for the Creative Commons Attribution 4.0 International License

Pressbooks Guide by BCcampus is licensed under a Creative Commons Attribution 4.0 International License, except where otherwise noted.

Share This Book