I'm sporadically active on the Astronomy Picture of the Day (APOD) forums, where discussion occasionally spirals into the astrophysical realm and waxes technical. That's where I first encountered the need to typeset equations online. I resorted to a quick and dirty solution:
- Decide whether laziness trumps steps 2-4.
- Use a LaTeX-to-image converter such as LaTeXiT to generate equation images.
- Upload images to university webspace.
- Embed images inline with text.
A cursory web search identified MathJax as the most magic-like way to type posts in LaTeX and see equations across all major browsers. I'd heard of MathML before, but since I'm so used to LaTeX already, MathJax looked way too easy to pass up, and it is. All the end user needs to do is to include the MathJax JavaScript library in their HTML via the following snippet [per official instructions]:
<script type="text/javascript"
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
(That's the secure snippet, which imports the script over HTTPS. An HTTP variant is provided through the above official instructions link for those who'd rather flirt with men in the middle.)
After embedding the above script in your HTML, everything should be hunky dory. Hack up some LaTeX in your HTML view; the default math delimiters for inline and paragraph equations are $$...$$ and \[...\]. So, this string:
gives you this:
\[ \nabla \times \mathbf E = - \frac{\partial \mathbf B}{\partial t} \]
Huge thanks go out to the MathJax team, and to you, dear reader, for reading all the way to the end of this healthcare.gov of a post. Until next time!
tl;dr: including a MathJax script in your web page lets you type LaTeX directly in HTML.
<script type="text/javascript"
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
(That's the secure snippet, which imports the script over HTTPS. An HTTP variant is provided through the above official instructions link for those who'd rather flirt with men in the middle.)
After embedding the above script in your HTML, everything should be hunky dory. Hack up some LaTeX in your HTML view; the default math delimiters for inline and paragraph equations are $$...$$ and \[...\]. So, this string:
\[ \nabla \times \mathbf E = - \frac{\partial \mathbf B}{\partial t} \]
gives you this:
\[ \nabla \times \mathbf E = - \frac{\partial \mathbf B}{\partial t} \]
Huge thanks go out to the MathJax team, and to you, dear reader, for reading all the way to the end of this healthcare.gov of a post. Until next time!
tl;dr: including a MathJax script in your web page lets you type LaTeX directly in HTML.
No comments:
Post a Comment