Skip to content

示例 ​

博客备注
查尔斯的知识库
mermaid 时序图live editor

markdown 语法 ​

自定义容器 ​

警告

VuePress v2 目前仍处于

提示

  • 使用 pnpm 时,你需要安装 vue 作为 peer-dependencies 。
  • 使用 yarn 2+ 时,你需要在 .yarnrc.yml 文件中设置 nodeLinker: 'node-modules' 。 :::
示例 .gitignore 文件
shell
.vuepress/.temp
# VuePress 默认缓存目录
.vuepress/.cache
# VuePress 默认构建生成的静态文件目录
.vuepress/dist

这是添加的标题

tip 后直接跟标题

无序列表 ​

  • 当前工作目录 cwd 下:
    • vuepress.config.ts
    • vuepress.config.js
    • vuepress.config.mjs
  • 源文件目录 sourceDir 下:
    • .vuepress/config.ts
    • .vuepress/config.js
    • .vuepress/config.mjs

  • 红色
  • 绿色
    • 红色
    • 绿色
  • 蓝色

有序列表 ​

  1. 红色
  2. 绿色
  3. 蓝色

引用文字 ​

这是一个有两段的块引用。这是第一段。 这是第二段。Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. 这是另一个只有一个段落的块引用。有三个空行分隔两个块引用。

水平线 ​


选择框和对号 ​

  • [ ] 作者靠才华吃饭
  • [x] 作者靠颜值吃饭

强调(斜体) ​

单个星号

单个下划线

*这个文字被文字星号包围*

要在用作强调分隔符的位置生成文字星号或下划线,可以用反斜杠转义

粗体 ​

双星号

双重下划线

代码 ​

使用printf()函数。

删除线 ​

错误的文字。

下划线 ​

下划线

徽标 ​

Title default Title ^1.9.0 Title beta Title caution

表情符号 ​

😄 😢 🐷

CodeGroup ​

sql
# email 不是主键,也没有设置唯一约束,根据熵增定律,查询结果是有可能会出现多条的
SELECT * FROM `sys_user` WHERE `email` = 'charles7c@126.com' LIMIT 1;
sql
# user_id 是主键,主键是非空唯一的,那么不需要添加 LIMIT 进行限制
SELECT * FROM `sys_user` WHERE `user_id` = 1;

空格 ​

海阔   天空

  插入一个空格   插入两个空格   插入四个空格   插入细空格

示例: 海阔 天空 海阔 天空 海阔 天空 海阔 天空

GitHub 风格的警报 ​

NOTE

强调用户在快速浏览文档时也不应忽略的重要信息。

TIP

有助于用户更顺利达成目标的建议性信息。

IMPORTANT

对用户达成目标至关重要的信息。

WARNING

因为可能存在风险,所以需要用户立即关注的关键内容。

CAUTION

行为可能带来的负面影响。

代码组 ​

js
/**
 * @type {import('vitepress').UserConfig}
 */
const config = {
	// ...
}

export default config
ts
import type { UserConfig } from 'vitepress'

const config: UserConfig = {
	// ...
}

export default config

HTML ​

this text is red

表格 ​

类别名称
颜色红色
黄色
姓氏
王张
CSW 命令状态封包
偏移 位
7 6 5 4 3 2 1 0

组件 ​

你可以在 Markdown 中直接使用 Vue 组件。

输入

md
这是默认主题内置的 `<Badge />` 组件 <Badge text="演示" />

输出

这是默认主题内置的 <Badge /> 组件 演示

iframe ​

代码区别 ​

diff
- module.exports = {
-   theme: '@vuepress/theme-default',
-   themeConfig: {
-     // 默认主题配置
-   },
- }

+ import { defaultTheme } from '@vuepress/theme-default'
+ import { defineUserConfig } from 'vuepress'
+
+ export default defineUserConfig({
+   theme: defaultTheme({
+     // 默认主题配置
+   })
+ })

反撇号` ​

`

原生显示 md 代码 ​

md
```ts{1,7-9}
import { defaultTheme } from '@vuepress/theme-default'
import { defineUserConfig } from 'vuepress'

export default defineUserConfig({
  title: '你好, VuePress',

  theme: defaultTheme({
    logo: 'https://vuejs.org/logo.png',
  }),
})
```

徽章 ​

制作徽章

@vuepress/cli@vuepress/plugin-register-components

上下标 ​

