From 81666ed54bb438f4af01fd4a111df8bd7d423120 Mon Sep 17 00:00:00 2001 From: d-dandrew <48591494+d-dandrew@users.noreply.github.com> Date: Tue, 2 Apr 2019 07:14:19 +0800 Subject: [PATCH] Add KaTeX support (#164) * Add render-latex-using-katex.md to Demonstarate how to use the katex * Update math.html add katex scripts and css --- .../content/posts/render-latex-using-katex.md | 36 +++++++++++++++++++ layouts/partials/posts/math.html | 14 ++++++++ 2 files changed, 50 insertions(+) create mode 100644 exampleSite/content/posts/render-latex-using-katex.md diff --git a/exampleSite/content/posts/render-latex-using-katex.md b/exampleSite/content/posts/render-latex-using-katex.md new file mode 100644 index 0000000..7fd69cb --- /dev/null +++ b/exampleSite/content/posts/render-latex-using-katex.md @@ -0,0 +1,36 @@ ++++ +date = "2019-03-20" +title = "Render LaTeX using KaTeX" +description = "Katex support demo" +katex = "true" +series = ["Theme", "Hugo"] ++++ + +Enable katex by adding `katex = "true"` to the [front matter](https://gohugo.io/content-management/front-matter/) + +```toml ++++ +katex = "true" ++++ +``` + +It's almost a dropin alternative to the mathjax solution,you should just choose one of them. + +Inline math looks like this + +```tex +This is text with inline math $\sum_{n=1}^{\infty} 2^{-n} = 1$ +``` + +This is text with inline math $\sum_{n=1}^{\infty} 2^{-n} = 1$ +and with math blocks: + +```tex +$$ +\sum_{n=1}^{\infty} 2^{-n} = 1 +$$ +``` + +$$ +\sum_{n=1}^{\infty} 2^{-n} = 1 +$$ diff --git a/layouts/partials/posts/math.html b/layouts/partials/posts/math.html index d33753a..111ed0a 100644 --- a/layouts/partials/posts/math.html +++ b/layouts/partials/posts/math.html @@ -22,3 +22,17 @@ }); {{- end -}} +{{- if .Params.katex -}} + + + +{{- end -}}