05 Oct 2020 - fubar - Sreekar Guddeti
A quick hack to render LaTeX equations in HTML pages using MathJaX
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Test Site</title>
<!-- Add MathJax rendering for LaTeX style rendering -->
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.5.3/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<!-- MathJax rendering configuration ends here -->
</head>
<body>
test body
</body>
</html>
To typset a block line equation, like
\[\exp^{i \pi} = -1,\]use
$$ \exp^{i \pi} = -1, $$
Even delimiters \\[ \\]
can also be used instead of $$ $$
.
To typeset inline equation,
The function \( f(x) \) returns the value 0 if even.
use
The function \\( f(x) \\) returns the value 0 if even.
The MathJaX Javascript can be added to a Jekyll powered site by [using Jekyll’s Liquid tags](https://xkdog.github.io/2017-02-06-mathjax/.
mathjax.html
file containing the line <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=default"></script>
and include it in the _html
folder at the root of the Jekyll site source.
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
}
};
</script>
<script id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
</script>
In this way, mathjax can be enabled on a per post basis
RawNBConvert
with a new line above and below.
<script>
MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
}
};
</script>
<script id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js">
</script>
The second option has been implemented in the my notebooks on Spintronics review.
For more information on how to use MathJax, and its latest features, refer to the canonical documentation on MathJax