18
$\begingroup$

$\mathrm{\TeX}$ is a markup language that allows us to insert content like equations and tables. MathJax is the add-in that StackExchange uses to render $\mathrm{\TeX}$ markup into $\mathrm{\TeX}$ graphics.

Using $\mathrm{\TeX}$ is simple:

  1. Put $ before-and-after $\mathrm{\TeX}$ markup to instruct MathJax to render it.

    • Example: Typing $x+1$ into a post renders $x+1$.
  2. Alternatively, put $$ before-and-after $\mathrm{\TeX}$ markup to instruct MathJax to render it centered on a new line.

    • Example: Typing $$x+1$$ into a post renders $$x+1$$

Answers below discuss more things that can be done with $\mathrm{\TeX}$.


See also

  1. Similar guides:

  2. MathJax's official website

  3. StackExchange for TeX/LaTeX

  4. "MathJax" on GitHub

  5. Wikipedia: "TeX"; "LaTeX"; "MathJax"


This question's meant to be a lot like the one at SE.Mathematics.Meta: "MathJax basic tutorial and quick reference". It's posted separately here to both give this SE its own version of it (making it easier to find and such) and also since there's likely going to be some variation in what features/commands users would be interested in here vs. at SE.Mathematics. That said, it'd make sense for responses to this question to have a similar formatting and often to cover the same content.

I'd suggest contributors write up one feature per answer, giving each a standardized title, rendering of the relevant $\TeX$, and the code markup for it.

$\endgroup$
10
$\begingroup$

Bra-ket notation

Related: "How does bra-ket notation work?".

Bra: $\left< x \right|$

\left< x \right|

Ket: $\left| x \right>$

\left| x \right>

Bra-ket: $\left< x \middle| y \right>$

\left< x \middle| y \right>

Bra-ket, extended: $\left< x \middle| y \middle| z \right>$

\left< x \middle| y \middle| z \right>

Tensor Product: $\left| x \right> \otimes \left| y \right>$

\left| x \right> \otimes \left| y \right>

Defining commands

The notation can get tedious in large amounts of $\TeX$, so it can be easier to define a \newcommand if writing a lot.

If you include