在Markdown中,上标和下标可以通过HTML的<sup>和<sub>标签来实现。

H2O

脚注 ​

先帝创业未半 [1]

vue ​

你好, Markdown 中的 Vue

当前计数为: 0

mermaid ​

mermaid docs, live editor

数学公式 ​

一、基本格式 ​

行内公式 ​

在两个美元符号中输入公式即可。

如$E=m\times c^2$ 效果:E=m×c2 (注:\times 是乘的意思)

整行公式 ​

在四个美元符号中输入公式,如果想要给公式后面添加编号,那么在公式后添加空格 + \tag{1}就可以了。

如$$ \sum_{i=0}^n i^2=\frac{(n^2+n)(2n+1)}{6} \tag{1} $$,效果:

(4){[(x1+x2)2−(y1−y2)4]×w}×(z12−z22)

上标与下标 ​

用_表示下标,^表示上标。

如$$ x_i^3+y_i^3=z_i^3 \tag{2} $$,效果:

(2)xi3+yi3=zi3

如$$ MSE=\sum_{i=1}^n (w\times x_i+b-y_i)^2 \tag{3} $$,效果:

(3)MSE=∑i=1n(w×xi+b−yi)2
tex
A_1^2
\\
B_{12}
\\
2^{x^2+y}
A12B122x2+y

括号 ​

()和[] 可以直接输入,但花括号{ }前面需要加转义符号\。

如$$ \{[(x_1+x_2)^2-(y_1-y_2)^4]\times w\}\times (z_1^2-z_2^2) \tag{4} $$ ,效果:

(4){[(x1+x2)2−(y1−y2)4]×w}×(z12−z22)

运算符 ​

img

并集 ​

⋃i=12R

交集 ​

⋂i=13

三角函数 ​

如$$ \sin(x+y)+\cos(y+z)+\tan(z+x)+\arcsin(x+y+z) \tag{7}$$,效果:

(7)sin⁡(x+y)+cos⁡(y+z)+tan⁡(z+x)+arcsin⁡(x+y+z)

对数 ​

如$\log_2 10$,效果:log2⁡10

如$\lg 10^3$,效果:lg⁡103

如$\ln (\pi+2)$,效果:ln⁡(π+2)

积分、导数 ​

如$g(x)=\frac{\partial f(x,y)}{\partial x}$,效果:g(x)=∂f(x,y)∂x

如$\int_a^{+\infty} x^2 \sin(x^3 +1)dx$,效果:∫a+∞x2sin⁡(x3+1)dx

如$$\displaystyle\int_0^{+\infty} \frac{1}{\sqrt{2\pi}}e^{-\frac {x^2}{2}}dx=\frac{1}{2} \tag{8}$$,效果:

(8)∫0+∞12πe−x22dx=12

开根号 ​

如$\sqrt{x+y}$,效果:x+y

如$\sqrt[n]{a + b}$,效果:x+y

tex
\sqrt{x}
\sqrt[3]{x}
xx3

分数 ​

tex
\frac{x}{1+x^2}
\\
\frac{\frac{1}{2}+x}{y}
\\
\tfrac{a}{b}
\frac{a}{b}
x1+x212+xyabab

组合数 ​

tex
\binom{n}{k}
\tbinom{n}{k}
(nk)(nk)

导数 ​

tex
a'
a''
a^{\prime}
a′a″a′

取模 ​

tex
x \pmod a
\\
2\mod{x}
x(moda)2modx

微分 ​

tex
\nabla
\partial x
\mathrm{d}x
\dot x
\ddot y
\Delta
∇∂xdxx˙y¨Δ

累加 ​

累加:使用 \sum_{下标表达式}^{上标表达式}

如$$ Y_i=\sum_{i=0}^{n} X_i \tag{5} $$,效果:

(5)Yi=∑i=0nXi

累积 ​

tex
\sum_{i=1}^{k}
\displaystyle\sum_{i=1}^n
\textstyle\sum_{i=1}^n
∑i=1k∑i=1n∑i=1n

累乘 ​

tex

\prod_{i=1}^{k}
\displaystyle\prod_{i=1}^n
\textstyle\prod_{i=1}^n
∏i=1k∏i=1n∏i=1n

极限 ​

tex

\lim_{k \to \infty}
\lim\limits_{k \to \infty}
\lim\nolimits_{k \to \infty}]
limk→∞limk→∞limk→∞]

二、修饰符号 ​

1. 简单的帽子 ​

tex
\hat{\theta}
\widehat{AB}
\\
\bar{y}
\overline{AB}
\\
\tilde{a}
\widetilde{ac}
\\
\bar{a}
\acute{a}
\check{a}
\grave{a}
\\
\dot{a}
\ddot{a}
θ^AB^y¯AB―a~ac~a¯a´aˇa`a˙a¨

2. 盒子和帽子 ​

tex
\overbrace{a+b+c}^{\text{note}}
\\
\underbrace{a+b+c}_{\text{note}}
\\
\boxed{\pi=3.14}
a+b+c⏞notea+b+c⏟noteπ=3.14

3. 各种括号 ​

tex
(
\big(
\Big(
\bigg(
\Bigg(
(((((
tex
[]
<>
|-2|
\{\}
[]<>|−2|{}
tex
\lgroup x \rgroup
\lVert a \rVert
\lceil 2.6 \rceil
\lfloor 1.2 \rfloor
⟮x⟯‖a‖⌈2.6⌉⌊1.2⌋
tex
\ulcorner
\urcorner
\llcorner
\lrcorner
⌜⌝⌞⌟

三、希腊字母 ​

imgimg

四、算术运算符号 ​

tex
+
-
\times
/
\div
\cdot
\#
\%
+−×/÷⋅#%
tex
\circ
\ast
\star
\otimes
\oplus
\odot
∘∗⋆⊗⊕⊙
tex
\pm
\mp
\dotplus
\divideontimes
±∓∔⋇

五、比较运算符 ​

tex
=
= \not
\equiv
\approx
\approxeq
\cong
\sim
\neq
\not=
==≢≈≊≅∼≠≠
tex
<
>
\le
\ge
\gg
\ll
<>≤≥≫≪
tex
\curlyeqprec
\curlyeqsucc
\prec
\succ
\preceq
\succeq
⋞⋟≺≻⪯⪰

六、集合运算符 ​

tex
\in
\owns \not
\subset \not
\supset
\subseteq
\supseteq
\\
\cap
\cup
\land
\lor
\\
\neg
\emptyset
\varnothing
\\
\because
\forall
\exists
\therefore
∈∋⊄⊅⊆⊇∩∪∧∨¬∅∅∵∀∃∴
tex
\cap
\cup
\land
\lor
\sqcup
\sqcap
∩∪∧∨⊔⊓

七、各种箭头 ​

tex
\gets
\leftarrow
\to
\rightarrow
\leftrightarrow
\\
\uparrow
\downarrow
\updownarrow
←←→→↔↑↓↕
tex
\Leftarrow
\Rightarrow
\Leftrightarrow
\iff
\\
\Uparrow
\Downarrow
\Updownarrow
⇐⇒⇔⟺⇑⇓⇕
tex
\nearrow
\searrow
\swarrow
\nwarrow
↗↘↙↖
tex
\longleftarrow
\longrightarrow
\longleftrightarrow
\Longleftarrow
\Longrightarrow
\Longleftrightarrow
\longmapsto
⟵⟶⟷⟸⟹⟺⟼
tex
\xrightarrow{over}
\xrightarrow[over]{}
\xrightarrow[under]{over}
\xleftarrow[]{over}
\xleftarrow[under]{}
\xleftarrow[under]{over}
→over→over→underover←over←under←underover

八、空间间距 ​

tex
A\!B
\\
AB
\\
A\thinspace B
\\
A\:B
\\
A\ B
\\
A \enspace B
\\
A\quad B
\\
A\qquad B
ABABABABA BABABAB

九、矩阵 ​

tex
A = \begin{matrix}
a & b\\
c & d
\end{matrix}
A=abcd
tex
B = \begin{pmatrix}
a & b\\
c & d
\end{pmatrix}
B=(abcd)
tex
D = \begin{bmatrix}
a & b\\
c & d
\end{bmatrix}
D=[abcd]
tex
E = \begin{Vmatrix}
a & b\\
c & d
\end{Vmatrix}
E=‖abcd‖
tex
F = \begin{Bmatrix}
a & b\\
c & d
\end{Bmatrix}
F={abcd}
tex
[A\ b] =
\begin{bmatrix}
\begin{array}{c c c|c}
a_{11} & a_{12} & a_{13} & b_1\\
a_{21} & a_{22} & a_{23} & b_2\\
a_{31} & a_{32} & a_{33} & b_3\\
\end{array}
\end{bmatrix}
[A b]=[a11a12a13b1a21a22a23b2a31a32a33b3]
tex
\begin{array}{c:c:c}
a & b & c \\
\hline
d & e & f \\
\hdashline
 g & h & i
\end{array}
abcdefghi
tex
L_{n\times n} = \begin{bmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\
a_{21} & a_{22} & \cdots & a_{2n} \\
\vdots & \vdots &\ddots & \vdots\\
a_{n1} & a_{n2} & \cdots & a_{nn} \\
\end{bmatrix}
Ln×n=[a11a12⋯a1na21a22⋯a2n⋮⋮⋱⋮an1an2⋯ann]

十、列式/方程组 ​

tex
\begin{aligned}
f(x) &= (x+1)^2\\
&= x^2 + 2x + 1
\end{aligned}
f(x)=(x+1)2=x2+2x+1
tex
f(x) = \begin{cases}
a &\text{if b}\\
b &\text{if a}\\
\end{cases}
f(x)={aif bbif a
tex
\begin{cases}
\begin{aligned}
x + 2y &= 1\\
3x - y &= 5
\end{aligned}
\end{cases}
{x+2y=13x−y=5
tex
g(x,y)=\left\{
\begin{array}{rcl}
\frac{M_g - d}{M_f-b}[f(x,y)-b]+d       &      & {b      \leq  f(x,y)  \leq M_f}\\
F^*_L     &      & {S_L \leq 0 < S_M}\\
F^*_R     &      & {S_M \leq 0 < S_R}\\
F_R       &      & {S_R \leq 0}
\end{array} \right.
g(x,y)={Mg−dMf−b[f(x,y)−b]+db≤f(x,y)≤MfFL∗SL≤0<SMFR∗SM≤0<SRFRSR≤0

十一、修改颜色和字体大小 ​

tex
\textcolor{blue}{F=ma}
\\
\textcolor{#00ff00}{F=ma}
\\
\textcolor{#ff0000}{F=ma}
\\
\color{blue} one\ line
\\
nothing
F=maF=maF=maone linenothing
tex
\colorbox{#00ff00}{F=ma}
\\
\colorbox{aqua}{A}
\\
\fcolorbox{red}{aqua}{A}
F=maAA
tex
AB
\Huge AB
\huge AB
\\
AB
\LARGE AB
\Large AB
\large AB
\\
AB
\small AB
\tiny AB
ABABABABABABABABABAB

十二、划掉 ​

tex
\cancel{5}
\bcancel{5}
\xcancel{ABC}
\not =
55ABC≠

十三、常见图形 ​

tex
\Box
\square
\blacksquare
\triangle
\triangledown
\blacktriangle
\diamond
\Diamond
\star
\bigstar
\circ
\bullet
\bigcirc
\bigodot
◻◻◼△▽▴⋄◊⋆★∘∙◯⨀
tex
\diamondsuit
\clubsuit
\heartsuit
\spadesuit
♢♣♡♠
tex
\angle
\measuredangle
\top
\bot
\infty
∠∡⊤⊥∞
tex
\checkmark
\dagger
\ddagger
\yen
\$
✓†‡¥$

十四、声明宏 ​

对于一些复杂但是只有少许不同的表达式,可以声明一个函数来调用,提高源码的可读性,减少出错

tex
\def\macroname#1#2{
your command
}

宏允许带任意数量的参数(也可以不带参),必须是#1,#2,……这样的命名格式,同时注意再定义宏的时候注意让#1与\ 中间隔一个空格,否则会解析成#。再调用的时候格式为\macroname{x}{y}{z},可以参考一下的例子

tex
\def\Normal#1#2#3{
\frac{1}{\sqrt{2\pi}\ #3}\exp{[-\frac{(#1 - #2)^2}{2\ #3^2}]}
}
f(x)=\Normal{x}{u_1}{\sigma_1}\\
f(y)=\Normal{y}{u_2}{\sigma_2}\\
f(x)=12π σ1exp⁡[−(x−u1)22 σ12]f(y)=12π σ2exp⁡[−(y−u2)22 σ22]
tex
\def\EXP{
e^x = 1 + x + \frac{1}{2!}x^2 + \frac{1}{3!}x^3  + \cdots
}
\EXP
ex=1+x+12!x2+13!x3+⋯
  1. 诸葛亮《出师表》 ↩︎

Updated At: