Ordinary HTML does not have any facility for displaying mathematics, so neither does standard Markdown. However, it is relatively easy to include well-formated mathematics in your HTML document by including a javascript math interpreter called MathJax in your document.
This requires you to do two things:
Include the following text somewhere in your Markdown document. MathJax recommends to placing it in the HTML header, but it can also appear in the body of the document.
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-MML-AM_CHTML">
</script>
For comprehensive documentation see the MathJax website - there are many configuration options.
There are three main styles for coding mathematics for HTML display:
TeX/LaTeX
$Y=XB + e$
or \\(Y=XB+e\\)
becomes \(Y=XB+e\)
while
\\[ f(x|\mu,\sigma^2) = \frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{(x-\mu)^2}{2\sigma^2}} \\]
becomes \[ f(x|\mu,\sigma^2) = \frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{(x-\mu)^2}{2\sigma^2}} \]
MathML
<math><mi>Y</mi><mo>=</mo><mi>X</mi><mi>B</mi><mo>+</mo><mi>e</mi></math>
becomes
while
<math>
<mtable displaystyle="true">
<mtr>
<mtd>
<mspace width="6.0em" />
</mtd>
<mtd columnalign="left">
<mi>f</mi>
<mrow>
<mo form="prefix">(</mo>
<mi>x</mi>
<mo>|</mo>
<mi>mu</mi>
<mo>,</mo>
<msup>
<mi>sigma</mi>
<mn>2</mn>
</msup>
<mo form="postfix">)</mo>
</mrow>
<mo>=</mo>
<mfrac linethickness="1">
<mn>1</mn>
<mrow>
<msqrt>
<mrow>
<mn>2</mn>
<mi>π</mi>
<msup>
<mi>σ</mi>
<mn>2</mn>
</msup>
</mrow>
</msqrt>
</mrow>
</mfrac>
<msup>
<mi>e</mi>
<mrow>
<mo>-</mo>
<mfrac linethickness="1">
<mrow>
<msup>
<mrow>
<mo form="prefix">(</mo>
<mi>x</mi>
<mo>-</mo>
<mi>μ</mi>
<mo form="postfix">)</mo>
</mrow>
<mn>2</mn>
</msup>
</mrow>
<mrow>
<mn>2</mn>
<msup>
<mi>σ</mi>
<mn>2</mn>
</msup>
</mrow>
</mfrac>
</mrow>
</msup>
</mtd>
</mtr>
</mtable>
</math>
becomes
AsciiMath
\` Y=XB+e \`
yields `Y=XB+e`
while
` f(x|mu,sigma^2)= 1/sqrt(2 pi sigma^2) e^(-(x-mu)^2/2sigma^2) `
becomes
` f(x|mu,sigma^2)= 1/sqrt(2 pi sigma^2) e^(-(x-mu)^2/2sigma^2) `
For Markdown documents, you will probably use TeX-style code. It is widely use and understood, although not always the easiest to read.
MathML is very tedious for a human to read or write.
And AsciiMath, while appealingly simple, uses backticks as math delimiters by default. Ordinarily these are used to format inline code in a Markdown document - distinguishing code from math is therefore harder. Another drawback to AsciiMath is that it does not encode as wide a variety of math typography as TeX.
There are two variations on writing math in TeX, the default style, and another more common style.
The default delimiters for TeX-style mathematics are a combination backslash-parentheses, backslash-square brackets, or double-dollar signs.
\(
and backslash-close paren, \)
\[
and backslash-close bracket, \]
The other common style, which requires some additional set up in your document, uses dollars signs, $
and $$
as math delimiters.
$
$$
and double-dollar sign, $$
See an example of each:
For a more extended MathML example, see
For a more extended AsciiMath example, see