Skip to content

Latest commit

 

History

History
1515 lines (1203 loc) · 43.8 KB

File metadata and controls

1515 lines (1203 loc) · 43.8 KB

markdown手册

[toc]

markdown基本语法

标题

# 一级标题
## 二级标题
### 三级标题
#### 四级标题
##### 五级标题
###### 六级标题

段落

a  

b

a

b

任务列表

- [ ] 跑步
- [ ] 骑车
- [x] 吃饭
- [ ] 睡觉
  • 跑步
  • 骑车
  • 吃饭
  • 睡觉

字体

*斜体*
_斜体_
**粗体**
__粗体__
___粗斜体___

斜体 斜体 粗体 粗体 粗斜体

分割线

***
* * *
******
- - -
----------





删除线

~~删除线~~ 

删除线

下划线

<u>下划线</u>

下划线

列表

* 无序列表1

+ 无序列表2

- 无序列表3

1. 有序列表

1. 列表嵌套
   -  嵌套
  • 无序列表1
  • 无序列表2
  • 无序列表3
  1. 有序列表

  2. 列表嵌套

    • 嵌套

区块

> 普通区块

> 嵌套区块1层
>
> > 嵌套区块2层

普通区块

嵌套区块1层

嵌套区块2层

源代码

```c++
#inclue <iostream>
int main(void) {
	std::cout << "hello world" << std::endl;
}
```
#inclue <iostream>
int main(void) {
	std::cout << "hello world" << std::endl;
}

链接

这个链接用 1 作为网址变量 [Google][1]

这个链接用 runoob 作为网址变量 [Runoob][runoob]

[1]: http://www.google.com/
[runoob]: http://www.runoob.com/

这个链接用 1 作为网址变量 Google

这个链接用 runoob 作为网址变量 Runoob

图片

![百度图标](https://www.baidu.com/img/PCfb_5bf082d29588c07f842ccde3f97243ea.png)

百度图标

锚定

这是正文,在这里引用锚点[<sup>[1]</sup>](#refer-anchor-1)

<div id="refer-anchor-1">[1] 作者. 文献名. 页码 起始-结束. 年份</div>

这是正文,在这里引用锚点[1](#refer-anchor-1)

[1] 作者. 文献名. 页码 起始-结束. 年份

脚注

注意:非标准语法,但typora支持

这里添加脚注[^1]

[^1]: 这里是脚注说明

这里添加脚注1

表格

无对齐方式:

|  表头  |  表头  |
|--------|--------|
| 单元格 | 单元格 |
| 单元格 | 单元格 |
表头 表头
单元格 单元格
单元格 单元格

对齐方式:

| 左对齐 |  居中  | 右对齐 |
| :----- | :----: | -----: |
| 单元格 | 单元格 | 单元格 |
| 单元格 | 单元格 | 单元格 |
左对齐 居中 右对齐
单元格 单元格 单元格
单元格 单元格 单元格

内嵌html语法样式

颜色

<span style='background-color:yellow'>黄色</span>

黄色

代码块

<pre>
int main(void) {
    ...
}
</pre>
int main(void) {
    ...
}

单元格

<table>
    <caption> 标题 </caption>
    <tr align = "left">
        <th> 表头1 </th>
        <th> 表头2 </th>
    </tr>
    <tr align = "left">
        <td rowspan = "2"> 单元格1 </td>
        <td align = "left"> 单元格2 </td>
    </tr>
    <tr>
        <td align = "center"> 单元格3 </td>
    </tr>
    <tr align = "right">
        <td colspan = "2"> 单元格4 </td>
    </tr>
</table>
标题
表头1 表头2
单元格1 单元格2
单元格3
单元格4
### 左右分栏
<div style="width: 50%; float:left;">左侧</div>
<div style="width: 50%; float:left;">右侧</div>
左侧
右侧

数学公式

希腊字母

效果 源码 效果 源码 效果 源码 效果 源码 效果 源码 效果 源码
$\alpha$ $\alpha$ $\kappa$ $\kappa$ $\psi$ $\psi$ $\digamma$ $\digamma$ $\Delta$ $\Delta$ $\Theta$ $\Theta$
$\beta$ $\beta$ $\lambda$ $\lambda$ $\rho$ $\rho$ $\varepsilon$ $\varepsilon$ $\Gamma$ $\Gamma$ $\Upsilon$ $\Upsilon$
$\chi$ $\chi$ $\mu$ $\mu$ $\sigma$ $\sigma$ $\varkappa$ $\varkappa$ $\Lambda$ $\Lambda$ $\Xi$ $\Xi$
$\delta$ $\delta$ $\nu$ $\nu$ $\tau$ $\tau$ $\varphi$ $\varphi$ $\Omega$ $\Omega$ $\ell$ $\ell$
$\epsilon$ $\epsilon$ $o$ $o$ $\theta$ $\theta$ $\varpi$ $\varpi$ $\Phi$ $\Phi$ $\aleph$ $\aleph$
$\eta$ $\eta$ $\omega$ $\omega$ $\upsilon$ $\upsilon$ $\varrho$ $\varrho$ $\Pi$ $\Pi$ $\beth$ $\beth$
$\gamma$ $\gamma$ $\phi$ $\phi$ $\xi$ $\xi$ $\varsigma$ $\varsigma$ $\Psi$ $\Psi$ $\daleth$ $\daleth$
$\iota$ $\iota$ $\pi$ $\pi$ $\zeta$ $\zeta$ $\vartheta$ $\vartheta$ $\Sigma$ $\Sigma$ $\gimel$ $\gimel$

文本文字

$$\mathbb{ABCdef}$$

$$ \mathbb{ABCdef} $$

$$\text{hello world}$$

$$ \text{hello world} $$

Ⅰ, Ⅱ, Ⅲ, Ⅳ, Ⅴ, Ⅵ, Ⅶ, Ⅷ, Ⅸ, Ⅹ, Ⅺ, Ⅻ, ⅩⅢ, ⅩⅣ, ⅩⅤ, ⅩⅥ, ⅩⅦ, ⅩⅧ, ⅩⅨ, ⅩⅩ, ⅩⅩⅩ, ⅩⅬ, Ⅼ, ⅬⅩ, ⅬⅩⅩ, ⅬⅩⅩⅩ, ⅩⅭ, ⅩⅭⅨ

Ⅰ, Ⅱ, Ⅲ, Ⅳ, Ⅴ, Ⅵ, Ⅶ, Ⅷ, Ⅸ, Ⅹ, Ⅺ, Ⅻ, ⅩⅢ, ⅩⅣ, ⅩⅤ, ⅩⅥ, ⅩⅦ, ⅩⅧ, ⅩⅨ, ⅩⅩ, ⅩⅩⅩ, ⅩⅬ, Ⅼ, ⅬⅩ, ⅬⅩⅩ, ⅬⅩⅩⅩ, ⅩⅭ, ⅩⅭⅨ

标准函数

效果 源码 效果 源码 效果 源码 效果 源码
$\arccos$ $\arccos$ $\arcsin$ $\arcsin$ $\arctan$ $\arctan$ $\arg$ $\arg$
$\cos(x)$ $\cos(x)$ $\cosh$ $\cosh$ $\cot(x)$ $\cot(x)$ $\coth$ $\coth$
$\csc$ $\csc$ $\deg$ $\deg$ $\det$ $\det$ $\dim$ $\dim$
$\exp $ $\exp$ $\gcd$ $\gcd$ $\hom$ $\hom$ $\inf$ $\inf$
$\ker $ $\ker$ $\lg x$ $\lg x$ $\lim^{x \to \infty}_{y \to 0}$ $\lim^{x \to \infty}_{y \to 0}$ $\liminf$ $\liminf$
$\limsup$ $\limsup$ $\ln x$ $\ln x$ $\log_x y$ $\log_x y$ $\max$ $\max$
$\min$ $\min$ $\Pr$ $\Pr$ $\sec$ $\sec$ $\sin(x)$ $\sin(x)$
$\sinh$ $\sinh$ $\sup$ $\sup$ $\tan(x)$ $\tan(x)$ $\tanh$ $\tanh$

算术运算

效果 源码 效果 源码 效果 源码 效果 源码
$x \pm y$ $x \pm y$ $x \mp y$ $x \mp y$ $x \times y$ $x \times y$ $x \cdot y$ $x \cdot y$
$x \ast y$ $x \ast y$ $x \div y$ $x \div y$ $x/y$ $x/y$ $x \quad y$ $x \quad y$
$x \mid y$ $x \mid y$ $x \nmid y$ $x \nmid y$ $x \parallel y$ $x \parallel y$ $x \nparallel y$ $x \nparallel y$

逻辑关系

效果 源码 效果 源码 效果 源码 效果 源码
$\forall$ $\forall$ $\exists$ $\exists$ $\because$ $\because$ $\therefore$ $\therefore$
$\neg$ $\neg$ $\infty$ $\infty$ $\emptyset$ $\emptyset$
$x \in y$ $x \in y$ $x \notin y$ $x \notin y$ $x \subset y$ $x \subset y$ $x \not\subset y$ $x \not\subset y$
$x \subseteq y$ $x \subseteq y$ $x \subsetneq y$ $x \subsetneq y$ $x \supset y$ $x \supset y$ $x \not\supset y$ $x \not\supset y$
$x \supseteq y$ $x \supseteq y$ $x \supsetneq y$ $x \supsetneq y$
$x \cup y$ $x \cup y$ $x \cap y$ $x \cap y$ $x \bigcup y$ $x \bigcup y$ $x \bigcap y$ $x \bigcap y$
$x \setminus y$ $x \setminus y$ $x \bigvee y$ $x \bigvee y$ $x \bigwedge y$ $x \bigwedge y$
$x \geq y$ $x \geq y$ $x \leq y$ $x \leq y$ $x \leqslant y$ $x \leqslant y$ $x \geqslant y$ $x \geqslant y$
$x &lt; y$ $x < y$ $x &gt; y$ $x > y$ $x \ll y$ $x \ll y$ $x \gg y$ $x \gg y$
$x \neq y$ $x \neq y$ $x \sim y$ $x \sim y$ $x \approx y$ $x \approx y$ $x \equiv y$ $x \equiv y$
$x \not\equiv y$ $x \not\equiv y$
$x \odot y$ $x \odot y$ $x \oplus y$ $x \oplus y$ $x \circ y$ $x \circ y$ $x \ominus$y $x \ominus y$
$x \bullet y$ $x \bullet y$ $x \otimes y$ $x \otimes y$
$(s, \preccurlyeq)$ $(s, \preccurlyeq)$ $x \prec y$ x \prec y
$(\mathcal{P}, \mathcal{C}, \mathcal{K}, \mathcal{E}, \mathcal{D})$ $(\mathcal{P}, \mathcal{C}, \mathcal{K}, \mathcal{E}, \mathcal{D})$

分割符号

效果 源码 效果 源码 效果 源码 效果 源码
${$ $\{$ $}$ $\}$ $\left [ \right ]$ $\left [ \right ]$ $\left ( \right )$ $\left ( \right )$
$\langle$ $\langle$ $\rangle$ $\rangle$
$|$ $|$ $\Vert$ $\Vert$
$\Uparrow$ $\Uparrow$ $\Downarrow$ $\Downarrow$ $\uparrow$ $\uparrow$ $\downarrow$ $\downarrow$
$\updownarrow$ $\updownarrow$ $\Updownarrow$ $\Updownarrow$
$\Leftarrow$ $\Leftarrow$ $\Rightarrow$ $\Rightarrow$ $\leftrightarrow$ $\leftrightarrow$ $\Leftrightarrow$ $\Leftrightarrow$
$\llcorner$ $\llcorner$ $\lrcorner$ $\lrcorner$ $\ulcorner$ $\ulcorner$ $\urcorner$ $\urcorner$

数学表达式

效果 源码 效果 源码
$\lfloor x \rfloor$ $\lfloor x \rfloor$ $\lceil x \rceil$ $\lceil x \rceil$
$\dot x$ $\dot x$ $\ddot x$ $\ddot x$
$\dot {\dot x}$ $\dot {\dot x}$
$\hat x$ $\hat x$ $\widehat {xy}$ $\widehat {xy}$
$\widetilde{x}$ $\widetilde{x}$
$x \leftarrow y$ $x \leftarrow y$ $x \rightarrow y$ $x \rightarrow y$
$x \mapsto y$ $x \mapsto y$
$\underleftarrow{a+b}$ $\underleftarrow{a+b}$ $\underrightarrow{a+b}$ \underrightarrow{a+b}
$\overleftarrow{a+b}$ $\overleftarrow{a+b}$ $\overrightarrow{a+b}$ $\overrightarrow{a+b}$
$\underline{a+b}$ $\underline{a+b}$ $\overline{a+b}$ $\overline{a+b}$
$\underleftrightarrow{a+b}$ $\underleftrightarrow{a+b}$ $\overleftrightarrow{a + b}$ $\overleftrightarrow{a + b}$
$\overbrace{a+\underbrace{b+c}_{1.0}+d}^{2.0}$ $\overbrace{a+\underbrace{b+c}_{1.0}+d}^{2.0}$ $\underbrace{a\cdot a\cdots a}_{b\text{ times}}$ $\underbrace{a\cdot a\cdots a}_{b\text{ times}}$
$a^b$ $a^b$ $\angle{abc}$ $\angle{abc}$
$\lbrace \frac{a}{b} \rbrace$ $\lbrace \frac{a}{b} \rbrace$ $\left \langle \frac{a}{b} \right \rangle$ $\left \langle \frac{a}{b} \right \rangle$
$\left [ a,b \right )$ $\left [ a,b \right )$
$A^* = \bigcup_{k=0}^{\infty} A^k$ $A^* = \bigcup_{k=0}^{\infty} A^k$
$\sqrt{x}$ $\sqrt{x}$ $\sqrt[n]{y}$ $\sqrt[n]{y}$
$\sum_{r=1}^n$ $\sum_{r=1}^n$
$\prod_{i=1}^{K}$ $\prod_{i=1}^{K}$ $\coprod$ $\coprod$
$\int^{\infty}_{0}$ $\int^{\infty}_{0}$ $\oint$ $\oint$
$\iint$ $\iint$ $\iiint$ $\iiint$
$\Bigg(\bigg(\Big(\big((x)\big)\Big)\bigg)\Bigg)$ $\Bigg(\bigg(\Big(\big((x)\big)\Big)\bigg)\Bigg)$ $\Bigg[\bigg[\Big[\big[[x]\big]\Big]\bigg]\Bigg]$ $\Bigg[\bigg[\Big[\big[[x]\big]\Big]\bigg]\Bigg]$
$\Bigg \langle \bigg \langle \Big \langle\big\langle\langle x \rangle \big \rangle\Big\rangle\bigg\rangle\Bigg\rangle$ $\Bigg \langle \bigg \langle \Big \langle\big\langle\langle x \rangle \big \rangle\Big\rangle\bigg\rangle\Bigg\rangle$ $\Bigg\lvert\bigg\lvert\Big\lvert\big\lvert\lvert x \rvert\big\rvert\Big\rvert\bigg\rvert\Bigg\rvert$ $\Bigg\lvert\bigg\lvert\Big\lvert\big\lvert\lvert x \rvert\big\rvert\Big\rvert\bigg\rvert\Bigg\rvert$
$\Bigg\lVert\bigg\lVert\Big\lVert\big\lVert\lVert x \rVert\big\rVert\Big\rVert\bigg\rVert\Bigg\rVert$ $\Bigg\lVert\bigg\lVert\Big\lVert\big\lVert\lVert x \rVert\big\rVert\Big\rVert\bigg\rVert\Bigg\rVert$
$\cdots$ $\cdots$ $\vdots$ $\vdots$
$60 %$ $60 \%$
$O(n \log n)$ $O(n \log n)$
$\aleph_0$ $\aleph_0$
$\vartheta_i$ $\vartheta_i$
$\mathbb{R}^n$ $\mathbb{R}^n$
$\nabla_{x_t}$ $\nabla_{x_t}$

数学公式

效果 源码
$f(x)$ $f(x)$
$\overset{a,b}{f(x)}$ $\overset{a,b}{f(x)}$
$\underset{ab}{f(x)}$ $\underset{ab}{f(x)}$
$ f\left(\left[\frac{1+\left{x,y\right}}{\left(\frac xy + \frac yx \right)(u+1)}+a \right]^{3/2} \right) \tag {行标} $ $ f\left(\left[\frac{1+\left\{x,y\right\}}{\left(\frac xy + \frac yx \right)(u+1)}+a \right]^{3/2} \right) \tag {行标} $
$\sum_{k_0,k_1,\ldots&gt;0 \atop k_0+k_1+\cdots=n}$ $\sum_{k_0,k_1,\ldots>0 \atop k_0+k_1+\cdots=n}$
${n+1 \choose k}={n \choose k}+{n \choose k-1}$ ${n+1 \choose k}={n \choose k}+{n \choose k-1}$
$\frac{\partial x}{\partial y}$ $\frac{\partial x}{\partial y}$
$a \overset{b}{=} c$ $a \overset{b}{=} c$
$a_{\left.{\overline{,2,}}!\right i}$
$\ddot{a}^{(m)}_{\left.{\overline{,2,}}!\right i}$
$x=a_0 + \cfrac {1^2}{a_1 + \cfrac {2^2}{a_2 + \cfrac {3^2}{a_3 + \cfrac {4^2}{a_4 + ...}}}}$ $x=a_0 + \cfrac {1^2}{a_1 + \cfrac {2^2}{a_2 + \cfrac {3^2}{a_3 + \cfrac {4^2}{a_4 + ...}}}}$
$\boxed{E=mc^2}$ $\boxed{E=mc^2}$
$c = m^e \bmod n$ $c = m^e \bmod n$

矩阵

矩阵(matrix)的表示:

$$
\begin{matrix}
x_{_{11} } & x_{_{12} } & \dots & x_{_{1n} } \\
x_{_{21} } & x_{_{22} } & \dots & x_{_{2n} } \\
\vdots & \vdots & \ddots  & \vdots  \\
x_{_{m1} } & x_{_{m2} } & \dots & x_{_{mn} } \\
\end{matrix}
$$

$$ \begin{matrix} x_{_{11} } &amp; x_{_{12} } &amp; \dots &amp; x_{_{1n} } \\ x_{_{21} } &amp; x_{_{22} } &amp; \dots &amp; x_{_{2n} } \\ \vdots &amp; \vdots &amp; \ddots &amp; \vdots \\ x_{_{m1} } &amp; x_{_{m2} } &amp; \dots &amp; x_{_{mn} } \\ \end{matrix} $$

矩阵(bmatrix)的表示:

$$
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}
$$

$$ \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix} $$

矩阵(Bmatrix)的表示:

$$
\begin{Bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{Bmatrix}
$$

$$ \begin{Bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{Bmatrix} $$

矩阵(pmatrix)的表示:

$\begin{pmatrix}1 & 2 \\ 3 & 4\\ \end{pmatrix}$

$\begin{pmatrix}1 & 2 \ 3 & 4\ \end{pmatrix}$

矩阵(vmatrix)的表示:

$\begin{vmatrix}1 & 2 \\ 3 & 4\\ \end{vmatrix}$

$\begin{vmatrix}1 & 2 \ 3 & 4\ \end{vmatrix}$

矩阵(Vmatrix)的表示:

$\begin{Vmatrix}1 & 2 \\ 3 & 4\\ \end{Vmatrix}$

$\begin{Vmatrix}1 & 2 \ 3 & 4\ \end{Vmatrix}$

增广矩阵(Augmented Matrix)的表示:

$$
\left[\begin{array}{ccc|c}
1 & 2 & 3 & 0\\
4 & 5 & 6 & 0\\
7 & 8 & 9 & 0
\end{array}\right]
$$

$$ \left[\begin{array}{ccc|c} 1 & 2 & 3 & 0\\ 4 & 5 & 6 & 0\\ 7 & 8 & 9 & 0 \end{array}\right] $$

行向量 $$ \vec{x} = (x_1, x_2, x_3, x_4) $$

$$
$\vec{x} = (x_1, x_2, x_3, x_4)$
$$

分类表达式

分类表达式1:

$$
f(n)
\begin{cases}
\cfrac n2, &\text{if n is even} \\
3n + 1, &\text{if n is odd}
\end{cases}
\qquad (1)f(n)
$$

$$ f(n) \begin{cases} \cfrac n2, &\text{if n is even} \\ 3n + 1, &\text{if n is odd} \end{cases} \qquad (1)f(n) $$

分类表达式2:

$$
L(Y,f(X)) =
\begin{cases}
0, & \text{Y = f(X)}  \\
1, & \text{Y $\neq$ f(X)}
\end{cases}
$$

$$ L(Y,f(X)) = \begin{cases} 0, & \text{Y = f(X)} \\ 1, & \text{Y $\neq$ f(X)} \end{cases} $$

多行表达式

$$
\begin{equation}\begin{split} 
a&=b+c-d \\ 
&\quad +e-f\\ 
&=g+h\\ 
& =i 
\end{split}\end{equation}
\qquad (1)
$$

$$ \begin{equation}\begin{split} a&=b+c-d \\ &\quad +e-f\\ &=g+h\\ & =i \end{split}\end{equation} \qquad (1) $$

方程组

$$
\left \{ 
\begin{array}{c}
a_1x+b_1y+c_1z=d_1 \\ 
a_2x+b_2y+c_2z=d_2 \\ 
a_3x+b_3y+c_3z=d_3
\end{array}
\right.
$$

$$ \left { \begin{array}{c} a_1x+b_1y+c_1z=d_1 \\ a_2x+b_2y+c_2z=d_2 \\ a_3x+b_3y+c_3z=d_3 \end{array} \right. $$

表格

$$
\begin{array}{c|lcr}
n & \text{左对齐} & \text{居中对齐} & \text{右对齐} \\
\hline
1 & 0.24 & 1 & 125 \\
2 & -1 & 189 & -8 \\
3 & -20 & 2000 & 1+10i \\
\end{array}
$$

$$ \begin{array}{c|lcr} n & \text{左对齐} & \text{居中对齐} & \text{右对齐} \\ \hline 1 & 0.24 & 1 & 125 \\ 2 & -1 & 189 & -8 \\ 3 & -20 & 2000 & 1+10i \\ \end{array} $$

交换图表

交换图表1:

$\require{AMScd}$
$$
\begin{CD}
    A @>a>> B\\
    @V b V V\# @VV c V\\
    C @>>d> D
\end{CD}
$$

$$ \begin{CD} A @>a>> B\\ @V b V V# @VV c V\\ C @>>d> D \end{CD} $$

交换图表2:

$$
\begin{CD}
    A @>>> B @>{\text{very long label}}>> C \\
    @. @AAA @| \\
    D @= E @<<< F
\end{CD}
$$

$$ \begin{CD} A @>>> B @>{\text{very long label}}>> C \\ @. @AAA @| \\ D @= E @<<< F \end{CD} $$

高级语法

流程图

样式流程图

基本语法:

  • graph 指定流程图方向:

    • graph LR 从左到右(left right)
    • graph TD 从上到下(top bottom)
    • graph RL 从右到左(right left)
    • graph BT 从下到上(bottom top)
  • 元素的形状定义

    • id[描述] 以直角矩形绘制
    • id(描述) 以圆角矩形绘制
    • id{描述} 以菱形绘制
    • id>描述] 以不对称矩形绘制
    • id((描述)) 以圆形绘制
  • 线条定义

    • A-->B 带箭头指向
    • A---B 不带箭头连接
    • A-.-B 虚线连接
    • A-.->B 虚线指向
    • A==>B 加粗箭头指向
    • A--描述---B 不带箭头指向并在线段中间添加描述
    • A--描述-->B 带描述的箭头指向
    • A-.描述.->B 带描述的虚线连指向
    • A==描述==>B 带描述的加粗箭头指向
  • 子流程图定义

    subgraph title
    	graph direction
    end

例:

```mermaid
graph LR
    A(开始) -->B(起床)
    B --天气不好--- C>干活]
    C ==> D{休息时间到了}
    D -.yes.-> E((休息))
    D -.no.-> C
    E --> F(吃饭)
	subgraph one
	F(吃饭)-->G(吃菜)-->H(夹菜)
	end
graph LR
    A(开始) -->B(起床)
    B --天气不好--- C>干活]
    C ==> D{休息时间到了}
    D -.yes.-> E((休息))
    D -.no.-> C
    E --> F(吃饭)
	subgraph one
	F(吃饭)-->G(吃菜)-->H(夹菜)
	end
Loading

标准流程图

基本语法:

  • 定义模块 id=>关键字: 描述 (“描述”的前面必须有空格,“=>” 两端不能有空格)

  • 关键字:

    • start 流程开始,以圆角矩形绘制
    • opearation 操作,以直角矩形绘制
    • condition 判断,以菱形绘制
    • subroutine 子流程,以左右带空白框的矩形绘制
    • inputoutput 输入输出,以平行四边形绘制
    • end 流程结束,以圆角矩形绘制
  • 定义模块间的流向:

    • 模块1 id->模块2 id :一般的箭头指向

    • 条件模块id (描述)->模块id(direction) :条件模块跳转到对应的执行模块,并指定对应分支的布局方向

例:

```flow
st=>start: 开始框
op=>operation: 处理框
cond=>condition: 判断框(是或否?)
sub1=>subroutine: 子流程
io=>inputoutput: 输入输出框
e=>end: 结束框

st->op->cond
cond(yes)->io->e
cond(no)->sub1(right)->op
st=>start: 开始框
op=>operation: 处理框
cond=>condition: 判断框(是或否?)
sub1=>subroutine: 子流程
io=>inputoutput: 输入输出框
e=>end: 结束框

st->op->cond
cond(yes)->io->e
cond(no)->sub1(right)->op

时序图

标准时序图

基本语法:

  • Title:标题:指定时序图的标题

  • Note direction of 对象:描述:在对象的某一侧添加描述,direction 可以为 right/left/over对象 可以是多个对象,以 , 作为分隔符

  • participant 对象 :创建一个对象

  • loop...end :创建一个循环体

  • 对象A->对象B:描述 : 绘制A与B之间的对话,以实线连接

    线条:

    • -> 实线实心箭头指向
    • --> 虚线实心箭头指向
    • ->> 实线小箭头指向
    • -->> 虚线小箭头指向

例:

```sequence
Title:时序图示例
客户端->服务端: 我想找你拿下数据 SYN
服务端-->客户端: 我收到你的请求啦 ACK+SYN
客户端->>服务端: 我收到你的确认啦,我们开始通信吧 ACK
Note right of 服务端: 我是一个服务端
Note left of 客户端: 我是一个客户端
Note over 服务端,客户端: TCP 三次握手
participant 观察者
Title:时序图示例
客户端->服务端: 我想找你拿下数据 SYN
服务端-->客户端: 我收到你的请求啦 ACK+SYN
客户端->>服务端: 我收到你的确认啦,我们开始通信吧 ACK
Note right of 服务端: 我是一个服务端
Note left of 客户端: 我是一个客户端
Note over 服务端,客户端: TCP 三次握手
participant 观察者

带样式时序图

基本语法同标准时序图,不同的是

  • 需要使用 mermaid 解析,并在开头使用关键字 sequenceDiagram 指明

  • 线段的样式遵循mermaid的解析方式:

    • -> : 实线连接
    • --> :虚线连接
    • ->> :实线箭头指向
    • -->> :虚线箭头指向

例:

```mermaid
sequenceDiagram
对象A->对象B:中午吃什么?
对象B->>对象A: 随便
loop 思考
    对象A->对象A: 努力搜索
end
alt 选择1
	对象A->>对象B: 选择1
else 选择2
	对象A->>对象C: 选择2
end
opt 可选
	对象A->>对象C: 可选项
end
par 并发
	对象A->>对象A: 并发1
and
	对象A->>对象B: 并发2
end
对象A-->>对象B: 火锅?
对象B->>对象A: 可以
Note left of 对象A: 我是一个对象A
Note right of 对象B: 我是一个对象B
participant 对象C
Note over 对象A,对象C: 汇总
sequenceDiagram
对象A->对象B:中午吃什么?
对象B->>对象A: 随便
loop 思考
    对象A->对象A: 努力搜索
end
alt 选择1
	对象A->>对象B: 选择1
else 选择2
	对象A->>对象C: 选择2
end
opt 可选
	对象A->>对象C: 可选项
end
par 并发
	对象A->>对象A: 并发1
and
	对象A->>对象B: 并发2
end
对象A-->>对象B: 火锅?
对象B->>对象A: 可以
Note left of 对象A: 我是一个对象A
Note right of 对象B: 我是一个对象B
participant 对象C
Note over 对象A,对象C: 汇总
Loading

甘特图

基本语法:

  • 使用 mermaid 解析语言,在开头使用关键字 gantt 指明

  • deteFormat 格式 指明日期的显示格式

  • title 标题 设置图标的标题

  • section 描述 定义纵向上的一个环节

  • 定义步骤:每个步骤有两种状态done(已完成)/active(执行中)

    • 描述: 状态,id,开始日期,结束日期/持续时间
    • 描述: 状态[,id],after id2,持续时间
    • crit :可用于标记该步骤需要被修正,将高亮显示
    • 如果不指定具体的开始时间或在某个步骤之后,将默认依次顺序排列

例:

```mermaid
gantt
        dateFormat  YYYY-MM-DD

        title 软件开发甘特图

        section 设计
        需求:done,des1, 2019-01-06,2019-01-08
        原型:active,des2, 2019-01-09, 3d
        UI设计:des3, after des2, 5d
        未来任务:des4, after des3, 5d

        section 开发
        学习准备理解需求:crit, done, 2019-01-06,24h
        设计框架:crit, done, after des2, 2d
        开发:crit, active, 3d
        未来任务:crit, 5d
        休息时间:2d

        section 测试
        功能测试:active, a1, after des3, 3d
        压力测试:after a1, 20h
        测试报告: 48h
gantt
        dateFormat  YYYY-MM-DD

        title 软件开发甘特图

        section 设计
        需求:done,des1, 2019-01-06,2019-01-08
        原型:active,des2, 2019-01-09, 3d
        UI设计:des3, after des2, 5d
        未来任务:des4, after des3, 5d

        section 开发
        学习准备理解需求:crit, done, 2019-01-06,24h
        设计框架:crit, done, after des2, 2d
        开发:crit, active, 3d
        未来任务:crit, 5d
        休息时间:2d

        section 测试
        功能测试:active, a1, after des3, 3d
        压力测试:after a1, 20h
        测试报告: 48h
Loading

UML图

类图

  • <|-- 继承

  • *__ 组合

  • o-- 聚合

  • --> 关联

  • -- 连接(实线)

  • ..> 依赖

  • ..|> 实现

  • .. 链接(虚线)

  • <<interface>> 接口

  • <<abstract>> 抽象类

  • <<service>> 服务类

  • <<enumeration>> 枚举

  • class 普通类

  • + public

  • - private

  • # protected

  • $ 静态

  • 不带符号表示 default

  • 包/内部类

  • 类图的画法

    1. 抽象类的类名以及抽象方法的名字都用斜体字表示
    2. 接口在类图中的第一层顶端用构造型 <<interface>>表示,下面是接口的名字,第二层是方法
classDiagram
	父类 <|-- 具体类

	class 父类{
		+public_func() bool
	}
	
	class 具体类{
		~ package ~
		+bool public_value
		#int protected_value
		-string private_value
		+public_func() bool
		#protected_func(num) int
		-private_func(str) string
	}
classDiagram
	父类 <|-- 具体类

	class 父类{
		+public_func() bool
	}
	
	class 具体类{
		~ package ~
		+bool public_value
		#int protected_value
		-string private_value
		+public_func() bool
		#protected_func(num) int
		-private_func(str) string
	}
Loading
classDiagram
	class 抽象类{
		<<abstract>>
		~ package ~
		+bool public_value
		#int protected_value
		-string private_value
		+public_func() bool
		#protected_func(num) int
		-private_func(str) string
	}
classDiagram
	class 抽象类{
		<<abstract>>
		~ package ~
		+bool public_value
		#int protected_value
		-string private_value
		+public_func() bool
		#protected_func(num) int
		-private_func(str) string
	}
Loading
classDiagram
	class 接口{
		<<interface>>
		~ package ~
		+public_func() bool
		#protected_func(num) int
		-private_func(str) string
	}
classDiagram
	class 接口{
		<<interface>>
		~ package ~
		+public_func() bool
		#protected_func(num) int
		-private_func(str) string
	}
Loading
classDiagram
	class 枚举{
		<<enumeration>>
		ELEM1
		ELEM2
		ELEM3
	}
classDiagram
	class 枚举{
		<<enumeration>>
		ELEM1
		ELEM2
		ELEM3
	}
Loading
classDiagram
	class 模版类~T~{
		+List~T~ public_value
	}
	模版类 : -List~T~ private_value
	模版类 : +public_func(List~T~ messages)
classDiagram
	class 模版类~T~{
		+List~T~ public_value
	}
	模版类 : -List~T~ private_value
	模版类 : +public_func(List~T~ messages)
Loading
classDiagram
classA --|> classB : Inheritance
classA1 o--|> classB1
classC --* classD : Composition
classE --o classF : Aggregation
classG --> classH : Association
classI -- classJ : Link(Solid)
classK ..> classL : Dependency
classM ..|> classN : Realization
classO .. classP : Link(Dashed)
classDiagram
classA --|> classB : Inheritance
classA1 o--|> classB1
classC --* classD : Composition
classE --o classF : Aggregation
classG --> classH : Association
classI -- classJ : Link(Solid)
classK ..> classL : Dependency
classM ..|> classN : Realization
classO .. classP : Link(Dashed)
Loading
classDiagram
    Customer "1" --> "*" Ticket
    Student "1" --> "1..*" Course
    Galaxy --> "many" Star : Contains
classDiagram
    Customer "1" --> "*" Ticket
    Student "1" --> "1..*" Course
    Galaxy --> "many" Star : Contains
Loading
classDiagram
class Shape
<<interface>> Shape
classDiagram
class Shape
<<interface>> Shape
Loading

饼图

pie
    title Key elements in Product X
    "Calcium" : 42.96
    "Potassium" : 50.05
    "Magnesium" : 10.01
    "Iron" :  5
pie
    title Key elements in Product X
    "Calcium" : 42.96
    "Potassium" : 50.05
    "Magnesium" : 10.01
    "Iron" :  5
Loading

折线图

(需要安装vidtor)

{
 "title" : {  
 "text": "简单的折线图",  
 "subtext": "纯属虚构"  
 },  
 "tooltip" : {  
 "trigger": "axis"  
 },  
 "toolbox": {  
 "show" : true,  
 "feature" : {  
 "mark" : {"show": true},  
 "dataView" : {"show": true, "readOnly": false},  
 "magicType" : {"show": true, "type": ["line", "bar"]},  
 "restore" : {"show": true},  
 "saveAsImage" : {"show": true}  
 }  
 },  
 "calculable" : true,  
    "xAxis": {
        "type": "category",
            "data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
    },
    "yAxis": {
        "type": "value"
    },
    "series": [{
        "data": [820, 932, 901, 934, 1290, 1330, 1320],
        "type": "line"
    }]
}

状态图

stateDiagram-v2
%% 注释

%% 状态
s1: 状态
s1 --> s2: 状态转换

%% 状态转换
[*] --> s3: 初始状态转换到其它

%% 合成状态
合成状态1 --> 合成状态2
合成状态1 --> 合成状态3
state 合成状态1 {
	[*] --> fir
	fir --> [*]
}
state 合成状态2 {
	[*] --> sec
	sec --> [*]
}
state 合成状态3 {
	[*] --> thi
	thi --> [*]
}

%% 分支与组合
state 分支状态 <<fork>>
分支状态 --> stat2: 分支
分支状态 --> stat3: 分支
state 组合状态 <<join>>
stat2 --> 组合状态: 组合
stat3 --> 组合状态: 组合

%% 标记状态
stat5: 状态标记
note left of stat5: 标记在左边

%% 并发
state 多线程 {
	[*] --> unlock1
	unlock1 --> lock1
	lock1 --> unlock1
	--
	[*] --> unlock2
	unlock2 --> lock2
	lock2 --> unlock2
	--
	[*] --> unlock3
	unlock3 --> lock3
	lock3 --> unlock3
}
stateDiagram-v2
%% 注释

%% 状态
s1: 状态
s1 --> s2: 状态转换

%% 状态转换
[*] --> s3: 初始状态转换到其它

%% 合成状态
合成状态1 --> 合成状态2
合成状态1 --> 合成状态3
state 合成状态1 {
	[*] --> fir
	fir --> [*]
}
state 合成状态2 {
	[*] --> sec
	sec --> [*]
}
state 合成状态3 {
	[*] --> thi
	thi --> [*]
}

%% 分支与组合
state 分支状态 <<fork>>
分支状态 --> stat2: 分支
分支状态 --> stat3: 分支
state 组合状态 <<join>>
stat2 --> 组合状态: 组合
stat3 --> 组合状态: 组合

%% 标记状态
stat5: 状态标记
note left of stat5: 标记在左边

%% 并发
state 多线程 {
	[*] --> unlock1
	unlock1 --> lock1
	lock1 --> unlock1
	--
	[*] --> unlock2
	unlock2 --> lock2
	lock2 --> unlock2
	--
	[*] --> unlock3
	unlock3 --> lock3
	lock3 --> unlock3
}
Loading

树状图

(typora等其他不支持graphviz的工具,可以使用这个网站:https://g.gravizo.com/svg 作为图床)

![graphviz](https://g.gravizo.com/svg?
	digraph demo {
    	bgcolor="beige"
    	node [shape="record", height=.1]
    	node0[label="<f0> | <f1> G | <f2>"]
    	node1[label="<f0> | <f1> E | <f2>"]
    	node2[label="<f0> | <f1> B | <f2>"]
    	node0:f0 -> node1:f1
    	node0:f2 -> node2:f1
    	a [label="{a | b | c}"]
    }
)

![graphviz](https://g.gravizo.com/svg? digraph demo { bgcolor="beige" node [shape="record", height=.1] node0[label=" | G | "] node1[label=" | E | "] node2[label=" | B | "] node0:f0 -> node1:f1 node0:f2 -> node2:f1 a [label="{a | b | c}"] } )

(如果工具如vnote等,支持graphviz,直接使用dot语法

​ digraph demo { ​ bgcolor="beige" ​ node [shape="record", height=.1] ​ node0[label=" | G | "] ​ node1[label=" | E | "] ​ node2[label=" | B | "] ​ node0:f0 -> node1:f1 ​ node0:f2 -> node2:f1 ​ a [label="{a | b | c}"] ​ }

参考

Footnotes

  1. 这里是脚注说明