Files
hextra_mirror/exampleSite/content/docs/guide/latex.ja.md
Xin 7031718449 feat(math): add optional MathJax support (#707)
* feat: add MathJax option

* docs: move math engine note

* refactor: update LaTeX documentation and improve MathJax integration

- Adjusted LaTeX documentation for clarity and formatting.
- Enhanced MathJax configuration in the templates to support both KaTeX and MathJax rendering.
- Removed deprecated comments and streamlined the script loading process for MathJax.
- Updated the passthrough extension settings in the Hugo configuration for better compatibility with LaTeX math expressions.

* docs: simplify LaTeX documentation and clarify configuration steps

- Updated LaTeX documentation to reflect that KaTeX is enabled by default, removing the need for manual activation.
- Added examples for using LaTeX math expressions and clarified the configuration for the passthrough extension in Hugo.
- Enhanced MathJax section to emphasize its use as an alternative rendering engine.
2025-06-14 14:36:10 +01:00

3.1 KiB

title, weight
title weight
LaTeX 4

デフォルトでは、(\KaTeX) が LaTeX 数式のレンダリングに使用されます。 手動での有効化は不要で、Markdown コンテンツで LaTeX 数式をすぐに使い始めることができます。

Markdown コンテンツ内で、インラインおよび別段落の LaTeX 数式がサポートされています。

インライン

これは \(\sigma(z) = \frac{1}{1 + e^{-z}}\) インラインです。

これは (\sigma(z) = \frac{1}{1 + e^{-z}}) インラインです。

別段落

$$F(\omega) = \int_{-\infty}^{\infty} f(t) e^{-j\omega t} \, dt$$

次のようにレンダリングされます:

F(\omega) = \int_{-\infty}^{\infty} f(t) e^{-j\omega t} \, dt

例えば、aligned 環境を使用する場合:

$$
\begin{aligned}
  \nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\
  \nabla \cdot \mathbf{B} &= 0 \\
  \nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \\
  \nabla \times \mathbf{B} &= \mu_0 \left( \mathbf{J} + \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \right)
\end{aligned}
$$

次のようにレンダリングされます:


\begin{aligned}
  \nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\
  \nabla \cdot \mathbf{B} &= 0 \\
  \nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \\
  \nabla \times \mathbf{B} &= \mu_0 \left( \mathbf{J} + \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \right)
\end{aligned}

設定

Important

Hugo が Markdown コンテンツ内の LaTeX 数式を検出できるように、Hugo 設定ファイルで パススルー拡張機能 を有効にして設定してください。

markup:
  goldmark:
    extensions:
      passthrough:
        delimiters:
          block: [['\[', '\]'], ["$$", "$$"]]
          inline: [['\(', '\)']]
        enable: true

サポートされている関数

サポートされている関数の一覧については、KaTeX サポートされている関数 を参照してください。

化学

化学式は mhchem 拡張機能を介してサポートされています。

インライン: (\ce{H2O}) は水です。

別段落:

$$\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}$$

次のようにレンダリングされます:

\ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-}

数式エンジン

MathJax

デフォルトでは、ビルドプロセス中に LaTeX 数式をレンダリングするために KaTeX が使用されます(推奨)。 代替として、MathJax を使用して数式をレンダリングすることもできます。

MathJax を使用するには、hugo.yaml 設定ファイルに以下を追加してください:

params:
  math:
    engine: mathjax