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: 

[latex]\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}[/latex]

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:

[latex]\alpha[/latex]

\(\alpha\)

[latex]\beta[/latex]

\(\beta\)

[latex]\omega[/latex]

\(\omega\)

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

[latex]\Gamma[/latex]

\(\Gamma\)

[latex]\Delta[/latex]

\(\Delta\)

[latex]\Omega[/latex]

\(\Omega\)

Superscripts and Subscripts

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

[latex]x_i^2[/latex]

\(x_i^2\)

[latex]\log_2 x[/latex]

\(\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:

[latex]10^10[/latex]

Generates \(10^10\) NOT \(10^{10}\)

The proper grouping syntax would be:

[latex]10^{10}[/latex]

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

[latex]x_i^2[/latex]

\(x_i^2\)

[latex]x_{i^2}[/latex]

\(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:

[latex](\frac{\sqrt x}{y^3})[/latex]

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

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

[latex]\left(\frac{\sqrt x}{y^3}\right)[/latex]

\(\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:

[latex]\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)[/latex]

\(\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:

[latex]\sum_1^n[/latex]

\(\sum_1^n\)

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

[latex]\sum_{i=0}^\infty i^2[/latex]

\(\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.

[latex]\frac ab[/latex]

\(\frac ab\)

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

[latex]\frac {a+1}{b+1}[/latex]

\(\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:

[latex]{a+1 \over b+1}[/latex]

\({a+1 \over b+1}\)

This is useful for creating more complex fractions such as:

[latex]\frac {a+1 \over b+1}{c+1 \over d+1}[/latex]

\(\frac {a+1 \over b+1}{c+1 \over d+1}\)

Radical Signs

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

[latex]\sqrt{x^3}[/latex]

\(\sqrt{x^3}\)

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

[latex]\sqrt[3]{x^3}[/latex]

\(\sqrt[3]{x^3}\)

You can also put fractions within radicals.

[latex]\sqrt[4]{\frac xy}[/latex]

\(\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.