(1) Getting started
There are three different types of markup (formatting commands) that we can differentiate between.
Markdown
Markdown is a simple markup language that is widely used on the Internet, and is built into all Stack Exchange websites. It allows you to (for example) write bold text, italicised text, and create hyperlinks.
When writing a question or answer, there are a number of buttons in the editing box that can help you with this. For more information, please see the editing help.
A limited subset of raw HTML tags are allowed on Stack Exchange, but these should generally not be required to write an answer.
MathJax
MathJax is a library which allows your web browser to display expressions written in $\LaTeX$ syntax.
Expressions that are enclosed within single ($...$
) or double ($$...$$
) dollar signs are interpreted using MathJax. Where possible, all mathematical expressions, except those in titles, should be typed using MathJax.
$...$
- A pair of single dollar signs specify an inline equation. This means you can use it seamlessly inside a sentence.
Type this:
Let $V$ denote the volume of a gas.
to get this:
Let $V$ denote the volume of a gas.
$$...$$
- A pair of double dollar signs specify a display equation. It gets its own line, is generally slightly larger, and is centred on the page.
Type this:
The ideal gas law is written as:
$$ pV = nRT $$
to get this:
The ideal gas law is written as: $$ pV = nRT $$
mhchem
The mhchem
package for MathJax adds extra functionality for chemical equations, as well as quantities with units, in MathJax. It provides two main commands:
\ce{...}
is used for typesetting chemical formulae and equations;
\pu{...}
is used for typesetting numbers with units / dimensions.
These two commands must appear within a MathJax expression: that means it must itself be enclosed either with $...$
or $$...$$
. Whatever is placed within the braces will be automatically passed to the mhchem package for rendering.
Note that the use of plain MathJax, i.e. $H_2O$
, leads to italicised chemical symbols like $H_2O$ which are not correct. Therefore, chemical equations should always be typeset using mhchem, and not simply in plain MathJax.
Type this:
The chemical formula of water is $\ce{H2O}$.
The freezing point of water is $\pu{273.15 K}$.
to get this:
The chemical formula of water is $\ce{H2O}$.
The freezing point of water is $\pu{273.15 K}$.
(Back to index)
Next section: (2.1) Basic MathJax: Superscripts and subscripts