Add Katex support

This commit is contained in:
zwbetz 2019-04-02 20:59:56 -05:00
parent cc43fcbe7b
commit 31c33627e6
5 changed files with 37 additions and 0 deletions

View File

@ -22,6 +22,7 @@ disqusShortname = "yourdiscussshortname"
# For more date formats see https://gohugo.io/functions/format/
dateFormat = "Jan 2, 2006"
codePenUser = "someUser"
katex = true
[menu]
[[menu.nav]]

View File

@ -22,6 +22,7 @@ params:
# For more date formats see https://gohugo.io/functions/format/
dateFormat: Jan 2, 2006
codePenUser: someUser
katex: true
menu:
nav:

View File

@ -0,0 +1,29 @@
---
title: "Katex Math Typesetting"
date: 2019-03-28
tags: [katex, math, typesetting, hugo]
---
Enable Katex in the config file by setting the `katex` param to `true`. This will import the necessary Katex CSS/JS.
**Note:** Use the online reference of [supported TeX functions](https://katex.org/docs/supported.html).
Some math:
```
$$ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $$
```
$$ \varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887… $$
More math:
```
$$
\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } }
$$
```
$$
\varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } }
$$

View File

@ -14,6 +14,7 @@
</div>
</div>
{{ partial "script.html" . }}
{{ partial "katex.html" . }}
{{ partial "google-analytics-async.html" . }}
</body>
</html>

View File

@ -0,0 +1,5 @@
{{ if eq $.Site.Params.katex true }}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.css" integrity="sha384-dbVIfZGuN1Yq7/1Ocstc1lUEm+AT+/rCkibIcC/OmWo5f0EA48Vf8CytHzGrSwbQ" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/katex.min.js" integrity="sha384-2BKqo+exmr9su6dir+qCw08N2ZKRucY4PrGQPPWU1A7FtlCGjmEGFqXCv5nyM5Ij" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>
{{ end }}