<font size=4>前言:最近沒(méi)課在看一些書(shū),博客搭好了所以想寫(xiě)一些筆記/分享,但是發(fā)現(xiàn)公式的編輯很是一個(gè)問(wèn)題,怎樣才能用比較簡(jiǎn)單快速的方法編輯出美觀規(guī)范的數(shù)學(xué)公式呢?語(yǔ)法+工具</font>
1.配置hexo-math插件
我使用的是NexT主題,對(duì)于大多數(shù)主題來(lái)說(shuō),推薦可以使用hexo-math插件來(lái)完成對(duì)LaTex公式的渲染。只需一步即可完成:
$ npm install hexo-math --save
是不是很省心~
2.常用LaTex語(yǔ)法
在這里我按照現(xiàn)有的文檔總結(jié)了幾個(gè)實(shí)用的LaTex語(yǔ)法:
段落處理
| 操作 | 方式 |
|---|---|
| 空格 | 不起作用 |
| 換行 | \ |
| 分段 | \par |
| 換頁(yè) | \newpage |
西文字符轉(zhuǎn)換表
實(shí)用為主,不贅述,可以用工具完成,工具下面會(huì)介紹
字號(hào)轉(zhuǎn)換命令表
| 中文字號(hào) | 控制命令 |
|---|---|
| 一號(hào) | \Huge |
| 二號(hào) | \huge |
| 三號(hào) | \LARGE |
| 四號(hào) | \Large |
| 小四號(hào) | \large |
| 五號(hào) | \normalsize |
| 小五號(hào) | \small |
| 六號(hào) | \footnotesize |
| 小六號(hào) | \scriptsize |
頁(yè)面控制命令
系統(tǒng)默認(rèn):字號(hào)10pt= 五號(hào)字;西文字體為羅馬字體;textwidth=12.2cm,textheight=18.6cm。相當(dāng)于美國(guó)標(biāo)準(zhǔn)信紙大小。
可以通過(guò)以下操作改變頁(yè)面尺寸:
\textwidth=
\textheight=
3.LaTex 公式渲染與 Markdown 渲染沖突問(wèn)題
如LaTex 中的下劃線_就會(huì)出現(xiàn)解析錯(cuò)誤。解決方法有很多,這里介紹兩種:
- 將LaTex 語(yǔ)法公式中的所有
_加反斜線\轉(zhuǎn)義,即\_可以解析成功。
但是,這樣的方式將導(dǎo)致所有的下標(biāo)都修改一遍。 - 將公式前后的一對(duì)
$分別換成{% math %}和{% endmath %}。
這種的方法實(shí)例將在5中給出。
4.在線LaTex編輯器
即使掌握了LaTex語(yǔ)法,但是編輯公式仍然是費(fèi)時(shí)費(fèi)力的,這里推薦在線LaTex編輯器,可以實(shí)現(xiàn)實(shí)時(shí)預(yù)覽功能的同時(shí)還提供了圖形輔助操作,節(jié)省了記憶和查詢(xún)語(yǔ)法的時(shí)間。相信你在第一眼看到它的時(shí)候就會(huì)用啦~
但是,最基本的語(yǔ)法還是要掌握的,工具不是萬(wàn)能的,有些生僻的格式還需要語(yǔ)法知識(shí),相輔相成嘛。
OK,用下面展示一些常用的代碼實(shí)例。
5.常用公式代碼實(shí)例
上下標(biāo)
{% math %}
\begin{aligned}
\dot{x} & = \sigma(y-x) \\
\dot{y} & = \rho x - y - xz \\
\dot{z} & = -\beta z + xy
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
\dot{x} & = \sigma(y-x) \
\dot{y} & = \rho x - y - xz \
\dot{z} & = -\beta z + xy
\end{aligned}
{% endmath %}
積分與求和
{% math %}
\begin{aligned}
\sum_{i=1}^{n}x_{i}=\int_{0}^{1}f(x)\mathrmu0z1t8osx
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
\sum_{i=1}{n}x_{i}=\int_{0}{1}f(x)\mathrmu0z1t8osx
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
\sum_{
1\leqslant i\leq n \atop
1\leqslant j\leq n
}a_{ij}
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
\sum_{
1\leqslant i\leq n \atop
1\leqslant j\leq n
}a_{ij}
\end{aligned}
{% endmath %}
極限
{% math %}
\begin{aligned}
\lim_{n \to \infty }\sin x_{n}=0
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
\lim_{n \to \infty }\sin x_{n}=0
\end{aligned}
{% endmath %}
根式
{% math %}
\begin{aligned}
x=\sqrt[m]{1+x^{p}}
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
x=\sqrt[m]{1+x^{p}}
\end{aligned}
{% endmath %}
絕對(duì)值
{% math %}
\begin{aligned}
\left | a+b \right |=\coprod_{m}^{n} \frac{e}{f}
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
\left | a+b \right |=\coprod_{m}^{n} \frac{e}{f}
\end{aligned}
{% endmath %}
矩陣
{% math %}
\begin{aligned}
\begin{pmatrix}
1 & 3 & 5 \\
2 & 4 & 6
\end{pmatrix}
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
\begin{pmatrix}
1 & 3 & 5 \
2 & 4 & 6
\end{pmatrix}
\end{aligned}
{% endmath %}
花括號(hào)
{% math %}
\begin{aligned}
\overbrace{a+b+\cdots +y+z}^{26}_{=\alpha +\beta}
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
\overbrace{a+b+\cdots +y+z}^{26}_{=\alpha +\beta}
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
a+\underbrace{b+\cdots +y}_{24}+z
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
a+\underbrace{b+\cdots +y}_{24}+z
\end{aligned}
{% endmath %}
堆砌
{% math %}
\begin{aligned}
y\stackrel{\rm def}{=} f(x) \stackrel{x\rightarrow 0}{\rightarrow} A
\end{aligned}
{% endmath %}
{% math %}
\begin{aligned}
y\stackrel{\rm def}{=} f(x) \stackrel{x\rightarrow 0}{\rightarrow} A
\end{aligned}
{% endmath %}