Skip to content

Commit e408173

Browse files
committed
Add support for math equations
1 parent 8b59fc7 commit e408173

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ params:
2929
# author: ["Me", "You"] # multiple authors
3030
images: ["<link or path of image for opengraph, twitter-cards>"]
3131
DateFormat: "January 2, 2006"
32+
math: true
3233
defaultTheme: auto # dark, light
3334
disableThemeToggle: false
3435

data/quotes.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,5 @@ quotes:
198198
author: "乔布斯"
199199
- text: "所谓大学之大,非有大楼之谓也,乃有大师之谓也。"
200200
author: 梅贻琦
201+
- text: "Time is a device that was invented to keep everything from happening at once"
202+
author: 剑桥大学建筑涂鸦

layouts/partials/extend_head.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{ if or .Params.math .Site.Params.math }}
2+
{{ partial "math.html" . }}
3+
{{ end }}

layouts/partials/math.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- https://adityatelange.github.io/hugo-PaperMod/posts/math-typesetting/ -->
2+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-5TcZemv2l/9On385z///+d7MSYlvIEw9FuZTIdZ14vJLqWphw7e7ZPuOiCHJcFCP" crossorigin="anonymous">
3+
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-cMkvdD8LoxVzGF/RPUKAcvmm49FQ0oxwDF3BGKtDXcEc+T1b2N+teh/OJfpU0jr6" crossorigin="anonymous"></script>
4+
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-hCXGrW6PitJEwbkoStFjeJxv+fSOOQKOPbJxSfM6G5sWZjAyWhXiTIIAmQqnlLlh" crossorigin="anonymous"></script>
5+
<script>
6+
document.addEventListener("DOMContentLoaded", function() {
7+
renderMathInElement(document.body, {
8+
// customised options
9+
// • auto-render specific keys, e.g.:
10+
delimiters: [
11+
{left: '$$', right: '$$', display: true},
12+
{left: '$', right: '$', display: false},
13+
{left: '\\(', right: '\\)', display: false},
14+
{left: '\\[', right: '\\]', display: true}
15+
],
16+
// • rendering keys, e.g.:
17+
throwOnError : false
18+
});
19+
});
20+
</script>

0 commit comments

Comments
 (0)