Markdown与Katex语法 个人整理简洁版

Markdown语法

基础标题+字体样式

# 一级标题
## 二级标题
以此类推

加粗字体 **加粗字体**
斜体字体 *斜体字体*
斜体加粗 ***斜体加粗***
删除线 ~~删除线~~
荧光笔 <mark>荧光笔</mark>
半 角 空 格 半&ensp;角&ensp;空&ensp;格
全 角 空 格 全&emsp;角&emsp;空&emsp;格

无序、有序列表

  • 无序列表1 * 无序列表1
  • 无序列表2 * 无序列表2
  • 无序列表3 * 无序列表3
  • 无序列表4 * 无序列表4
  1. 有序列表1 1. 有序列表1
  2. 有序列表2 2. 有序列表2
  3. 有序列表3 3. 有序列表3
  4. 有序列表4 4. 有序列表4

建表

表头 左对齐 居中 右对齐
单元格 单元格 单元格 单元格
单元格 单元格 单元格 单元格
1
2
3
4
| 表头 | 左对齐 | 居中 | 右对齐 |
| - | :- | :-: | -: |
| 单元格 | 单元格 | 单元格 | 单元格 |
| 单元格 | 单元格 | 单元格 | 单元格 |

超链接

[想要显示的链接名](目标网址)
示例
点这里下载Anaconda [点这里下载Anaconda](https://www.anaconda.com/download)

图片

有关abbrlink的拓展

  1. 第一次使用的用户用如下命令安装
1
$ npm install hexo-abbrlink --save
  1. _config.yml中修改相关内容为如下
1
2
3
4
5
6
7
# URL
## Set your site url here. For example, if you use GitHub Page, set url as 'https://username.github.io/project'
url: 博客的地址,一般为https://"Github用户名".github.io
permalink: p/:abbrlink.html
abbrlink:
alg: crc32 # 算法:crc16(default) and crc32
rep: hex # 进制:dec(default) and hex

添加图片到正文

  1. 一般使用如下命令新建一篇文章
1
$ hexo new '你的文章名字'

则会在路径/source/_posts下生成一篇年-月-日-标题.md以及名为年-月-日-标题的文件夹

  1. 把想要插入的图片存放于该文件夹中,并使用如下命令
    ![本文的abbrlink](./你的图片.jpg "自定义鼠标悬停显示名")

示例
e6a46991 ![e6a46991](./testpic1.jpg "autumn")

Katex语法

我使用的是Next主题,如何安装可以参考这里
_config.next.yml中的相关片段修改为

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# ---------------------------------------------------------------
# Math Formulas Render Support
# See: https://theme-next.js.org/docs/third-party-services/math-equations
# Warning: Please install / uninstall the relevant renderer according to the documentation.
# Server-side plugin: https://github.com/next-theme/hexo-filter-mathjax
# ---------------------------------------------------------------

math:
# Default (false) will load mathjax / katex script on demand.
# That is it only render those page which has `mathjax: true` in front-matter.
# If you set it to true, it will load mathjax / katex script EVERY PAGE.
every_page: false

mathjax:
enable: false
# Available values: none | ams | all
tags: none

katex:
enable: true
# See: https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex
copy_tex: true

并将如下代码复制到你的文章.md<!-- less -->或者<!-- more -->后面

1
2
3
4
5
6
7
8
9
10
11
<head>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre'],
inlineMath: [['$','$']]
}
});
</script>
</head>

在2个$之间增加指令,就可以实现行间数学模式,与正文不冲突
在2个$$之间增加指令,将公式居中显示的单独模块

个人常用字符

希腊字母

效果 指令 效果 指令
α\alpha \alpha σ\sigma \sigma
β\beta \beta τ\tau \tau
γ\gamma \gamma Γ\Gamma \Gamma
δ\delta \delta Δ\Delta \Delta
ϵ\epsilon \epsilon ψ\psi \psi
ζ\zeta \zeta ω\omega \omega
η\eta \eta Ω\Omega \Omega
θ\theta \theta Θ\Theta \Theta
λ\lambda \lambda ϕ\phi \phi
μ\mu \mu φ\varphi \varphi
π\pi \pi ξ\xi \xi
ρ\rho \rho

箭头

样例 指令 样例 指令
\leftarrow \leftarrow \Leftarrow \Leftarrow
\rightarrow \rightarrow \Rightarrow \Rightarrow
\leftrightarrow \leftrightarrow \Leftrightarrow \Leftrightarrow
\uparrow \uparrow \mapsto \mapsto
\downarrow \downarrow \rightleftharpoons \rightleftharpoons

运算符

样例 指令 样例 指令
×\times \times \wedge \wedge
÷\div \div \vee \vee
\cap \cap \oplus \oplus
\cup \cup \otimes \otimes
\cdot \cdot \cdots \cdots

