Appendix B: Math and Chemistry Equations

Pressbooks uses the MathJax display engine to render accessible equations. Both LaTeX and MathML can be used. Right/Control click on any of the quadratic equations below to see the accessible content.

You can create LaTeX, MathML and chemistry equations by using these editors:

Equatio and the Mathpix Snip tool are extremely useful ways to screen grab equations and turn them into LaTeX. They even work with hand written equations.

LaTeX

For a Pressbook, your LaTeX equation must be wrapped in shortcode:
[latex]LaTeX eqn[/latex]

or

\[LaTeX eqn\]

or

$$ LaTeX eqn $$.

However, if you want to create PDF versions of your book for your readers to download, use:

[latex]LaTeX eqn[/latex]

For this reason, we suggest only using [latex]LaTeX eqn[/latex]for your LaTex equations. This way if you ever decide to make PDF files available for your readers, you will not have to edit your chapters.

Here is Wikipedia’s list of LaTeX mathematical symbols.

For 18,000+ symbols and the corresponding LATEX commands that produce them, check out Scott Pakin’s The Comprehensive LaTeX Symbol List.

For PDF Export

If you want to export a PDF of your Pressbook with LaTeX content:

  • Use Digital PDF export
  • LaTeX in image captions does not render; put caption content in the chapter’s text
  • Must use [latex]equation[/latex], not $$ or \[ \]
  • Math ML does not render

Examples

Inline LaTeX

[latex]x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}[/latex]

This is an inline example [latex]x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}[/latex] where the equation appears in the sentence.

Sometimes equations can render so small, they’re difficult to read. You can solve this by using \large or \Large or \LARGE at the the beginning of the LaTeX equation.

\large: This is an inline example [latex]\large x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}[/latex] where the equation is in the sentence.
\Large: This is an inline example [latex]\Large x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}[/latex] where the equation is in the sentence.
\LARGE: This is an inline example [latex]\LARGE x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}[/latex] where the equation is in the sentence.

This site lists even more sizes.

Display mode LaTeX

Display mode renders an equation centered on a separate line.

\[x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}\]
or
$$x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$$

[latex]\large x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}[/latex]

The following HTML creates the aligned equations below.

\[\large\begin{align*}
(x – 2)(x + 1)(x + 3) & = (x^2 – x – 2)(x + 3) \\
& = (x^2 – x – 2)(x) + (x^2 – x – 2)(3) \\
& = x^3 – x^2 – 2x + 3x^2 – 3x – 6 \\
& = \boxed{x^3 + 2x^2 – 5x – 6}
\end{align*}\]

\[\large\begin{align*}
(x – 2)(x + 1)(x + 3) & = (x^2 – x – 2)(x + 3) \\
& = (x^2 – x – 2)(x) + (x^2 – x – 2)(3) \\
& = x^3 – x^2 – 2x + 3x^2 – 3x – 6 \\
& = \boxed{x^3 + 2x^2 – 5x – 6}
\end{align*}\]

NOTES:

  • If you create a page and only use the display mode latex shortcode or $$, it will not render without an empty instance (no equation) of the latex shortcodes somewhere on the page.
  • Currently for PDF exports, LaTeX must be wrapped in styled p tags to create display mode equations.
    • HTML paragraph tag styled with text aligned to center and LaTeX equation
      Figure 1: Screen grab of HTML p tags with centered LaTeX equation.

      [latex]LaTeX Eqn[/latex]

      [latex]\large x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}[/latex]

    • A slight shortcut is to do this in the Visual editor by highlighting a LaTeX equation and pressing the “Align center” button in the first row of the toolbar. There’s also a keyboard shortcut for this which is revealed when hovering over that button.

LaTeX Symbols: The Basics

Description Command Output
addition + +
subtraction _ _
plus or minus \pm [latex]\pm[/latex]
multiplication (times) \times [latex]\times[/latex]
multiplication (dot) \cdot [latex]\cdot[/latex]
division symbol \div [latex]\div[/latex]
division (slash) / /
circle plus \oplus [latex]\oplus[/latex]
circle times \otimes [latex]\otimes[/latex]
equal = =
not equal \ne [latex]\ne[/latex]
less than < <
greater than > >
less than or equal to \le [latex]\le[/latex]
greater than or equal to \ge [latex]\ge[/latex]
approximately equal to \approx [latex]\approx[/latex]
infinity \infty [latex]\infty[/latex]
dots 1,2,3,\ldots 1, 2, 3, . . .
dots 1+2+3+\cdots 1 + 2 + 3 + á á á
fraction \frac{a}{b} [latex]\frac{a}{b}[/latex]
square root \sqrt{x} [latex]\sqrt{x}[/latex]
nth root \sqrt[n]{x} [latex]\sqrt[n]{x}[/latex]
exponentiation a^b [latex]a^b[/latex]
subscript a_b [latex]a_b[/latex]
absolute value |x| |x|
natural log \ln(x) [latex]ln(x)[/latex]
logarithms \log_{a}b [latex]\log_{a}b[/latex]
exponential function e^x=\exp(x) ex [latex]e^x=\exp(x)[/latex]
degree \deg(f) [latex]\deg(f)[/latex]
Example x=\frac{-b\pm\sqrt{b^2-4ac}}{2a} [latex]x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}[/latex]

Table of the most commonly used LaTeX commands.

MathML

MathML can also be used in Pressbooks as well as LaTeX, though short code is not needed for MathML.

Figure 2 is a screen grab which was the only way to display the MathML without it rendering.

Math ML equation
Figure 2 Screen grab of MathML

The above MathML renders as:

x=b±b24ac2a

Changing “block” to “inline” gives you inline equations. By adding display=”block” to the math tag and adding an mstyle tag with fontsize=’2 pt’…

MathML equation with display and m style added
Figure 3 Display options added to MathML

…you get:

x=b±b24ac2a

If you use fontsize=’2.5 pt’, you get:

x=b±b24ac2a

NOTE:

You don’t need the xmlns=“http://www.w3.org/1998/Math/MathML” in the math tag as is shown in Figure 2; Pressbooks does this. You just need the <math> and </math> tags.

Below are helpful resources for MathML.

Beginner’s Guide to MathML by Daniel Scully

Wolfram MathML examples

MathML Quick Guide

License

Icon for the Creative Commons Attribution 4.0 International License

PSU OER Pressbooks Quick Start Guide Copyright © 2020 by Wade Shumaker is licensed under a Creative Commons Attribution 4.0 International License, except where otherwise noted.

Share This Book