<!doctype html><htmllang=en><head><metacharset=utf-8><metahttp-equiv=x-ua-compatiblecontent="IE=edge"><metaname=viewportcontent="width=device-width,initial-scale=1,shrink-to-fit=no"><title>Math Typesetting - PaperMod</title><metaname=descriptioncontent="Mathematical notation in a Hugo project can be enabled by using third party JavaScript libraries."><metaname=authorcontent="Hugo Authors"><linkrel=canonicalhref=https://adityatelange.github.io/hugo-PaperMod/posts/math-typesetting/><linkhref=https://adityatelange.github.io/hugo-PaperMod/css/stylesheet.min.2c6d841b2e1281d63c99e42f35a3da2ab1ddb7995647ea9484ab121f02f8702f.cssintegrity="sha256-LG2EGy4SgdY8meQvNaPaKrHdt5lWR+qUhKsSHwL4cC8="rel="preload stylesheet"as=style><linkrel=apple-touch-iconhref=https://adityatelange.github.io/hugo-PaperMod/apple-touch-icon.png><linkrel=iconhref=https://adityatelange.github.io/hugo-PaperMod/favicon.ico><metaname=generatorcontent="Hugo 0.75.1"></head><bodyclass=singleid=top><script>if(window.matchMedia('(prefers-color-scheme: dark)').matches){document.body.classList.add('dark');}</script><headerclass=header><navclass=nav><pclass=logo><ahref=https://adityatelange.github.io/hugo-PaperMod/>PaperMod</a></p><ulclass=menuid=menuonscroll=menu_on_scroll()><li><ahref=https://adityatelange.github.io/hugo-PaperMod/archives/><span>Archives</span></a></li><li><ahref=https://adityatelange.github.io/hugo-PaperMod/tags/><span>Tags</span></a></li><li><ahref=https://adityatelange.github.io/hugo-PaperMod/series/><span>Series</span></a></li></ul></nav></header><mainclass=main><articleclass=post-single><headerclass=post-header><h1class=post-title>Math Typesetting</h1><divclass=post-meta><time>March 8, 2019</time> · 1 min · Hugo Authors</div></header><divclass=post-content><p>Mathematical notation in a Hugo project can be enabled by using third party JavaScript libraries.</p><p>In this example we will be using <ahref=https://katex.org/>KaTeX</a></p><ul><li>Create a partial under <code>/layouts/partials/math.html</code></li><li>Within this partial reference the <ahref=https://katex.org/docs/autorender.html>Auto-render Extension</a> or host these scripts locally.</li><li>Include the partial in your templates like so:</li></ul><divclass=highlight><prestyle=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-bashdata-lang=bash><spanstyle=color:#f92672>{{</span><spanstyle=color:#66d9ef>if</span> or .Params.math .Site.Params.math <spanstyle=color:#f92672>}}</span>
<spanstyle=color:#f92672>{{</span> end <spanstyle=color:#f92672>}}</span>
</code></pre></div><ul><li>To enable KaTex globally set the parameter <code>math</code> to <code>true</code> in a project’s configuration</li><li>To enable KaTex on a per page basis include the parameter <code>math: true</code> in content files</li></ul><p><strong>Note:</strong> Use the online reference of <ahref=https://katex.org/docs/supported.html>Supported TeX Functions</a></p><linkrel=stylesheethref=https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.cssintegrity=sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjqcrossorigin=anonymous><scriptdefersrc=https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.jsintegrity=sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJzcrossorigin=anonymous></script><scriptdefersrc=https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.jsintegrity=sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkIcrossorigin=anonymousonload=renderMathInElement(document.body);></script><h3id=examples>Examples</h3><p>Inline math: \(\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…\)</p><p>Block math:
<span>Theme️<ahref=https://git.io/hugopapermodrel=noopenertarget=_blank>PaperMod</a></span></footer><ahref=#toparia-label="go to top"title="Go to Top"><buttonclass=top-linkid=top-linktype=button><svgxmlns="http://www.w3.org/2000/svg"viewBox="0 0 12 6"><pathd="M12 6H0l6-6z"/></svg></button></a>