关系符

样例 指令 样例 指令
\neq \neq \subset \subset
\leq \leq \subseteq \subseteq
\geq \geq \approx \approx
\ll \ll \equiv \equiv
\gg \gg \cong \cong
\prec \prec \parallel \parallel
\succ \succ \perp \perp
\in \in \notin \notin

无穷、偏分、证明

样例 指令 样例 指令
\infty \infty \exists \exists
\partial \partial ¬\neg \neg
ø\text{\o} \text{\o} \because \because
\forall \forall \therefore \therefore

上标、下标

样例 指令 样例 指令
aˉ\bar{a} \bar{a}
a^\hat{a} \hat{a}
abc^\widehat{abc} \widehat{abc}
a~\tilde{a} \tilde{a} a~\utilde{a} \utilde{a}
abc~\widetilde{abc} \widetilde{abc}
A\vec{A} \vec{A}
AB\overline{AB} \overline{AB} AB\underline{AB} \underline{AB}
AB\overleftarrow{AB} \overleftarrow{AB} AB\underleftarrow{AB} \underleftarrow{AB}
AB\overleftrightarrow{AB} \overleftrightarrow{AB} AB\underleftrightarrow{AB} \underleftrightarrow{AB}
AB\overleftharpoon{AB} \overleftharpoon{AB}
AB\overgroup{AB} \overgroup{AB} AB\undergroup{AB} \undergroup{AB}

求和、求积、二项式

样例 指令
$$\sum_{i=1}^n$$ \sum_{i=1}^n
$$\prod_{i=1}^n$$ \prod_{i=1}^n
$$\tbinom{a}{b}$$ \tbinom{a}{b}

矩阵、行列式

(abcd)\left(\begin{matrix} a & b \\ c & d \end{matrix}\right)

1
2
3
4
$$\left(\begin{matrix}
a & b \\
c & d
\end{matrix}\right)$$

abcd\left|\begin{matrix} a & b \\ c & d \end{matrix}\right|

1
2
3
4
$$\left|\begin{matrix}
a & b \\
c & d
\end{matrix}\right|$$

(12n23n+1n21nn+1n2)\left(\begin{matrix} 1 & 2 & \cdots & n \\ 2 & 3 & \cdots & n+1 \\ \vdots & \vdots & \ddots & n^2 - 1\\ n & n+1 & \cdots & n^2 \end{matrix}\right)

1
2
3
4
5
6
$$\left(\begin{matrix}
1 & 2 & \cdots & n \\
2 & 3 & \cdots & n+1 \\
\vdots & \vdots & \ddots & n^2 - 1\\
n & n+1 & \cdots & n^2
\end{matrix}\right)$$

维持等号缩进

f(Xθ)=f(x1,x2,,xnθ)=f(x1θ)f(x2θ)f(xnθ)=i=1n1xi!eθθxi=(i=1n1xi!)enθθi=1nxi\begin{aligned} f(X|\theta) &= f(x_1,x_2,\cdots,x_n|\theta)\\ &= f(x_1|\theta) \cdot f(x_2|\theta) \cdots f(x_n|\theta)\\ &= \prod_{i=1}^n \frac{1}{x_i !} e^{-\theta}\theta^{x_i}\\ &= \left(\prod_{i=1}^n \frac{1}{x_i !}\right) e^{-n \theta}\theta^{\sum_{i=1}^n x_i} \end{aligned}

1
2
3
4
5
6
$$\begin{aligned}
f(X|\theta) &= f(x_1,x_2,\cdots,x_n|\theta)\\
&= f(x_1|\theta) \cdot f(x_2|\theta) \cdots f(x_n|\theta)\\
&= \prod_{i=1}^n \frac{1}{x_i !} e^{-\theta}\theta^{x_i}\\
&= \left(\prod_{i=1}^n \frac{1}{x_i !}\right) e^{-n \theta}\theta^{\sum_{i=1}^n x_i}
\end{aligned}$$

分段函数的表示(与Latex有差异)

因为不能用\equation和各种\cases,所以需要变通一下

f(x,θ)={1x2πθe12θ[log(x)]2, x>00, otherwisef(x,\theta) = \left\{ \begin{array}{ll} \dfrac{1}{x\sqrt{2\pi \theta}} e^{-\frac{1}{2\theta} [\log(x)]^2} &,\text{ $x>0$} \\ 0 &,\text{ otherwise} \end{array} \right.

1
2
3
4
5
$$f(x,\theta) = \left\{ \begin{array}{ll}
\dfrac{1}{x\sqrt{2\pi \theta}} e^{-\frac{1}{2\theta} [\log(x)]^2} &,\text{ $x>0$} \\
0 &,\text{ otherwise}
\end{array} \right.
$$