如何安装textlive
请自行百度,网络上面有很多教程。
-
一份其实很短的 LaTeX 入门文档
该文档包含作者,标题,日期,章节,段落,目录,插入数学公式、图片,表格,页眉页脚、页边距、间距的基本设置。
以下代码将我之前的一篇博客用Python可视化钢琴演奏录音用LaTeX编写编译,供各位参考其用法,点击此处直接下载。
12.6更新,最近在写英文论文,模板里用到了双页排版,涉及到处理数学公式的一些问题,在此总结下。
由于我目前的博客使用的是 KaTeX \KaTeX KATEX引擎处理的数学公式,而 LaTeX \LaTeX LATEX在使用的时候还是和他有区别的,特别是 LaTeX \LaTeX LATEX有而 KaTeX \KaTeX KATEX没有的命令在这里就无法很好的展示。因此我将用图片展示效果,附上相应的 LaTeX \LaTeX LATEX代码。
- 公式组的大括号。
\begin{equation}
\label{eq1}
\left\{
\begin{aligned}
x_c = \frac{M_{10}}{M_{00}},y_c = \frac{M_{01}}{M_{00}} \\
M_{00} = \sum_x \sum_y I(x,y) \\
M_{10} = \sum_x \sum_y xI(x,y) \\
M_{01} = \sum_x \sum_y yI(x,y)
\end{aligned}
\right.
\end{equation}
\left
和\right
总是成对出现的,但是我们需要的只是左边的大括号,因此写成\left\{
和\right.
即可。
如果要达到下面这样的效果呢?要求每一个公式后面都需要有编号,如下图:
这样需要我们在导言区引入两个package
,代码也和上面不同,直接使用subequations
里面嵌套numcases
即可。
\usepackage{subeqnarray}
\usepackage{cases}
\begin{subequations}
\label{eq3}
\begin{numcases}{}
x_c = \frac{M_{10}}{M_{00}},y_c = \frac{M_{01}}{M_{00}} \\
M_{00} = \sum_x \sum_y I(x,y) \\
M_{10} = \sum_x \sum_y xI(x,y) \\
M_{01} = \sum_x \sum_y yI(x,y)
\end{numcases}
\end{subequations}
- 公式间距微调
双栏排版,寸土寸金,万一公式太长,而又不想切换成单栏,就会出现下面的这种情况。可以看到,公式编号已经被挤到下一行去了,但是运算符之间的间距又比较大,可不可以将运算符之间的距离缩小呢?
参考博客LATEX微调公式间距
\begin{equation}
\label{eq6}
L_{o_1 o_2} \! = \! \sqrt{(x_{o_1} \! - \! x_{o_2})^2 \! + \! (y_{o_1} \! - \! y_{o_2})^2 \! + \! (z_{o_1} \! - \! z_{o_2})^2}
\end{equation}
在运算符之间输入\!
即可。其实\quad
,\qquad
,\,
,\:
,\;
,\!
本来是添加空格的,只不过\!
增加的是一个负的空格,就把间距缩小了。
缩小后的间距如下:
- 单双栏切换及公式下标大小调整
有时候,公式实在太长,不可能在单栏里面排下,只能换成双栏去排版。
对于这个模板来说,单双栏切换很简单,只需要将代码包含在\singlecolumn{}
的大括号之间就行,因为模板已经帮我们设置好了。稍后我们会介绍在没有模板的情况下的通用做法。
\singlecolumn{
\begin{equation}
\label{eq5}
L_{NM} = \frac{
\begin{Vmatrix}
x_{C} - x_{A} & y_{C} - y_{A} & z_{C} - z_{A} \\
x_{B} - x_{A} & y_{B} - y_{A} & z_{B} - z_{A} \\
x_{D} - x_{C} & y_{D} - y_{C} & z_{D} - z_{C}
\end{Vmatrix}
}{
\sqrt{
\begin{vmatrix}
y_{B} - y_{A} & z_{B} - z_{A} \\
y_{D} - y_{C} & z_{D} - z_{C}
\end{vmatrix}^2 +
\begin{vmatrix}
z_{B} - z_{A} & x_{B} - x_{A} \\
z_{D} - z_{C} & x_{D} - x_{C}
\end{vmatrix}^2 +
\begin{vmatrix}
x_{B} - x_{A} & y_{B} - y_{A} \\
x_{D} - x_{C} & y_{D} - y_{C}
\end{vmatrix}^2
}
}
\end{equation}
}
但是这样还有个小问题,如果你注意看我用红笔标出来的地方,
y
B
y_B
yB和
y
A
y_A
yA,这个下标会不会显得太大了?有点丑哦,如果A
和B
能再小一点就更好了。
参考博客Latex中改变下标的字体尺寸
采用最简洁的做法,我们在导言区添加一条\let\sss= \scriptscriptstyle
,然后在需要让下标变小的地方,如y_B
,使用y_{\sss B}
即可。完整代码如下:
\let\sss= \scriptscriptstyle
\singlecolumn{
\begin{equation}
\label{eq5}
L_{NM} = \frac{
\begin{Vmatrix}
x_{\sss C} - x_{\sss A} & y_{\sss C} - y_{\sss A} & z_{\sss C} - z_{\sss A} \\
x_{\sss B} - x_{\sss A} & y_{\sss B} - y_{\sss A} & z_{\sss B} - z_{\sss A} \\
x_{\sss D} - x_{\sss C} & y_{\sss D} - y_{\sss C} & z_{\sss D} - z_{\sss C}
\end{Vmatrix}
}{
\sqrt{
\begin{vmatrix}
y_{\sss B} - y_{\sss A} & z_{\sss B} - z_{\sss A} \\
y_{\sss D} - y_{\sss C} & z_{\sss D} - z_{\sss C}
\end{vmatrix}^2 +
\begin{vmatrix}
z_{\sss B} - z_{\sss A} & x_{\sss B} - x_{\sss A} \\
z_{\sss D} - z_{\sss C} & x_{\sss D} - x_{\sss C}
\end{vmatrix}^2 +
\begin{vmatrix}
x_{\sss B} - x_{\sss A} & y_{\sss B} - y_{\sss A} \\
x_{\sss D} - x_{\sss C} & y_{\sss D} - y_{\sss C}
\end{vmatrix}^2
}
}
\end{equation}
}
效果如下:
在没有模板的情况下, 我们切换单双栏采用IEEE
的做法
\newcounter{mytempeqncnt}
\begin{figure*}[!t]
% ensure that we have normalsize text
\normalsize
% Store the current equation number.
\setcounter{mytempeqncnt}{\value{equation}}
% Set the equation number to one less than the one
% desired for the first equation here.
% The value here will have to changed if equations
% are added or removed prior to the place these
% equations are referenced in the main text.
\setcounter{equation}{5}
\begin{equation}
\label{eqn_dbl_x}
x = 5 + 7 + 9 + 11 + 13 + 15 + 17 + 19 + 21+ 23 + 25
+ 27 + 29 + 31
\end{equation}
\begin{equation}
\label{eqn_dbl_y}
y = 4 + 6 + 8 + 10 + 12 + 14 + 16 + 18 + 20+ 22 + 24
+ 26 + 28 + 30
\end{equation}
% Restore the current equation number.
\setcounter{equation}{\value{mytempeqncnt}}
% IEEE uses as a separator
% \hrulefill
% The spacer can be tweaked to stop underfull vboxes.
\vspace*{4pt}
\end{figure*}