Blog 写作时的一些规范和特殊用法参考。同时作为 Markdown 渲染时的标准参考文件。
File
- 使用文件名为链接名,因此使用英文,用
-代替空格 - Front Matter 中写上
date和lastmod属性
Grammar
- 标点符号放在加粗外,比如:应该是证明:而非证明:
- 推导数学公式时加入
:,表示下面的公式与本段有关,除非有连接词 - 中文使用直角引号「」
- 中文和英文之间空格
- 数字和单位之间空格,如 8 GB
- 括号中放英文翻译时都使用英文括号,比如数学 (Math) 而不是数学(Math)
Markdown
脚注
示例1
标题引用
可以为标题增加 ID,以便在文内引用
Callout
Obsidian、Hugo 和 Typora 支持的 callout style 并不一致。
- Hugo:默认不支持,可通过安装 hugo-admonitions 插件实现,
- Obsidian:相比于 GitHub Alerts 支持更多。
- Typora:支持 GitHub Alerts。
Hugo 和 Obsidian 中支持 foldable callout:
Tip
在 callout 类型后增加 + 或 - 标志可使 callout 支持折叠。+ 默认状态为展开,- 默认折叠。
Hugo 和 Obsidian 中支持 nested callout:
所有样式如下:
全部支持
全部支持
全部支持。Obsidian 中是 Tip 的别名。
全部支持
全部支持。Obsidian 中是 warning 的别名。
Hugo + Obsidian
Hugo + Obsidian
Hugo + Obsidian
Hugo + Obsidian
Hugo + Obsidian
Hugo + Obsidian
Hugo + Obsidian。Obsidian 中是 danger 的别名。
Hugo + Obsidian
Hugo
Hugo
Hugo
Hugo
Hugo
Hugo
Hugo
Hugo
Obsidian
Obsidian
Obsidian
Image Caption
Mermaid Graph
pie "Dogs" : 386 "Cats" : 85 "Rats" : 15
venn-beta title "Team overlap" set Frontend set Backend union Frontend,Backend["APIs"]
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$数学推导:$\implies, \iff$
连分数使用
$$ \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{\#}
- 默认是二元运算符,如果想当负号使用,应该用括号包起来,例如:$\forall -x$ 对比 $\forall {-x}$
字体
默认拉丁字母、小写希腊字母是斜体,阿拉伯数字、大写希腊字母是罗马体
对字母有效:(一般用来表示特殊集合)
\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} $$$$ \norm{v}_2 \quad \norm{\frac 1 2} \quad \norm*{\frac 1 2} $$自定义数学符号
数学符号以罗马体表示,间距和上下标也会有区别,比如正确的写法 $\sin(x)$ 对比 $sin(x)$。自定义数学符号可以使用 \DeclareMathOperator 或 \DeclareMathOperator*。等价于使用 \operatorname 和 \operatorname*
MathJax Extensions
See MathJax Extension List TODO
$$ \toggle{math1}{math2}\endtoggle $$$$ \require{physics} \begin{pmatrix} \imat{2} \end{pmatrix} $$centernot:
$$ \centernot\implies \qquad \not\implies $$$$ \norm{a} $$自定规范
下面是一些自己制定的规范,用来更好的统一自己的写作,非强制
- 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
这是一个脚注 ↩︎