<spanclass=logo-switches><buttonid=theme-toggleaccesskey=ttitle="(Alt + T)"><svgid="moon"xmlns="http://www.w3.org/2000/svg"width="24"height="24"viewBox="0 0 24 24"fill="none"stroke="currentcolor"stroke-width="2"stroke-linecap="round"stroke-linejoin="round"><pathd="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg><svgid="sun"xmlns="http://www.w3.org/2000/svg"width="24"height="24"viewBox="0 0 24 24"fill="none"stroke="currentcolor"stroke-width="2"stroke-linecap="round"stroke-linejoin="round"><circlecx="12"cy="12"r="5"/><linex1="12"y1="1"x2="12"y2="3"/><linex1="12"y1="21"x2="12"y2="23"/><linex1="4.22"y1="4.22"x2="5.64"y2="5.64"/><linex1="18.36"y1="18.36"x2="19.78"y2="19.78"/><linex1="1"y1="12"x2="3"y2="12"/><linex1="21"y1="12"x2="23"y2="12"/><linex1="4.22"y1="19.78"x2="5.64"y2="18.36"/><linex1="18.36"y1="5.64"x2="19.78"y2="4.22"/></svg></button><ulclass=lang-switch><li>|</li><li><ahref=https://adityatelange.github.io/hugo-PaperMod/fr/title=🇫🇷aria-label=:fr:>🇫🇷</a></li><li><ahref=https://adityatelange.github.io/hugo-PaperMod/fa/title=Faaria-label=Fa>Fa</a></li></ul></span></div><ulid=menu><li><ahref=https://adityatelange.github.io/hugo-PaperMod/archivestitle=Archive><span>Archive</span></a></li><li><ahref=https://adityatelange.github.io/hugo-PaperMod/categories/title=Categories><span>Categories</span></a></li><li><ahref=https://adityatelange.github.io/hugo-PaperMod/search/title="Search (Alt + /)"accesskey=/><span>Search</span></a></li><li><ahref=https://adityatelange.github.io/hugo-PaperMod/tags/title=Tags><span>Tags</span></a></li></ul></nav></header><mainclass=main><articleclass=post-single><headerclass=post-header><h1class=post-title>Math Typesetting</h1><divclass=post-description>A brief guide to setup KaTeX</div><divclass=post-meta>March 8, 2019 · 1 min · Hugo Authors</div></header><divclass=toc><details><summaryaccesskey=ctitle="(Alt + C)"><divclass=details>Table of Contents</div></summary><divclass=inner><ul><li><ahref=#examplesaria-label=Examples>Examples</a></li></ul></div></details></div><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 (<ahref=../papermod/papermod-faq/#custom-head--footer><code>extend_head.html</code></a>) like so:</li><li>refer <ahref=https://github.com/adityatelange/hugo-PaperMod/issues/236>ISSUE #236</a></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>
</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<ahiddenclass=anchoraria-hidden=truehref=#examples>#</a></h3><p>Inline math: \(\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…\)</p><p>Block math:</p><p>$$
<span>Theme <ahref=https://git.io/hugopapermodrel=noopenertarget=_blank>PaperMod</a></span></footer><ahref=#toparia-label="go to top"title="Go to Top (Alt + G)"><buttonclass=top-linkid=top-linktype=buttonaccesskey=g><svgxmlns="http://www.w3.org/2000/svg"viewBox="0 0 12 6"fill="currentcolor"><pathd="M12 6H0l6-6z"/></svg></button></a>