by Anand S
~1 min read

MathJax is a simple, yet powerful, way of including Tex/LaTex/MathML based mathematics in HTML webpages.

Usage

To enable MathJax support configure your _config.xml to:

  • Set kramdown as the Markdown parser.
  • Add MathJax to your post.

Add the following code to the bottom of your post markdown file.

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

Use $$ as delimiters to enable TeX math mode, both for inline and display (i.e. block) rendering.

Here is an example equation that is inline: \(a^2 + b^2 = c^2\), where \(a\), \(b\), and \(c\) are variables.

Here is a block rendering with no default equation numbering:

\[\frac{1}{n^{2}}\]

And, below is a block using the \begin{equation} and \end{equation} LaTeX delimiters. This equation will be numbered in the ams and all setting for mathjax.tags.

\[\begin{equation} \mathbf{X}_{n,p} = \mathbf{A}_{n,k} \mathbf{B}_{k,p} \label{test} \end{equation}\]

If equation numbering is turned on, we should see an equation number here: \(\eqref{test}\).

An example using the {align} LaTeX environment is below. The first equation has a \notag directive.

\[\begin{align} (x + y) (x - y) &= x^2 + xy - xy + y^2 \notag \\ &= x^2 - y^2 \end{align}\]

Comments powered by Talkyard.