Blatantly ripped off from chem.SE, this post is meant to help people understand how to use MathJax formatting of mathematical expressions here on Robotics.


1 Answer 1


Getting started with MathJax

On Robotics Stack Exchange, we use MathJax to format mathematical expressions. MathJax is a tool that lets us display LaTeX expressions on a browser.

To use MathJax, enclose your mathematical expressions within single($...$) or double($$...$$) dollar signs. Single dollar signs make the expression inline, for example, Let $x$ be a variable gives:

Let $x$ be a variable.

On the other hand, double dollar signs make the expression a block element. It gets its own line, and is slightly larger. For example, The equation of motion is as follows: $$v=u+at$$ It is a SUVAT equation gives:

The equation of motion is as follows: $$v=u+at$$ It is a SUVAT equation

Note that the extra spaces in LaTeX do not render, use \: or ~ for a space.

Basic MathJax

Superscripts and subscripts

You can denote superscripts via the ^ character, and subscripts via _. For example, x^2 renders as $x^2$, x_1 renders as $x_1$, and x_1^3 renders as $x_1^3$.

If you want to include more than one character in the super/sub script, enclose it in curly braces ({...}).

For example, x^10 renders as $x^10$, but x^{10} renders as $x^{10}$

To put superscripts before the symbol, do this: {^{a}R_{b}} which renders as: ${^{a}R_{b}}$

Fractions and square roots

Fractions can be easily displayed using \frac{..}{..}. For example, \frac{a+b^c}{de+f} renders as $\frac{a+b^c}{de+f}$

Protip: You can exclude the braces for single-character numerators/denominators (if the first character is a letter, you need to use a space after \frac, though). For example \frac12 renders as $\frac12$, and \frac ab renders as $\frac ab$

Square roots can be added in a similar manner, via \sqrt{....}. For example, \sqrt{x+y} renders as $\sqrt{x+y}$.


\dot{x} \hat{y} \bar{h} \overrightarrow{v} J^\dagger J^{+} T^\top z' a^{\circ} render as:

$\dot{x}$ $\hat{y}$ $\bar{h}$ $\overrightarrow{v}$ $J^\dagger$ $J^{+}$ $T^\top$ $z'$ $a^{\circ}$

Matrices and vectors

Row vectors are easy enough. $[xyz]$ $(xyz)$ render as: $[xyz]$ $(xyz)$ But you might want to use a space separator. $[1,2,3]$ $[x~y~z]$ $(x~y~z)$ render as: $[1,2,3]$ $[x~y~z]$ $(x~y~z)$

Column vectors are done like this. \begin{pmatrix} x \\ y \\ z \end{pmatrix} \begin{bmatrix} a \\ b \\ c \end{bmatrix} render as:

$$\begin{pmatrix} x \\ y \\ z \end{pmatrix}~~\begin{bmatrix} a \\ b \\ c \end{bmatrix}$$

2D matrices can also have parentheses or brackets by using pmatrix or bmatrix accordingly. Here is the structure:

r_{11} & r_{12} & r_{13}\\
r_{21} & r_{22} & r_{23}\\
r_{31} & r_{32} & r_{33}

$$ \begin{bmatrix} r_{11} & r_{12} & r_{13}\\ r_{21} & r_{22} & r_{23}\\ r_{31} & r_{32} & r_{33} \end{bmatrix} $$


\otimes \cdot \in \circ \bullet render as: $\otimes$ $\cdot$ $\in$ $\circ$ $\bullet$

Greek letters

Greek letters can be added usung a backslash (\), followed by the name of the letter. Captialise the first letter of the name for greek capital letters.

Eg \alpha \beta \gamma \delta \Omega \Delta renders as $\alpha$ $\beta$ $\gamma$ $\delta$ $\Omega$ $\Delta$.

Make sure that you put spaces after these if you are typing normal alphabet characters. Eg e^{\pii} gives an error, you need to use e^{\pi i} for $e^{\pi i}$.

Note that there are special commands \varepsilon \varsigma \varrho \varpi to distinguish between the lunate Greek letters ($\varepsilon$ $\varsigma$ $\varrho$ $\varpi$ rather than $\epsilon$ $\sigma$ $\rho$ $\pi$).

Misc. Symbols

\nabla \infty \partial renders as $\nabla$ $\infty$ $\partial$

Font stuff

boldsymbol and mathbf have slightly different results: for example: \boldsymbol{x} \mathbf{x} render as: $\boldsymbol{x}$ $\mathbf{x}$

Another fancy font: \mathbb{R} renders as: $\mathbb{R}$

Further reading

Thanks to Manishearth for the chem.SE answer on which this is based.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .