LaTeX Formula Syntax
For practicing LaTeX syntax, while testing the rendering result of the katex engine
Greek Letters and Split Formulas
$$\begin{split} \alpha \qquad alpha \ \beta \qquad beta \ \gamma \qquad gamma \ \delta \qquad delta \ \epsilon \qquad epsilon \ \varepsilon \qquad varepsilon\ \zeta \qquad zeta \ \eta \qquad eta \theta \qquad theta\ \end{split}$$
bye.
Matrixes
Add prefixes b, v, p, m in front of matrix for brackets, vertical bars, parentheses; none for no brackets $$\begin{matrix}1\quad0 \ 0\quad 1\end{matrix}$$ Combine with dots $$\begin{bmatrix} 1 & 0 & 0 & \cdots \ 0 & 1 &0 & \cdots \ \vdots & \vdots & \vdots & \ddots \end{bmatrix}$$
Vectors
Use vec for single letters, overrightarrow for multiple letters, and there is another thing $\rightarrow$ $$\vec{a} \cdot \overrightarrow{AB}$$
Horizontal Braces
$$\overbrace{x_1+x_2+…+x_i}^{n items}$$ $$\underbrace{a+b+\cdots +z}_{26 letters of the alphabet}$$
Underline, Overline, and Hats
First, the two standard notations, which cannot be previewed normally within the editor $$\underline{a+b+c}$$ $$\overline{x+y+z}$$ Next, two notations that can be normally previewed within the editor, both using the over command, one as a prefix and the other as a suffix $$\over{over}$$ $${over\quad behind}\over$$ $$x\quad\bar x \quad \hat x \quad \tilde x$$
Square Roots
$$\sqrt{x}+\sqrt[3]{y_{i}}$$
Fractions
A particularly unique syntax, first type \frac{x}{y}, with the command indicator at the very beginning $$\frac{x}{y}$$
Subscripts and Superscripts
$$x^{2/3}\tag{1.1}$$ $$x_{i+1}$$
Multiplication
$$y=x\cdot z$$
Inequalities
Standard notation $$1\neq2$$ Abbreviation, not sure if it can be rendered $$\begin{cases} 1\equiv1\ 1 \quad x\bmod2\ \end{cases}$$
Product
\prod
$\prod$
\sim
$\sim
\mathbb $\mathbb E
x \prime
$x \prime$
Mathematical Formulas
FixIt Supports mathematical formulas based on [$\KaTeX$][katex].
In [params.math]
under the theme configuration, set the property enable = true
,
and set the property math: true
in the front matter of the article to enable automatic rendering of mathematical formulas.
Since Hugo renders Markdown documents into HTML based on syntax like _
/*
/>>
, and some textual content in the form of escape characters (such as \(
/\)
/\[
/\]
/\\
) will be automatically processed for escape sequences, it is necessary to express these places with additional escape characters to achieve automatic rendering:
_
->\_
*
->\*
>>
->\>>
\(
->\\(
\)
->\\)
\[
->\\[
\]
->\\]
\\
->\\\\
The FixIt theme supports the [raw
shortcode] to avoid these escape characters,
allowing you to write raw mathematical formula content.
An example of raw
:
|
|
The output effect rendered as follows:
Inline Formulas
The default inline formula delimiters are:
For example:
|
|
The output effect is as follows:
$c = \pm\sqrt{a^2 + b^2}$ and \(f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi\)
Formula Block
The default formula block separators include:
$$ ... $$
\[ ... \]
(escaped:\\[ ... \\]
)\begin{equation} ... \end{equation}
(unnumbered:\begin{equation*} ... \end{equation*}
)\begin{align} ... \end{align}
(unnumbered:\begin{align*} ... \end{align*}
)\begin{alignat} ... \end{alignat}
(unnumbered:\begin{alignat*} ... \end{alignat*}
)\begin{gather} ... \end{gather}
(unnumbered:\begin{gather*} ... \end{gather*}
)\begin{CD} ... \end{CD}
goldmark.renderer.hardWraps
. When set to true, Goldmark will render line breaks as <br>
elements.For example:
|
|
The output effect is as follows:
$$ c = \pm\sqrt{a^2 + b^2} $$
\[ f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi \]
\begin{equation*} \rho \frac{\mathrm{D} \mathbf{v}}{\mathrm{D} t}=\nabla \cdot \mathbb{P}+\rho \mathbf{f} \end{equation*}
\begin{equation} \mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots \end{equation}
\begin{align} a&=b+c \\ d+e&=f \end{align}
\begin{alignat}{2} 10&x+&3&y = 2 \\ 3&x+&13&y = 4 \end{alignat}
\begin{gather} a=b \\ e=b+c \end{gather}
\begin{CD} A @>a>> B \\ @VbVV @AAcA \\ C @= D \end{CD}
Copy-tex
[Copy-tex][copy-tex] is a $\KaTeX$ plugin.
This extension copies the $\LaTeX$ source code of $\KaTeX$ rendered formulas to the clipboard when selecting and copying them.
Enable Copy-tex by setting the copyTex = true
property under [params.math]
in the theme configuration.
When selecting and copying the formulas rendered in the previous section, you’ll find that the LaTeX source code is copied.
mhchem
[mhchem][mhchem] is a $\KaTeX$ plugin.
With this extension, you can easily write beautiful chemical equations in your articles.
Enable mhchem by setting the mhchem = true
property under [params.math]
in the theme configuration.
|
|
The output effect is as follows:
$$ \ce{CO2 + C -> 2 CO} $$
$$ \ce{Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-} $$
Character Annotations or Comments
The FixIt theme supports a Character Annotations or Comments Markdown extension syntax:
The output is rendered as follows:
Hugo
Fraction
FixIt theme supports a Fraction Markdown extension syntax:
|
|
The output is rendered as follows:
Light/Dark
90/100