\newcommand{\bra}[1]{\left<#1\right|}\newcommand{\ket}[1]{\left|#1\right>}\newcommand{\bk}[2]{\left<#1\middle|#2\right>}\newcommand{\bke}[3]{\left<#1\middle|#2\middle|#3\right>}

at the start of your $\TeX$, then it defines the commands \bra{}, \ket{}, \bk{}{}, and \bke{}{}{}. Thereafter, you can use them easily:

  • \bra{x} renders as $\newcommand{\bra}[1]{\left< #1 \right|}\newcommand{\ket}[1]{\left| #1 \right>}\newcommand{\bk}[2]{\left< #1 \middle| #2 \right>}\bra{x}$.

  • \ket{x} renders as $\newcommand{\bra}[1]{\left< #1 \right|}\newcommand{\ket}[1]{\left| #1 \right>}\newcommand{\bk}[2]{\left< #1 \middle| #2 \right>}\ket{x}$.

  • \bk{x}{y} renders as $\newcommand{\bra}[1]{\left< #1 \right|}\newcommand{\ket}[1]{\left| #1 \right>}\newcommand{\bk}[2]{\left< #1 \middle| #2 \right>}\bk{x}{y}$.

  • \bke{x}{y}{z} renders as $\newcommand{\bke}[3]{\left<#1\middle|#2\middle|#3\right>}\bke{x}{y}{z}$

Un-code-golf'd, this code's:

\newcommand{\bra}[1]{\left< #1 \right|}
\newcommand{\ket}[1]{\left| #1 \right>}
\newcommand{\bk}[2]{\left< #1 \middle| #2 \right>}
\newcommand{\bke}[3]{\left< #1 \middle| #2 \middle| #3 \right>}

Alternatives to using <, |, >

  1. \langle can be used instead of < and renders as $\langle$.

  2. \rangle can be used instead of > and renders as $\rangle$.

  3. \vert can be used instead of | and renders as $\vert$.

    • Other variants include: \lvert, \rvert, and \mid.
  4. These alternatives can be easier since they don't require (but may employ) \left, \middle, \right qualifiers.

    • \langle x \vert: $\langle x \vert$

    • \left\langle x \right\vert: $\left\langle x \right\vert$

  5. However, the \left, \middle, \right qualifiers can make the rendering cleaner.

    • \langle v \vert \sum_{{\forall}i{\in}{\mathbb{N}}} \vert e_i \rangle looks weird:

$$\langle v \vert \sum_{{\forall}i{\in}{\mathbb{N}}} \vert e_i \rangle$$

  • \left\langle v \middle\vert \sum_{{\forall}i{\in}{\mathbb{N}}} \middle\vert e_i \right\rangle fixes it:

$$ \left\langle v \middle\vert \sum_{{\forall}i{\in}{\mathbb{N}}} \middle\vert e_i \right\rangle $$

  • \left< v \middle| \sum_{{\forall}i{\in}{\mathbb{N}}} \middle| e_i \right> is easier:

$$\left< v \middle| \sum_{{\forall}i{\in}{\mathbb{N}}} \middle| e_i \right>$$

$\endgroup$
5
$\begingroup$

Basics of typesetting in MathJax

Mathematics Stack Exchange has a MathJax basic tutorial and quick reference but they are free to alter or delete it without consulting us. Let's have our own, using their template. Constructive edits below this line most welcome.

This list is greatly improved over the linked-to list which has far less information than what is included here.


(Deutsch: MathJax: LaTeX Basic Tutorial und Referenz)

If you don't find exactly what you are looking for in this first section there are links near the bottom of this answer which enumerate every possible MathJax command. This answer can't include every symbol as it would bog down page loading times.

  1. To see how any formula was written in any question or answer, including this one, right-click on the expression it and choose "Show Math As > TeX Commands". (When you do this, the '$' will not display. Make sure you add these. See the next point.)

  2. For inline formulas, enclose the formula in $...$. For displayed formulas, use $$...$$.
    These render differently. For example, type
    $\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$
    to show $\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$ (which is inline mode) or type
    $$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$
    to show $$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$ (which is display mode).

  3. For Greek letters, use \alpha, \beta, …, \omega: $\alpha, \beta, … \omega$. For uppercase, use \Gamma, \Delta, …, \Omega: $\Gamma, \Delta, …, \Omega$.

  4. For superscripts and subscripts, use ^ and _. For example, x_i^2: $x_i^2$, \log_2 x: $\log_2 x$.

  5. 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 {}. If you do 10^10, you will get a surprise: $10^10$. But 10^{10} gives what you probably wanted: $10^{10}$. Use curly braces to delimit a formula to which a superscript or subscript applies: x^5^6 is an error; {x^y}^z is ${x^y}^z$, and x^{y^z} is $x^{y^z}$. Observe the difference between x_i^2 $x_i^2$ and x_{i^2} $x_{i^2}$.

  6. Parentheses Ordinary symbols ()[] make parentheses and brackets $(2+3)[4+4]$. Use \{ and \} for curly braces $\{\}$.

    These do not scale with the formula in between, so if you write (\frac{\sqrt x}{y^3}) the parentheses will be too small: $(\frac{\sqrt x}{y^3})$. Using \left(\right) will make the sizes adjust automatically to the formula they enclose: \left(\frac{\sqrt x}{y^3}\right) is $\left(\frac{\sqrt x}{y^3}\right)$.

    \left and\right apply to all the following sorts of parentheses: ( and ) $(x)$, [ and ] $[x]$, \{ and \} $\{ x \}$, | $|x|$, \vert $\vert x \vert$, \Vert $\Vert x \Vert$, \langle and \rangle $\langle x \rangle$, \lceil and \rceil $\lceil x \rceil$, and \lfloor and \rfloor $\lfloor x \rfloor$. \middle can be used to add additional dividers. There are also invisible parentheses, denoted by .: \left.\frac12\right\rbrace is $\left.\frac12\right\rbrace$.

    If manual size adjustments are required: \Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr) gives $\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)$.

  7. Sums and integrals \sum and \int; the subscript is the lower limit and the superscript is the upper limit, so for example \sum_1^n $\sum_1^n$. Don't forget {} if the limits are more than a single symbol. For example, \sum_{i=0}^\infty i^2 is $\sum_{i=0}^\infty i^2$. Similarly, \prod $\prod$, \int $\int$, \bigcup $\bigcup$, \bigcap $\bigcap$, \iint $\iint$, \iiint $\iiint$.

  8. Fractions There are two ways to make these. \frac ab applies to the next two groups, and produces $\frac ab$; for more complicated numerators and denominators use {}: \frac{a+1}{b+1} is $\frac{a+1}{b+1}$. If the numerator and denominator are complicated, you may prefer \over, which splits up the group that it is in: {a+1\over b+1} is ${a+1\over b+1}$.

  9. Fonts

    • Use \mathbb or \Bbb for "blackboard bold": $\mathbb{CHNQRZ}$.
    • Use \mathbf for boldface: $\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\mathbf{abcdefghijklmnopqrstuvwxyz}$.
    • Use \mathtt for "typewriter" font: $\mathtt{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\mathtt{abcdefghijklmnopqrstuvwxyz}$.
    • Use \mathrm for roman font: $\mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\mathrm{abcdefghijklmnopqrstuvwxyz}$.
    • Use \mathsf for sans-serif font: $\mathsf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$ $\mathsf{abcdefghijklmnopqrstuvwxyz}$.
    • Use \mathcal for "calligraphic" letters: $\mathcal{ ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
    • Use \mathscr for script letters: $\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$
    • Use \mathfrak for "Fraktur" (old German style) letters: $\mathfrak{ABCDEFGHIJKLMNOPQRSTUVWXYZ} \mathfrak{abcdefghijklmnopqrstuvwxyz}$.
  10. Radical signs Use sqrt, which adjusts to the size of its argument: \sqrt{x^3} $\sqrt{x^3}$; \sqrt[3]{\frac xy} $\sqrt[3]{\frac xy}$. For complicated expressions, consider using {...}^{1/2} instead.

  11. Some special functions such as "lim", "sin", "max", "ln", and so on are normally set in roman font instead of italic font. Use \lim, \sin, etc. to make these: \sin x $\sin x$, not sin x $sin x$. Use subscripts to attach a notation to \lim: \lim_{x\to 0} $$\lim_{x\to 0}$$

  12. There are a very large number of special symbols and notations, too many to list here; see this shorter listing, or this exhaustive listing. Some of the most common include:

    • \lt \gt \le \ge \neq $\lt\, \gt\, \le\, \ge\, \neq$. You can use \not to put a slash through almost anything: \not\lt $\not\lt$ but it often looks bad (also see two lines down).
    • \lessapprox\gtrapprox\lesssim\gtrsim
    • \lnapprox\gnapprox\lnsim\gnsim
    • \times \div \pm \mp $\times\, \div\, \pm\, \mp$. \cdot is a centered dot: $x\cdot y$
    • \cup \cap \setminus \subset \subseteq \subsetneq \supset \in \notin \emptyset \varnothing $\cup\, \cap\, \setminus\, \subset\, \subseteq \,\subsetneq \,\supset\, \in\, \notin\, \emptyset\, \varnothing$
    • {n+1 \choose 2k} or \binom{n+1}{2k} ${n+1 \choose 2k}$
    • \to \rightarrow \leftarrow \Rightarrow \Leftarrow \mapsto $\to\, \rightarrow\, \leftarrow\, \Rightarrow\, \Leftarrow\, \mapsto$
    • \land \lor \lnot \forall \exists \top \bot \vdash \vDash $\land\, \lor\, \lnot\, \forall\, \exists\, \top\, \bot\, \vdash\, \vDash$
    • \star \ast \oplus \circ \bullet $\star\, \ast\, \oplus\, \circ\, \bullet$
    • \approx \sim \simeq \cong \equiv \prec \lhd $\approx\, \sim \, \simeq\, \cong\, \equiv\, \prec, \lhd$.
    • \infty \aleph_0 $\infty\, \aleph_0$ \nabla \partial $\nabla\, \partial$ \Im \Re $\Im\, \Re$
    • For modular equivalence, use \pmod like this: a\equiv b\pmod n $a\equiv b\pmod n$.
    • \ldots is the dots in $a_1, a_2, \ldots ,a_n$ \cdots is the dots in $a_1+a_2+\cdots+a_n$
    • Some Greek letters have variant forms: \epsilon \varepsilon $\epsilon\, \varepsilon$, \phi \varphi $\phi\, \varphi$, and others. Script lowercase l is \ell $\ell$.

    Detexify lets you draw a symbol on a web page and then lists the $\TeX$ symbols that seem to resemble it. These are not guaranteed to work in MathJax but are a good place to start. To check that a command is supported, note that MathJax.org maintains a list of currently supported $\LaTeX$ commands, and one can also check Dr. Carol JVF Burns's page of $\TeX$ Commands Available in MathJax or the list on Michael Downes "Math Symbol and Math Fonts" website.

  13. Spaces MathJax usually decides for itself how to space formulas, using a complex set of rules. Putting extra literal spaces into formulas will not change the amount of space MathJax puts in: a␣b and a␣␣␣␣b are both $a b$. To add more space, use \, for a thin space $a\,b$; \; for a wider space $a\;b$. \quad and \qquad are large spaces: $a\quad b$, $a\qquad b$.

To reduce the space between a series of MathJax commands and a following word (doesn't work well with punctuation) use \! as many times as necessary.

To set plain text, use \text{…}: $\{x\in s\mid x\text{ is extra large}\}$. You can nest $…$ inside of \text{…}.

  1. Accents and diacritical marks Use \hat for a single symbol $\hat x$, \widehat for a larger formula $\widehat{xy}$. If you make it too wide, it will look silly. Similarly, there are \bar $\bar x$ and \overline $\overline{xyz}$, and \vec $\vec x$ and \overrightarrow $\overrightarrow{xy}$ and \overleftrightarrow $\overleftrightarrow{xy}$. For dots, as in $\frac d{dx}x\dot x = \dot x^2 + x\ddot x$, use \dot and \ddot.

Accents from "Math symbols and math fonts" by Michael Downes:

\acute{x} $\acute{x}$ \bar{x} $\bar{x}$ \vec{x} $\vec{x}$ \widetilde{xxx} $\widetilde{xxx}$ \grave{x} $\grave{x}$ \breve{x} $\breve{x}$

\dot{x} $\dot{x}$ \widehat{xxx} $\widehat{xxx}$ \ddot{x} $\ddot{x}$ \check{x} $\check{x}$ \ddot{x} $\ddot{x}$ \tilde{x} $\tilde{x}$

\hat{x} $\hat{x}$ \dddot{x} $\dddot{x}$

  1. Special characters used for MathJax interpreting can be escaped using the \ character: \$ $\$$, \{ $\{$, \_ $\_$, etc. If you want \ itself, you should use \backslash $\backslash$, because \\ is for a new line.

Additional examples from math.stackexchange.com showing how to draw commutative diagrams using \array or \newcommand:

Example 1:

$$ 
\newcommand{\ra}[1]{\!\!\!\!\!\!\!\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!\!\!\!} 
\newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} 
% 
\begin{array}{llllllllllll} 0 & \ra{f_1} & A & \ra{f_2} & B & \ra{f_3} & C & \ra{f_4} & D & \ra{f_5} & 0 \\ 
\da{g_1} & & \da{g_2} & & \da{g_3} & & \da{g_4} & & \da{g_5} & & \da{g_6} \\ 
0 & \ra{h_1} & 0 & \ra{h_2} & E & \ra{h_3} & F & \ra{h_4} & 0 & \ra{h_5} & 0 \\ 
\end{array} 
$$

$$ \newcommand{\ra}[1]{\!\!\!\!\!\!\!\!\!\!\!\!\xrightarrow{\quad#1\quad}\!\!\!\!\!\!\!\!} \newcommand{\da}[1]{\left\downarrow{\scriptstyle#1}\vphantom{\displaystyle\int_0^1}\right.} % \begin{array}{llllllllllll} 0 & \ra{f_1} & A & \ra{f_2} & B & \ra{f_3} & C & \ra{f_4} & D & \ra{f_5} & 0 \\ \da{g_1} & & \da{g_2} & & \da{g_3} & & \da{g_4} & & \da{g_5} & & \da{g_6} \\ 0 & \ra{h_1} & 0 & \ra{h_2} & E & \ra{h_3} & F & \ra{h_4} & 0 & \ra{h_5} & 0 \\ \end{array} $$

Example 2:

$$
\begin{array}{ccccccccc}
0 & \xrightarrow{i} & A & \xrightarrow{f} & B & \xrightarrow{q} & C & \xrightarrow{d} & 0 \\
\downarrow & \searrow & \downarrow & \nearrow & \downarrow & \searrow & \downarrow & \nearrow & \downarrow \\
0 & \xrightarrow{j} & D & \xrightarrow{g} & E & \xrightarrow{r} & F & \xrightarrow{e} & 0
\end{array}
$$

$$ \begin{array}{ccccccccc} 0 & \xrightarrow{i} & A & \xrightarrow{f} & B & \xrightarrow{q} & C & \xrightarrow{d} & 0 \\ \downarrow & \searrow & \downarrow & \nearrow & \downarrow & \searrow & \downarrow & \nearrow & \downarrow \\ 0 & \xrightarrow{j} & D & \xrightarrow{g} & E & \xrightarrow{r} & F & \xrightarrow{e} & 0 \end{array} $$


The word on Tables: Is there Markdown to create tables? - ASCII only, real Tables were denied.

Our whitelisted subset of HTML: What HTML tags are allowed on Stack Exchange sites?

The enormous list of $\TeX$ commands allowed in MathJax.

Michael Downes of the American Mathematical Society has a useful MathJax website.

Another plethora of tips are offered on the LaTeX - Mathematics: Fractions and Binomials Wiki.

Hacking the quod erat demonstrandum symbol is discussed here: "\qed for MathJax here on stackexchange" - Spoiler: $$\tag*{$\blacksquare$}$$

$$\tag*{$\blacksquare$}$$


Note: It is important that this post be reasonably short and not suffer from too much bloat. To include more topics, please create short addenda and post them as answers instead of inserting them into this post.

$\endgroup$
  • $\begingroup$ Comments are not for extended discussion; this conversation has been moved to chat. $\endgroup$ – Sanchayan Dutta Dec 31 '18 at 20:57
5
$\begingroup$

QCircuit / XYJax / Xy-Pic:

Qcircuit is a set of macros to generate quantum ciruits, it uses a couple of accessory extensions and works with MathJax.

Here's an example (written using Tex, over at Wikipedia):

\begin{document}
\begin{align*}
 \Qcircuit @C=1em @R=.7em {
  \lstick{\ket{\psi}_C}   & \ctrl{1} & \gate{H} & \meter                  & \control \cw \\
  \lstick{\ket{\Phi}^+_A} & \targ    & \meter   & \control \cw \cwx[1] \\
  \lstick{\ket{\Phi}^+_B} & \qw	     & \qw      & \targ                   & \control \cwx[-2] \qw & \rstick{\ket{\psi}_B} \qw
 }
\end{align*}
\end{document}

Such code, written in a MathJax compatible format, would create this image (which would be editable):

Quantum Teleportation

Apparently the Stacks website has QCircuit, and there's mention of it over at Tex.SE; but it doesn't seem to be working (enabled) here. If someone could figure out how to trigger it on a webpage (with a 'require' command) that would be awesome. Please comment or edit this answer with a tested answer.

Q-circuit Tutorial at arXiv.

$\endgroup$
3
$\begingroup$

Typesetting chemistry in MathJax

Source: Quantum Computing SE meta: Formatting chemical formulae and reactions

The LaTeX package mhchem is not activated here, by default. However, you can load it yourself, by using the command \require{\mhchem} (you need to use it only once on a page).

Example: \require{\mhchem}\ce{H2O} generates $\require{\mhchem}\ce{H2O}$.

Courtesy: @DavidCervone on Physics SE


Chemistry Stack Exchange has a community wiki by @ManishEarth titled How can I format math/chemistry expressions here? which documents the MathJax commands for chemistry. Since they are free to alter/delete their copy without consulting us, let's have our own, using their template. Constructive edits below this line most welcome.

Getting started

On chemistry.SE, we use MathJax to format mathematical as well as chemical equations and similar expressions in questions, answers, and comments. MathJax allows us to typeset expressions using $\LaTeX$ notation.

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

Let $x$ be a variable.

On the other hand, double dollar signs make the math 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, in math mode, MathJax ignores the spaces you type, e.g. $a b$ yields $a b$. MathJax formats expressions the way it is common in mathematics texts. However, the printing rules for signs and symbols used in the natural sciences and technology may require additional spaces (in particular, between the numerical value and the unit symbol). In math mode, use \ (backslash space) or ~ (tilde) if you want the equivalent of space in normal text. Where separation of numbers into groups of three digits is used, the groups shall be separated by a thin space \, (backslash comma); e.g. $299\,792\,458$ yields $299\,792\,458$.

Basic chem

We use the mhchem package for chemistry. It lets us easily format chemical formulas and reactions without typing too much.

There really is only one command you need to know here: \ce{...}. \ce{...} takes its parameters and automatically formats it. For example,

$\ce{HCl}$ dissociates in water as follows:
$$\ce{H2O + HCl <=> H3O+ + Cl-}$$

Renders as

$\ce{HCl}$ dissociates in water as follows: $$\ce{H2O + HCl <=> H3O+ + Cl-}$$

Note that spaces are very important for mhchem to separate super/subscripts from normal text. \ce{H3O+} will display $\ce{H3O+}$, but \ce{H2O +} will display $\ce{H2O +}$. When typesetting ions with more than a single charge, the argument has to be raised using the caret (^; also known as the circumflex accent) character, e.g. $\ce{Cu^2+}$ renders as $\ce{Cu^2+}$, while $\ce{Cu2+}$ would incorrectly render to $\ce{Cu2+}$. (Also see basic math below.)

Various types of reaction arrows are supported, including ->, <=>, <==>>, etc.

It also supports various types of bonds, via the \bond{..} command (to be called inside \ce{...}). You need not call \bond for normal bonds.

Eg: \ce{H\bond{->}A-B=C#D\bond{~}E\bond{~-}F\bond{...}G\bond{<-}E} displays:

$$\ce{H\bond{->}A-B=C#D\bond{~}E\bond{~-}F\bond{...}G\bond{<-}E}$$

Full documentation of mhchem here

Basic math

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

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

However, where it is necessary to include fractions in the body text, they shall, where possible, be reduced to a single level by using a solidus (/) or, where applicable, the negative index. For example, instead of $\frac{1}{\sqrt 2}$ write $1/\sqrt 2$ or $2^{-1/2}$; instead of $C_{\mathrm m,p} = 33.58\ \mathrm{\frac{J}{K \cdot mol}}$ write $C_{\mathrm m,p} = 33.58\ \mathrm{J/(K \cdot mol)}$ or $C_{\mathrm m,p} = 33.58\ \mathrm{J\cdot K^{-1} \cdot mol^{-1}}$.

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

Greek letters

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

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

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}.

Note that there are special commands \varepsilon , \varsigma , \varrho , and \varpi to distinguish between the lunate Greek letters.

MathJax extensions

MathJax has available a variety of extensions enabling other features: strikeout lines, enclosures, text/background coloration, interactive equations, etc. Information about these extensions and how to enable them can be found at this meta post.

Further reading

If you would like to know more, you can continue reading about which symbols are written in italic (sloping) type and which are printed in roman (upright) type.


Note: As of April 30 2017 the CDN hosting at cdn.mathjax.org was shut down, as a result directories such as https://github.com/mathjax/MathJax-third-party-extensions/tree/master/mhchem (like the one appearing in the original of the text below) will 404. According to Issue #39 "[IMPORTANT] MathJax CDN end-of-life & suggested changes to third-party extensions #39" all 3rd party extensions will be hosted in separate repositories (one per extensions). See link to Issue #39 for a partial list of the new locations.

MathJax/mhchem Extension 3.3 was moved to: https://github.com/mhchem/MathJax-mhchem. The full Mathjax/mhchem is now located at: https://mhchem.github.io/MathJax-mhchem/.

$\endgroup$
-3
$\begingroup$

Please be careful when using TeX/MathJax in titles!

This is more on how not to use MathJax, but still good to keep in mind.

A good overview of why not to use do this is given here, but let me briefly summarize:

  1. Titles are visible in places that do not render TeX!
  2. If you must describe your title with TeX, you probably aren't summarizing your question enough. Try to make a natural language title, that is usually possible and summarizes your question better.
  3. If you insist, then by all means, use TeX in the title. But there's always room for improvement. IMO, TeX in title is never necessary and a sign that the title can be improved!
$\endgroup$
  • $\begingroup$ Comments are not for extended discussion; this conversation has been moved to chat. $\endgroup$ – Sanchayan Dutta Dec 31 '18 at 20:56

You must log in to answer this question.

protected by Sanchayan Dutta Dec 13 '18 at 19:19

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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