# 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:

The Mathpix Snip tool is an extremely useful way to screen grab equations and turn them into LaTeX.

## LaTeX

For a Pressbook, your LaTeX equation must be wrapped in shortcode:
`$LaTeX eqn$`

or

`$LaTeX eqn$`

or

`$$LaTeX eqn$$`.

`$LaTeX eqn$`

For this reason, we suggest only using `$LaTeX eqn$`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.

### Examples

#### Inline LaTeX

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

This is an inline example $x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$ 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 $\large x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$ where the equation is in the sentence.
\Large: This is an inline example $\Large x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$ where the equation is in the sentence.
\LARGE: This is an inline example $\LARGE x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$ 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}$$`

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

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*}

NOTE:

• If you create a page and only use the display mode latex shortcode or , it will not render without an empty `` somewhere on the page.
• Currently for PDF exports, LaTeX must be wrapped in styled p tags to create display mode equations.
• $LaTeX Eqn$

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

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

Table of the most commonly used LaTeX commands.

## MathML

MathML can be used in Pressbooks, but it will only render in display/block mode. If you need inline display, currently you will need to use LaTeX.

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.

The above MathML renders as:

$x=\frac{–b±\sqrt{{b}^{2}–4ac}}{2a}$

By adding display=”block” to the math tag and adding an mstyle tag with fontsize=’2 pt’…

…you get:

$x=–b±b2–4ac2a$

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

$x=–b±b2–4ac2a$

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