Browse Source

Add Katex support

zwbetz 6 years ago
parent
commit
31c33627e6

+ 1 - 0
exampleSite/config.toml

@@ -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]]

+ 1 - 0
exampleSite/config.yaml

@@ -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:

+ 29 - 0
exampleSite/content/post/katex-math-typesetting/index.md

@@ -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} } } 
+$$

+ 1 - 0
layouts/_default/baseof.html

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

+ 5 - 0
layouts/partials/katex.html

@@ -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 }}