Tex

Mr.Hope ... 2020-1-7 About 5 min

Let the Markdown file in your VuePress site support the TeX\TeX syntax.

# Config







 





module.exports = {
  plugins: [
    [
      "md-enhance",
      {
        // Enable Tex Support
        tex: true,
      },
    ],
  ],
};
1
2
3
4
5
6
7
8
9
10
11

# Grammar

# Inline Syntax

Use $codes$.

Euler’s identity $e^{i\pi}+1=0$ is a beautiful formula in $\mathbb{R}^2$.
1

Euler’s identity eiπ+1=0e^{i\pi}+1=0 is a beautiful formula in R2\mathbb{R}^2.

# Block Syntax

Use $$codes$$.

$$
\frac {\partial^r} {\partial \omega^r} \left(\frac {y^{\omega}} {\omega}\right)
= \left(\frac {y^{\omega}} {\omega}\right) \left\{(\log y)^r + \sum_{i=1}^r \frac {(-1)^ Ir \cdots (r-i+1) (\log y)^{ri}} {\omega^i} \right\}
$$
1
2
3
4

rωr(yωω)=(yωω){(logy)r+i=1r(1)Ir(ri+1)(logy)riωi}\frac {\partial^r} {\partial \omega^r} \left(\frac {y^{\omega}} {\omega}\right) = \left(\frac {y^{\omega}} {\omega}\right) \left\{(\log y)^r + \sum_{i=1}^r \frac {(-1)^ Ir \cdots (r-i+1) (\log y)^{ri}} {\omega^i} \right\}

# Playground

Here will be the render result

# Advanced

Besides setting tex: true in plugin options, you can also pass an object to it as KatexOptions. It will be passed to katex. Please see Katex Docs (opens new window) for available options.

# Tutorial

# Operator

  • Some operators can be entered directly in math mode; others need to be generated using control sequences:

    • +: ++
    • -: -
    • \times: ×\times
    • \ div: ÷\div
    • =: ==
    • \pm: ±\pm
    • \cdot: \cdot
    • \cup: \cup
    • \geq: \geq
    • \leq: \leq
    • \neq: \neq
    • \approx: \approx
    • \equiv: \equiv
    • \quad: \quad (blank separator)
  • Radical: \sqrt{xxx} xxx\sqrt{xxx}

  • Fraction \frac{aaa}{bbb} aaabbb\frac{aaa}{bbb} (the first parameter is the numerator and the second is the denominator).

  • Lianjia: \sum \sum

  • Tandem: \prod \prod

  • Limit: \lim lim\lim

  • Points: \int \int

  • Multiple points:

    • \iint: \iint
    • \iiint: \iiint
    • \liiiint:  ⁣ ⁣ ⁣\liiiint (Use \iiiint for block as normal)
    • \idotsint  ⁣ ⁣\idotsint

Tips

Large operators such as continuous addition, multiplication, limits, and integrals can use \limits and \nolimits to force explicitly specify compress these superscripts or not.

\iiiint( ⁣ ⁣ ⁣\liiiint) is support by hack, so for inline display you should use \liiiint.

\varoiint, \sqint, \sqiint, \ointctrclockwise, \ointclockwise, \varointclockwise, \varointctrclockwise, \fint, \landupint, \landdownint are not supported currently.

Case

x\sqrt{x}, 12\frac{1}{2}.

i=1nii=1n\sum_{i=1}^n i\; \prod_{i=1}^n

i=1nii=1n\sum\limits _{i=1}^n i\; \prod\limits_{i=1}^n

12x212x2 ⁣ ⁣ ⁣12x2 ⁣ ⁣12x2\iint_1^2 x^2\; \iiint_1^2 x^2\; \liiiint_1^2 x^2\; \idotsint_1^2 x^2

12x212x2 ⁣ ⁣ ⁣12x2 ⁣ ⁣12x2\iint\limits_1^2 x^2\; \iiint\limits_1^2 x^2\; \liiiint\limits_1^2 x^2\; \idotsint\limits_1^2 x^2

12x212x2 ⁣ ⁣ ⁣ ⁣12x2 ⁣ ⁣12x2\iint_1^2 x^2\; \iiint_1^2 x^2\; \iiiint_1^2 x^2\; \idotsint_1^2 x^2

$\sqrt{x}$, $\frac{1}{2}$.

$\sum_{i=1}^n i\; \prod_{i=1}^n$

$\sum\limits _{i=1}^n i\; \prod\limits _{i=1}^n$

$\iint_1^2 x^2\; \iiint_1^2 x^2\; \liiiint_1^2 x^2\; \idotsint_1^2 x^2$

$\iint\limits_1^2 x^2\; \iiint\limits_1^2 x^2\; \liiiint\limits_1^2 x^2\; \idotsint\limits_1^2 x^2$

$$\iint_1^2 x^2\; \iiint_1^2 x^2\; \iiiint_1^2 x^2\; \idotsint_1^2 x^2$$
1
2
3
4
5
6
7
8
9
10
11

# Symbol

  • English letters can be entered directly

    abcxyzABCa \quad b \quad c \quad x \quad y \quad z \quad A \quad B \quad C

    $a \quad b \quad c \quad x \quad y \quad z \quad A \quad B \quad C$
    
    1
  • Greek characters use \characterName to enter symbols, and output capital letters when the first letter is capitalized.

    αβγΩΔΓ\alpha \quad \beta \quad \gamma \quad \Omega \quad \Delta \quad \Gamma

    $\alpha \quad \beta \quad \gamma \quad \Omega \quad \Delta \quad \Gamma$
    
    1
  • Other mathematical expressions can be used correspondingly

    logabx\log_{a}{b} \quad \partial x

    $\log_{a}{b} \quad \partial x$
    
    1

# Superscript and Subscript

  • Superscript, use ^ to achieve
  • Subscript, use _ to achieve
  • By default, superscript and subscript only apply to the next character. To work with multiple consecutive characters, please enclose these characters in curly brackets {}.

# Demo

Einstein ’s E=mc2E=mc^2.

210>10002^{10} > 1000

Einstein ’s $E=mc^2$.

$2^{10} > 1000$
1
2
3

# Delimiters (parentheses, etc.)

Various parentheses are represented by commands such as (), [], \{\}, \langle\rangle.

Tips

Note that curly braces are usually used to enter command and environment parameters, so they must be preceded by \ in mathematical formulas.

Because the application of | and \| in LaTeX is too casual, we recommend using \lvert\rvert and \ lVert\rVert instead.

To adjust the size of these delimiters, we recommend using \big, \Big, \bigg, \Bigg and a series of commands to adjust the size before the above brackets.

(((((x)))))\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr) [[[[[x]]]]]\Biggl[\biggl[\Bigl[\bigl[[x]\bigr]\Bigr]\biggr]\Biggr] {{{{{x}}}}}\Biggl \{\biggl \{\Bigl \{\bigl \{\{x\}\bigr \}\Bigr \}\biggr \}\Biggr\} x\Biggl\langle\biggl\langle\Bigl\langle\bigl\langle\langle x \rangle\bigr\rangle\Bigr\rangle\biggr\rangle\Biggr\rangle x\Biggl\lvert\biggl\lvert\Bigl\lvert\bigl\lvert\lvert x \rvert\bigr\rvert\Bigr\rvert\biggr\rvert\Biggr\rvert x\Biggl\lVert\biggl\lVert\Bigl\lVert\bigl\lVert\lVert x \rVert\bigr\rVert\Bigr\rVert\biggr\rVert\Biggr\rVert

$\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)$
$\Biggl[\biggl[\Bigl[\bigl[[x]\bigr]\Bigr]\biggr]\Biggr]$
$\Biggl \{\biggl \{\Bigl \{\bigl \{\{x\}\bigr \}\Bigr \}\biggr \}\Biggr\}$
$\Biggl\langle\biggl\langle\Bigl\langle\bigl\langle\langle x
\rangle\bigr\rangle\Bigr\rangle\biggr\rangle\Biggr\rangle$
$\Biggl\lvert\biggl\lvert\Bigl\lvert\bigl\lvert\lvert x
\rvert\bigr\rvert\Bigr\rvert\biggr\rvert\Biggr\rvert$
$\Biggl\lVert\biggl\lVert\Bigl\lVert\bigl\lVert\lVert x
\rVert\bigr\rVert\Bigr\rVert\biggr\rVert\Biggr\rVert$
1
2
3
4
5
6
7
8
9

