# Inserting Math into BULB Lesson Pages

BU Learning Blocks sites support the use of MathJax-LaTeX plugin in order to render mathematical formulae and equations. The MathJax-LaTeX plugin enables MathJax functionality for WordPress.

## What is MathJax? What is MathJax-LaTeX?

MathJax is a JavaScript display engine for mathematics that works in all browsers. MathJax enables rendering of embedded LaTeX or MathML in HTML pages. The MathJax JavaScript is inserted and loaded only on those pages which require it. This ensures that MathJax is not loaded for all pages, which will otherwise slow loading down.

The MathJax-LaTeX plugin allows for the embedding of MathJax (using the LaTeX syntax) into BULB pages.

## How do I embed MathJax-LaTeX equations on a BULB Lesson Page?

MathJax LaTeX equations are added to BULB Lesson Pages in normal paragraph blocks, shortcode blocks, or in BULB content block fields such as question header, question body, and in the answer fields of the Multiple Choice or Multiple Answer Blocks.

In order to put a MathJax LaTeX equation into these fields, all you need is to surround your LaTeX equation between the LaTeX shortcode tags. To begin, type the word “latex” surrounded by square brackets, insert your LaTeX syntax, then close the shortcode with the “/latex”–again surrounded by square brackets.

This is better illustrated through an example. If you wanted to render the following equation:

$$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$

You would type this in the appropriate block in your page editor:

$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$


You can use these shortcodes multiple times per page—in paragraph Blocks, shortcode blocks, or within BULB block content areas.

## Common Syntax

#### Greek Letters

For using Greek letters use \alpha, \beta, …, \omega, like this:

$\alpha$

$$\alpha$$

$\beta$

$$\beta$$

$\omega$

$$\omega$$

For uppercase, use \Gamma, \Delta, …, \Omega:

$\Gamma$

$$\Gamma$$

$\Delta$

$$\Delta$$

$\Omega$

$$\Omega$$

#### Superscripts and Subscripts

To add superscripts and subscripts use the “^” and “_”. For example:

$x_i^2$

$$x_i^2$$

$\log_2 x$

$$\log_2 x$$

#### Groups

Superscripts, subscripts, and other operations apply only to the next “group”. A “group” is either a single symbol, or any formula surrounded by curly braces, { and }. For example, it you want to show:

$$10^{10}$$

You will need to be careful of grouping:

$10^10$

Generates $$10^10$$ NOT $$10^{10}$$

The proper grouping syntax would be:

$10^{10}$

Use curly braces to delimit the formula to which a superscript or subscript applies. Observe the difference between the following two examples:

$x_i^2$

$$x_i^2$$

$x_{i^2}$

$$x_{i^2}$$

#### Parentheses

Ordinary symbols () and [] make parentheses and brackets. Use \{ and \} to render curly brackets. These symbols do not scale to the formulae that they enclose. To do so, use “\left” and “\right” to make the sizes adjust to the size of the formulae they enclose. For example:

$(\frac{\sqrt x}{y^3})$

$$(\frac{\sqrt x}{y^3})$$

Instead, view the same equation using the “\left” and “\right” delimiters:

$\left(\frac{\sqrt x}{y^3}\right)$

$$\left(\frac{\sqrt x}{y^3}\right)$$

“\left” and “\right” apply to all the following sorts of parentheses (again, make sure to always enclose your formulae in the “latex” shortcode tags):

• “(” and “)” = (x) = $$(x)$$
• “[” and “]” = [x] = $$[x]$$
• “\{” and “\}” = \{x\} = $$\{x\}$$
• “\|” = \|x\| = $$\|x\|$$
• “\vert” = \vert x \vert = $$\vert x \vert$$
• “\Vert” = \Vert x \Vert = $$\Vert x \Vert$$
• “\langle” and “\rangle” = \langle x \rangle = $$\langle x \rangle$$
• “\lceil” and “\rceil” = \lceil x \rceil = $$\lceil x \rceil$$
• “\lfloor” and “\rfloor” = \lfloor x \rfloor = $$\lfloor x \rfloor$$

You can make manual adjustments to the sizes by using the following syntax:

$\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)$

$$\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)$$

#### Sums and Integrals

“\sum” and “\int” create sums and integrals. The subscript is the lower limit and the superscript is the upper limit. For example:

$\sum_1^n$

$$\sum_1^n$$

Remember, if you want to include more complex subscripts and superscripts, use curly brackets { and }.

$\sum_{i=0}^\infty i^2$

$$\sum_{i=0}^\infty i^2$$

Similar syntax applies to:

• $$\prod$$ = \prod
• $$\int$$ = \int
• $$\bigcup$$ = \bigcup
• $$\bigcap$$ = \bigcap
• $$\iint$$ = \iint
• $$\iiint$$ = \iiint

#### Fractions

There are three main ways to generate fractions. “\frac” applies to the next two groups.

$\frac ab$

$$\frac ab$$

Make sure you use curly brackets, “{” and “}”, to create more complex fractions.

$\frac {a+1}{b+1}$

$$\frac {a+1}{b+1}$$

If your numerator or denominator is more complicated, you may want to use “\over” to split a single group. For example:

${a+1 \over b+1}$

$${a+1 \over b+1}$$

This is useful for creating more complex fractions such as:

$\frac {a+1 \over b+1}{c+1 \over d+1}$

$$\frac {a+1 \over b+1}{c+1 \over d+1}$$

Use “\sqrt” to create formulae using radical signs. For example:

$\sqrt{x^3}$

$$\sqrt{x^3}$$

Use square brackets to designate the level of your radical (square root, cube root, etc…).

$\sqrt[3]{x^3}$

$$\sqrt[3]{x^3}$$

You can also put fractions within radicals.

$\sqrt[4]{\frac xy}$

$$\sqrt[4]{\frac xy}$$

For more detailed expressions, please consider referencing this guide.

Reminder: While using BULB, please be sure to always enclose your formulae in the “[ latex ]” opening tag and “[ /latex ]” closing tag (with the spaces removed) or the latex syntax will not render on the page.

#### Inserting Math into BULB Lesson Pages

Posted 4 years ago