KaTeX

How to add KaTeX to your Doks website.

On this page

💡

Equation Editor by CodeCogs is an online LaTeX equation editor, where you can create, integrate, and download equations.

1. Enable

KaTeX support is switched off per default. Activate it by setting kaTex = true in ./config/_default/params.toml.

2. Copy fonts

Copy KaTeX fonts from ./node_modules/katex/dist/fonts/ to ./static/fonts/:

  1. npm run copy:katex-fonts

3. Configure

Customize Doks’ default configuration (if needed) in ./assets/js/katex.js:

  1. document.addEventListener('DOMContentLoaded', function() {
  2. renderMathInElement(document.body, {
  3. delimiters: [
  4. {left: '$$', right: '$$', display: true},
  5. {left: '$', right: '$', display: false},
  6. {left: '\\(', right: '\\)', display: false},
  7. {left: '\\[', right: '\\]', display: true},
  8. ],
  9. });
  10. });

Example

Excerpt taken from Supernova Neutrinos by Lei Ma.

Markdown

  1. The average energy of the neutrinos $\langle E \rangle$ emitted during a supernova explosion is of the order of 10MeV, and the neutrino luminosity at the early epoch of the explosion is approximately $10^{52}\mathrm{ergs\cdot s^{-1}}$.
  2. Therefore, the number density of the neutrinos at the radius $R$ is
  3. $$
  4. \begin{equation*}
  5. n \sim 10^{18} \mathrm{cm^{-3}} \left(\frac{100\mathrm{km}}{R}\right)^2 \left(\frac{10\mathrm{MeV}}{\langle E \rangle}\right).
  6. \end{equation*}
  7. $$

HTML

KaTeX Example

Note, this is an image, because KaTeX support is switched off on this site.

Resources