# Ellipsis

The ellipsis is represented by commands such as \dots,\cdots, \vdots,\ddots.

Tips

\dots and\cdots have different vertical positions. The former is generally used for subscripted sequences.

x1,x2,,xn1,2,,nx_1,x_2,\dots ,x_n \quad 1,2,\cdots ,n \quad \vdots\quad \ddots

$x_1,x_2,\dots ,x_n \quad 1,2,\cdots ,n \quad \vdots\quad \ddots$
1

# Matrix

pmatrix, bmatrix, Bmatrix, vmatrix, Vmatrix and other environments can add various separators on both sides of the matrix.

(abcd)[abcd]{abcd}abcdabcd\begin{pmatrix} a&b\\c&d \end{pmatrix} \quad \begin{bmatrix} a&b\\c&d \end{bmatrix} \quad \begin{Bmatrix} a&b\\c&d \end{Bmatrix} \quad \begin{vmatrix} a&b\\c&d \end{vmatrix} \quad \begin{Vmatrix} a&b\\c&d \end{Vmatrix}

$$
\begin{pmatrix} a&b\\c&d \end{pmatrix} \quad
\begin{bmatrix} a&b\\c&d \end{bmatrix} \quad
\begin{Bmatrix} a&b\\c&d \end{Bmatrix} \quad
\begin{vmatrix} a&b\\c&d \end{vmatrix} \quad
\begin{Vmatrix} a&b\\c&d \end{Vmatrix}
$$
1
2
3
4
5
6
7

Using the smallmatrix environment, you can generate small matrices of inline formulas.

A small matix: (abcd)( \begin{smallmatrix} a&b\\c&d \end{smallmatrix} ).

A small matix: $( \begin{smallmatrix} a&b\\c&d \end{smallmatrix} )$.
1

# Multi-line Formula

  • newline

    Use \\ or \newline to wrap

    x=a+b+c+d+e+f+gx = a+b+c+{} \\ d+e+f+g

    x=a+b+c+d+e+f+gx = a+b+c+ \newline d+e+f+g

    $$
    x = a+b+c+ \\
    d+e+f+g
    $$
    
    $$
    x = a+b+c+ \newline
    d+e+f+g
    $$
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
  • Alignment

    You can use the aligned environment to achieve alignment, and&to identify fixed anchor points

    x=a+b+c+d+e+f+g\begin{aligned} x ={}& a+b+c+{} \\ &d+e+f+g \end{aligned}

    10x+3y=23x+13y=4\begin{alignedat}{2} 10&x+ &3&y = 2 \\ 3&x+&13&y = 4 \end{alignedat}

    $$
    \begin{aligned}
    x ={}& a+b+c+{} \\
    &d+e+f+g
    \end{aligned}
    $$
    
    $$
    \begin{alignedat}{2}
       10&x+ &3&y = 2 \\
       3&x+&13&y = 4
    \end{alignedat}
    $$
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13

# Formula Group

Formula groups that do not require alignment can use the gather environment.

a=b+c+dx=y+z\begin{gathered} a = b+c+d \\ x = y+z \end{gathered}

$$
\begin{gathered}
a = b+c+d \\
x = y+z
\end{gathered}
$$
1
2
3
4
5
6

# Numbering

x+y2x(1)\tag{1} x+y^{2x}

x+y2x1\tag*{1} x+y^{2x}

$\tag{1} x+y^{2x}$

$\tag*{1} x+y^{2x}$
1
2
3

# Segmented Functions

Use case environment

y={x,x0x,x>0y= \begin{cases} -x,\quad x\leq 0 \\ x,\quad x>0 \end{cases}

$$
y= \begin{cases}
-x,\quad x\leq 0 \\
x,\quad x>0
\end{cases}
$$
1
2
3
4
5
6

# Text

To insert text in tex, you should use \text{} to wrap them.

# More

For more symbols, pleasae check out

Last update: June 4, 2022 13:16
Contributors: Mr.Hope , Mr.Hope