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

`$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}$

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.

## 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 1 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.1 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 1; 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