12 lines
4.4 KiB
HTML

<!doctype html><html lang=en-US><head><meta http-equiv=X-Clacks-Overhead content="GNU Terry Pratchett"><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><link rel="shortcut icon" href=https://clente.github.io/hugo-bearcub/images/favicon.png><title>Math Typesetting | Bear Cub</title>
<meta name=title content="Math Typesetting"><meta name=description content="A brief guide to setup KaTeX"><meta name=keywords content><meta property="og:title" content="Math Typesetting"><meta property="og:description" content="A brief guide to setup KaTeX"><meta property="og:type" content="article"><meta property="og:url" content="https://clente.github.io/hugo-bearcub/blog/math-typesetting/"><meta property="og:image" content="https://clente.github.io/hugo-bearcub/images/social_card_bg_hu0f7c7fe460ec4b5e9751ccb8d9c9aa0f_651110_f04b02fb568efe4613d2ccb871cc6a41.webp"><meta property="article:section" content="blog"><meta property="article:published_time" content="2019-03-08T00:00:00+00:00"><meta property="article:modified_time" content="2019-03-08T00:00:00+00:00"><meta property="og:site_name" content="Bear Cub"><meta property="fb:admins" content="0000000000"><meta name=twitter:card content="summary_large_image"><meta name=twitter:image content="https://clente.github.io/hugo-bearcub/images/social_card_bg_hu0f7c7fe460ec4b5e9751ccb8d9c9aa0f_651110_f04b02fb568efe4613d2ccb871cc6a41.webp"><meta name=twitter:title content="Math Typesetting"><meta name=twitter:description content="A brief guide to setup KaTeX"><meta name=twitter:site content="@example"><meta itemprop=name content="Math Typesetting"><meta itemprop=description content="A brief guide to setup KaTeX"><meta itemprop=datePublished content="2019-03-08T00:00:00+00:00"><meta itemprop=dateModified content="2019-03-08T00:00:00+00:00"><meta itemprop=wordCount content="114"><meta itemprop=image content="https://clente.github.io/hugo-bearcub/images/social_card_bg_hu0f7c7fe460ec4b5e9751ccb8d9c9aa0f_651110_f04b02fb568efe4613d2ccb871cc6a41.webp"><meta itemprop=keywords content><meta name=referrer content="no-referrer-when-downgrade"><link href=/hugo-bearcub/style.min.css rel=stylesheet><link href=/hugo-bearcub/syntax.min.css rel=stylesheet></head><body><header><a class=skip-link href=#main-content>Skip to main content</a>
<a href=/hugo-bearcub class=title><h1>Bear Cub</h1></a><nav><a href=/hugo-bearcub/>Home</a>
<a href=/hugo-bearcub/blog/>Blog</a>
<a href=https://clente.github.io/hugo-bearcub/index.xml>RSS</a>
<a class=disabled role=link aria-disabled=true>pt-BR 🇧🇷</a></nav></header><main id=main-content><h1>Math Typesetting</h1><p class=byline><time datetime=2019-03-08 pubdate>2019-03-08
</time>· Hugo Authors</p><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 <a href=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 <a href=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><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=ln>1</span><span class=cl><span class=o>{{</span> <span class=k>if</span> or .Params.math .Site.Params.math <span class=o>}}</span>
</span></span><span class=line><span class=ln>2</span><span class=cl><span class=o>{{</span> partial <span class=s2>&#34;math.html&#34;</span> . <span class=o>}}</span>
</span></span><span class=line><span class=ln>3</span><span class=cl><span class=o>{{</span> end <span class=o>}}</span></span></span></code></pre></div><ul><li>To enable KaTex globally set the parameter <code>math</code> to <code>true</code> in a project&rsquo;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 <a href=https://katex.org/docs/supported.html>Supported TeX Functions</a></p><h3 id=examples>Examples</h3><p>Block math:
$$
\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } }
$$</p></content><p></p><p><a href='mailto:me@example.com?subject=Reply%20to%20"Math%20Typesetting"'>Reply to this post by email ↪</a></p></main><footer><small>John Doe (CC BY 4.0) | Made with <a href=https://github.com/clente/hugo-bearcub>Bear Cub</a></small></footer></body></html>