數學排版

KaTeX 設定簡要指南

Hugo 專案中的數學符號可以透過使用第三方 JavaScript 函式庫來啟用

在本例中我們將使用 KaTeX

  • 在下面創建一個部分 /layouts/partials/math.html
  • 在此部分中引用 自動渲染擴充功能 或在本機上託管這些腳本
  • 將部分內容包含在範本中,如下所示:
1
2
3
{{ if or .Params.math .Site.Params.math }}
{{ partial "math.html" . }}
{{ end }}
  • 若要全域啟用 KaTex,請將參數設定 math to true 專案配置中的
  • 若要在每頁啟用 KaTex,請 math: true 在內容檔案中包含該參數

注意: 使用 Supported TeX Functions 的線上參考

Examples 範例

Inline math: $\varphi = \dfrac{1+\sqrt5}{2}= 1.6180339887…$

Block math: $$ \varphi = 1+\frac{1} {1+\frac{1} {1+\frac{1} {1+\cdots} } } $$

Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy