Skip to content

Latest commit

 

History

History
59 lines (33 loc) · 2.52 KB

math.md

File metadata and controls

59 lines (33 loc) · 2.52 KB

Add mathjax script right into the markdown file like so:

<!-- Equations using MathJax -->
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "all"} } });       </script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "all"} } }); </script>

Add knitr block into the markdown file.

1 + 1
## [1] 2

Display equations by delimiting with <div>$$

$$ J_\alpha(x) = \sum\limits_{m=0}^\infty \frac{(-1)^m}{m! \, \Gamma(m + \alpha + 1)}{\left({\frac{x}{2}}\right)}^{2 m + \alpha} $$

And inline equations with <span>$, like $e = mc^2$

Now the following works:

  • Pandoc generated latex: pandoc -s math.md -o math.tex.
  • The Markdown file will be converted to valid html by almost any markdown converter, which ignores the div/span elements. The mathjax script added in the top will cause these to display correctly. (Note this works for the inline equation too, even though mathjax says it shouldn't?)
  • To get pandoc to run in this mode without touching the math syntax, use --strict option: pandoc -s --strict math.md -o math.html
  • Pandoc can handle the mathjax rendering itself, since without strict enabled, it reads inside the div/span elements and finds math syntax it recognizes. as does pandoc -s --mathjax math.md -o math3.html. Likewise for mathml: pandoc -s --mathml -o math4.html.
  • Simple html works too, though has no rendering engine: pandoc -s math.md -o math2.html so the result is not displayed properly.

See results