Setting up TeX math rendering for your blog or website
Setting up \(\TeX\)math typesetting on your website is one of those tasks that can seem really difficult if you don’t know what to look for. Here’s a simple way to do it.
I used Khan Academy’s KaTeX typesetting library for my blog. KaTeX is fast, self-contained, and works largely as you would expect. Here are the instructions:
-
Include KaTeX on your site by adding the required reference tags and scripts to your html template1. See this commit for the changes I made to get it working on this blog.
-
Typeset math by enclosing your notation within
\\(
and\\)
for inline typesetting, or\\[
and\\]
for typesetting on a separate line.For example, with inline typesetting,
\\(\alpha\\)
, becomes \(\alpha\). With non-inline typesetting,\\[x^2 + y^2 + z^2 = r^2\\]
becomes: \[x^2 + y^2 + z^2 = r^2\] -
If you have any rendering issues, check your console for error messages. Also take a look at the full documentation on Github.
Footnotes
-
You can also download these files and host them on your server directly instead of getting them from the cdn. ↩