Latex Formula Syntax

Used to practice Latex syntax and test the rendering results of the KaTeX engine

1 Greek Letters and Multiline 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}$$ image-20240229161236144

bye.

2 Matrices

Add prefix b v p m to matrix, corresponding to square brackets, vertical lines, parentheses; no brackets if not added $$\begin{matrix}1\quad0 \ 0\quad 1\end{matrix}$$ Used with dots $$\begin{bmatrix} 1 & 0 & 0 & \cdots \ 0 & 1 &0 & \cdots \ \vdots & \vdots & \vdots & \ddots \end{bmatrix}$$

3 Vectors

Single letter vec, multi-letter overrightarrow, another is this thing $\rightarrow$ $$\vec{a} \cdot \overrightarrow{AB}$$

4 Overbraces

$$\overbrace{x_1+x_2+…+x_i}^{n items}$$ $$\underbrace{a+b+\cdots +z}_{26 English letters}$$

5 Underlines and Hats

First, two standard writing methods, cannot preview correctly in the editor $$\underline{a+b+c}$$ $$\overline{x+y+z}$$ Then two writing methods that can be previewed correctly in the editor, both are over commands, one is a prefix, the other is a suffix $$\over{over}$$ $${over\quad behind}\over$$ $$x\quad\bar x \quad \hat x \quad \tilde x$$

6 Radicals

$$\sqrt{x}+\sqrt[3]{y_{i}}$$

7 Fractions

The syntax is quite special, first type \frac{x}{y}, command mark at the very front $$\frac{x}{y}$$

8 Subscripts

$$x^{2/3}\tag{1.1}$$ $$x_{i+1}$$

9 Multiplication

$$y=x\cdot z$$

10 Inequalities

Standard writing $$1\neq2$$ Abbreviated, not sure if it can render $$\begin{cases} 1\equiv1\ 1 \quad x\bmod2\ \end{cases}$$

11 Products

\prod $\prod$ \sim $\sim$ \mathbb $\mathbb E$ x \prime $x \prime$

12 Mathematical Formulas

FixIt provides support for mathematical formulas based on [$\KaTeX$][katex].

Set the attribute enable = true under [params.math] in the theme configuration, and set the attribute math: true in the front matter of the article to enable automatic rendering of mathematical formulas.

Tip
Note

Since Hugo generates HTML documents based on syntax like _/*/>> when rendering Markdown documents, and some text content in the form of escape characters (such as \(/\)/\[/\]/\\) will be automatically escaped, additional escape character expressions are needed to achieve automatic rendering:

  • _ -> \_
  • * -> \*
  • >> -> \>>
  • \( -> \\(
  • \) -> \\)
  • \[ -> \\[
  • \] -> \\]
  • \\ -> \\\\

The FixIt theme supports the [raw shortcode] to avoid these escape characters, allowing the writing of raw mathematical formula content.

A raw example:

1
2
3
4
5
6
{{< raw >}}Inline formula: \(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\){{< /raw >}}

{{< raw >}}
Formula block:
\[ a=b+c \\ d+e=f \]
{{< /raw >}}

The rendered output is as follows:

Inline formula: \(\mathbf{E}=\sum_{i} \mathbf{E}_{i}=\mathbf{E}_{1}+\mathbf{E}_{2}+\mathbf{E}_{3}+\cdots\)
Formula block: \[ a=b+c \\ d+e=f \]

12.1 Inline Formulas

The default inline formula delimiters are:

  • $ ... $
  • \( ... \) (escaped: \\( ... \\))

For example:

1
$c = \pm\sqrt{a^2 + b^2}$ and \\(f(x)=\int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d \xi\\)

The rendered output 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\)

12.2 Formula Blocks

The default formula block delimiters are:

  • $$ ... $$
  • \[ ... \] (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}
Warning
Be cautious when enabling goldmark.renderer.hardWraps to true, as it will render line breaks as <br> elements when there are line breaks in the formula block.

For example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
$$ 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}

The rendered output 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}

Tip
Customize the delimiters for inline formulas and formula blocks in the theme configuration.

12.3 Copy-tex

[Copy-tex][copy-tex] is a $\KaTeX$ plugin.

With this extension, when selecting and copying formulas rendered by $\KaTeX$, their $\LaTeX$ source code will be copied to the clipboard.

Set the attribute copyTex = true under [params.math] in the theme configuration to enable Copy-tex.

By selecting and copying the formulas rendered in the previous section, you can find that the copied content is the LaTeX source code.

12.4 mhchem

[mhchem][mhchem] is a $\KaTeX$ plugin.

With this extension, you can easily write beautiful chemical equations in your articles.

Set the attribute mhchem = true under [params.math] in the theme configuration to enable mhchem.

1
2
3
$$ \ce{CO2 + C -> 2 CO} $$

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

The rendered output is as follows:

$$ \ce{CO2 + C -> 2 CO} $$

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

13 Character Annotation or Comment

The FixIt theme supports a character annotation or comment Markdown extension syntax:

1
[Hugo]^(an open-source static site generator)

The rendered output is as follows:

Hugoan open-source static site generator

14 Fractions

FixIt 0.2.0 | NEW

The FixIt theme supports a fraction Markdown extension syntax:

1
2
3
[Light]/[Dark]

[99]/[100]

The rendered output is as follows:

Light/Dark

90/100

Buy me a coffee~
Tim AlipayAlipay
Tim PayPalPayPal
Tim WeChat PayWeChat Pay
0%