<!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"><linkhref=https://adityatelange.github.io/hugo-PaperMod/css/stylesheet.min.ccf6286c213b38ef035641642f10216cc3382d1e756f7e58a0f96a6fab3784a2.cssintegrity="sha256-zPYobCE7OO8DVkFkLxAhbMM4LR51b35YoPlqb6s3hKI="rel="preload stylesheet"as=style><linkhref=https://adityatelange.github.io/hugo-PaperMod/custom.cssrel=stylesheet><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.74.3"></head><bodyclass=single><headerclass=header><navclass=nav><pclass=logo><ahref=https://adityatelange.github.io/hugo-PaperMod/>PaperMod</a></p><ulclass=menu><li><ahref=/hugo-PaperMod/archives/>Archives</a></li><li><ahref=/hugo-PaperMod/tags/>Tags</a></li><li><ahref=/hugo-PaperMod/series/>Series</a></li><li><ahref=/hugo-PaperMod/categories/>Categories</a></li></ul></nav></header><mainclass=mainid=top><articleclass=post-single><headerclass=post-header><h1class=post-title>Math Typesetting</h1><divclass=post-meta>Hugo Authors · March 8, 2019</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: