博客写作时的一些规范和特殊用法参考
File
- 使用文件名为链接名,因此使用英文,用
-
代替空格 - Front Matter 中写上
date
和updated
属性
Markdown
列表不空行
列表之间不要空行,否则会被 pandoc 渲染为段落,间距会增大:
不空行:
- 111
- 222
- 333
空行:
111
222
333
Mermaid Graph
flowchart LR
A[Hard] -->|Text| B(Round)
B --> C{Decision}
C -->|One| D[Result 1]
C -->|Two| E[Result 2]
sequenceDiagram
Alice->>John: Hello John, how are you?
loop Healthcheck
John->>John: Fight against hypochondria
end
Note right of John: Rational thoughts!
John-->>Alice: Great!
John->>Bob: How about you?
Bob-->>John: Jolly good!
classDiagram
Class01 <|-- AveryLongClass : Cool
<<interface>> Class01
Class09 --> C2 : Where am i?
Class09 --* C3
Class09 --|> Class07
Class07 : equals()
Class07 : Object[] elementData
Class01 : size()
Class01 : int chimp
Class01 : int gorilla
class Class10 {
<<service>>
int id
size()
}
stateDiagram
[*] --> Still
Still --> [*]
Still --> Moving
Moving --> Still
Moving --> Crash
Crash --> [*]
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
journey
title My working day
section Go to work
Make tea: 5: Me
Go upstairs: 3: Me
Do work: 1: Me, Cat
section Go home
Go downstairs: 5: Me
Sit down: 3: Me
gantt
dateFormat YYYY-MM-DD
section Section
Completed :done, des1, 2014-01-06,2014-01-08
Active :active, des2, 2014-01-07, 3d
Parallel 1 : des3, after des1, 1d
Parallel 2 : des4, after des1, 1d
Parallel 3 : des5, after des3, 1d
Parallel 4 : des6, after des4, 1d
pie
"Dogs" : 386
"Cats" : 85
"Rats" : 15
gitGraph
commit
commit
branch develop
checkout develop
commit
commit
checkout main
merge develop
commit
commit
Grammar
- 推导数学公式时加入
:
,表示下面的公式与本段有关,除非有连接词 - 中文使用直角引号「」
- 中文和英文之间空格
- 数字和单位之间空格,如 8 GB
Tags
代码块头信息
|
|
Quote
|
|
{% blockquote Seth Godin https://sethgodin.typepad.com/seths_blog/2009/07/welcome-to-island-marketing.html Welcome to Island Marketing %} Every interaction is both precious and an opportunity to delight. {% endblockquote %}
{% cq %}茕茕白兔东奔西顾衣不如新人不如故{% endcq %}
Gist
{% gist f572e65dadb525a3ee501c001f657328 demo_gist_hello_func.py %}
Group Pictures
|
|
格式参见:
示例:
{% gp 5-2 %}
{% endgp %}
iframe
{% iframe https://www2.imm.dtu.dk/pubdb/views/edoc_download.php/3274/pdf/imm3274.pdf 900 500 %}
{% pdf https://www2.imm.dtu.dk/pubdb/views/edoc_download.php/3274/pdf/imm3274.pdf 500 %}
Video
|
|
YouTube
可以选择视频或播放列表
{% youtube LQF27xBvC9c %}
{% youtube PLzpTV3l6KkbBvBXS-nY613VH8q7MsgH2m ‘playlist’ %}
Button
|
|
url
: Absolute or relative path to URL.text
: Button text. Required if no icon specified.icon
: Font Awesome icon name. Required if no text specified.[class]
: Optional parameter. Font Awesome class(es):fa-fw
|fa-lg
|fa-2x
|fa-3x
|fa-4x
|fa-5x
[title]
: Optional parameter. Tooltip at mouseover.
{% btn #math, Math, infinity fa-fw fa-lg, to math chapter %}
Note
{% note default %} default tag {% endnote %}
{% note primary no-icon %} primary tag without icon {% endnote %}
{% note success Summary %} success tag with summary {% endnote %}
{% note info %} info tag {% endnote %}
{% note warning %} warning tag {% endnote %}
{% note danger %} danger tag {% endnote %}
Label
{% label default @Text %} {% label primary @Text %} {% label success @Text %} {% label info @Text %} {% label warning @Text %} {% label danger @Text %}
Tabs
{% tabs Tab 1, -1 %}
Tab with automatic label and None selected
Tab with automatic label and None selected
Tab with automatic label and None selected
{% endtabs %}
{% tabs Tab 2, 3 %}
This is Tab 1.
This is Tab 2.
Tab with automatic label and 3rd selected
{% endtabs %}
{% tabs Tab 3 %}
Tab 1 with custom label only
Tab 2 with icons only
Tab 3 with icon and label
{% endtabs %}
- Permalink for > Tab three
- Permalink for > Tab three 2
Math
基本知识
注释以
%
开头颜色:${\color{red} a + b =} c$
分数如果分子分母只有一个符号则可以省去括号:$\frac 1 2$
盒装公式:$\boxed{a+b}$
对比 $|-k|, \lvert - k\rvert, |{-k}|$; $\lVert -k \rVert, \|-k\|$
\mod
相关:$a\mod b$, $a\pmod b$, $a\bmod b$连分数使用
$$ \cfrac{1}{\sqrt{2}+ \cfrac{1}{\sqrt{2}+ \cfrac{1}{\sqrt{2}+\dotsb }}} $$cfrac
:改变限制的位置使用
$$ \begin{gather*} \sum_a \qquad \sum\nolimits_a \\ \int_a \qquad \int\limits_a \end{gather*} $$\limits
和\nolimits
:多行上下标使用
$$ \sum_{\substack{ 0\le i\le m \\ 0 < j < n}} P(i,j) $$\substack
:\text
表示 text,\mathrm
表示数学符号,\operatorname
表示函数
Spacing
Code | Description |
---|---|
\quad | space equal to the current font size |
\, | 3/18 of \quad |
\: | 4/18 of \quad |
\; | 5/18 of \quad |
\! | -3/18 of \quad |
\ (space after backslash) | equivalent of space in normal text |
\qquad | twice of \quad |
二元运算符和关系运算符的距离有极细微的差异:
$$ \begin{align*} 3ax+4by=5cz\\ 3ax<4by+5cz \end{align*} $$因此在定义自己的运算符时应确定是二元运算符 \mathbin{\#}
还是关系运算符 \mathrel{\#}
字体
默认拉丁字母、小写希腊字母是斜体,阿拉伯数字、大写希腊字母是罗马体
对字母有效:(一般用来表示特殊集合)
\mathbb
: 黑板粗体\mathcal
: 手写体(无小写)\mathscr
: 花体\mathfrak
: 哥特体
对整个公式有效:\mathnormal
, \mathrm
, \mathit
, \mathbf
, \mathsf
, \mathtt
Display Math
主环境
单行使用 equation
:
公式超出一行使用 multline
:
多行居中不对齐使用 gather
:
多行对齐使用 align
:(每个等式由两部分组成,用 &
分隔;等式之间同样由 &
分隔。用于排列多个公式)
align
会在列之间加入空格,如果希望自己控制距离则使用 alignat
:
align
为 flalign
:$$
\begin{flalign}
x&=y & w &=z & a&=b+c\\
2x&=-y & 3w&=\frac{1}{2}z & a&=b\\
-4 + 5x&=2+y & w+2&=-1+w & ab&=cb
\end{flalign}
$$主环境都可以在名字最后加入 *
来抑制自动编号
从属环境
公式多行推导使用从属环境 split
:
分段函数使用 cases
(公式样式会变为行内公式)或 dcases
(需要 mathtools
包)
其它从属环境:multlined
, gathered
, aligned
, alignedat
其它
MathJax 尚不支持从属编号环境 subequations
自定义
宏TODO
$$ \def\specialFrac#1#2{\frac{x + #1}{y + #2}} \specialFrac{7}{z+3} $$ $$ \DeclarePairedDelimiters\norm{\lVert}{\rVert} % require{\mathtools} \norm{v}_2 \quad \norm{\frac 1 2} \quad \norm*{\frac 1 2} \quad \norm[\Bigg]{v} $$自定义数学符号
数学符号以罗马体表示,间距和上下标也会有区别,比如正确的写法 $\sin(x)$ 对比 $sin(x)$。自定义数学符号可以使用 \DeclareMathOperator
或 \DeclareMathOperator*
。等价于使用 \operatorname
和 \operatorname*
MathJax Extensions
See MathJax Extension List TODO
$$ \toggle{math1}{math2}\endtoggle $$physics:
$$ \require{physics} $$centernot:
$$ \require{centernot} \centernot\implies \qquad \not\implies $$mathtools:
自定规范
下面是一些自己制定的规范,用来更好的统一自己的写作,非强制
- Expectation: $\mathbb{E}$
- Set: $\mathbb{R}, \mathbb{Z}$
- Empty set: $\varnothing$
- Gaussian: $\mathcal{N}$
- Conditional probability: $p(a | b)$
- Set with conditions: $\{a \mid a\in A\}$
- $i$-th