--- title: Dollar Math based_on: https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/math.md --- # TeX Math Inline math goes between `$` characters, and display math goes between `$$`: ```````````````````````````````` example Let $x$ and $y$ be integers such that $$x=y + 2$$ .

Let x and y be integers such that x=y + 2

```````````````````````````````` In inline math, the opening `$` must not be followed by a whitespace, and the closing `$` must not be preceded by whitespace. ```````````````````````````````` example This is not math: 2000$. And neither is this $ 4 $. Or this $4 $. .

This is not math: 2000$. And neither is this $ 4 $. Or this $4 $.

```````````````````````````````` Display math delimiters can be surrounded by whitespace: ```````````````````````````````` example This is display math: $$ e=mc^2 $$ .

This is display math: e=mc^2

```````````````````````````````` Note that math can contain embedded math. In scanning for a closing delimiter, we skip material in balanced curly braces: ```````````````````````````````` example disabled This is display math: $$ \text{Hello $x^2$} $$ And this is inline math: $\text{Hello $x$ there!}$ .

This is display math: \[ \text{Hello $x^2$} \] And this is inline math: \(\text{Hello $x$ there!}\)

```````````````````````````````` To avoid treating currency signs as math delimiters, one may occasionally have to backslash-escape them: ```````````````````````````````` example The cost is between \$10 and 30$. .

The cost is between $10 and 30$.

```````````````````````````````` Dollar signs must also be backslash-escaped if they occur within math: ```````````````````````````````` example $\text{\$}$ .

\text{\$}

```````````````````````````````` Everything inside the math construction is treated as math, and not given its normal commonmark meaning. ```````````````````````````````` example $bc$ .

b<a>c

```````````````````````````````` Block math can directly follow a paragraph. ```````````````````````````````` example This is inline display math $$1+2$$ This is block math $$ 1+2 $$ .

This is inline display math 1+2

This is block math 1+2

````````````````````````````````