Latex使用笔记
笔者最近开始使用latex编辑文档,此处记录一下latex的使用过程中一些值得记录的点。
Latex安装
latex安装网上教程很多,笔者参考TeX Live2018_latex安装教程 安装成功,未安装图形化界面; latex还有一个多人共享的编辑网站overleaf ,这个网站可以实时多人共同编译一个latex文件,需要把文档需要的图片等都上传,并能方便的online编译以及下载最终完成的project和生成的PDF文件。
Latex使用语法记录
此处记录下使用过程中一些零散搜集的语法,以备查阅。 1、\usepackage{xxxx}: 调用的一些包要在文档开头声明 2、
✓
\checkmark
✓ : \checkmark 3、
文本加粗
\textbf{文本加粗}
文本加粗 : \textbf,公式里面的加粗要用 \bm 4、
x
2
1
x^{1}_{2}
x 2 1 : 上下标x^{1}_{2} 5、标题:\section, \subsection, \subsubsection 6、图片、标题、公式等都可以加label,然后使用\ref引用指定的内容 7、参考文献使用txt,将百度学术或者谷歌学术的BibTex内容复制进txt后,将后缀更改为.bib,然后使用\cite{BibTex内容开头的名字}引用,最后要在文章末尾加上\bibliography{.bib的名字}。编译的时候先运行一次pdfLatex(不同编译器不同,笔者用的是TeX Live),再运行一次BibTex,再运行两次pdfLatex即可。 8、插入表格代码示例:
// Using figure in Latex
\begin{ figure} [ ! t]
\centerline{ \includegraphics[ width= \columnwidth] { figure. jpg} }
\caption{ figure description}
\label{ fig_label}
\end{ figure}
9、\emph{i}:变成斜体 10、
y
x
\frac{y}{x}
x y :分式表示 \frac{y}{x} 11、
x
^
\hat{x}
x ^ : 加帽子\hat{x} 12、插入公式代码示例:flalign表示&标注的位置左对齐,split表示\的位置换行。
// equation
\begin{ flalign}
\begin{ split}
& xxx = \\
& xxx\label{ equation_label} }
\end{ split}
\end{ flalign}
13、
∘
\circ
∘ : 圆圈 \circ 14、
⋅
\cdot
⋅ :点乘 \cdot 15、
x
\sqrt{x}
x
: 根号 \sqrt 16、希腊字母表:latex希腊字母表 17、注释 %
Latex表格格式
latex使用表格比较麻烦,这里简单给出几个使用过程中用到的样式。
简单三线表
// 三线表
\begin{ table} [ ! t]
\caption{ xxxxxxx. }
\label{ xxxxx}
\centering
\begin{ tabular} { ccccc}
\toprule{ Method}
& AArTRE & MArTRE & Time ( s) \\
\midrule
baseline & xxx & xxx & xxx \\
xxx & xxx & xxx & xxx \\
xxx & xxx & xxx & xxx \\
xxx & xxx & xxx & xxx \\
\bottomrule
\end{ tabular}
\begin{ tablenotes}
\item[ 1 ] xxx
\end{ tablenotes}
\end{ table}
复杂表头三线表
// 复杂三线表跨双栏居中
\begin{ table* } [ htbp]
\caption{ xxx}
\label{ xxx}
\centering
\begin{ tabular} { cccccccccccccccccccccccccccccccccccccccccccccc}
\toprule
\multicolumn{ 2 } { c} { \multirow{ 2 } * { Method} } & \multicolumn{ 2 } { c} { xxx} & \multicolumn{ 2 } { c} { xxx} & \multicolumn{ 2 } { c} { xxx} & \multicolumn{ 2 } { c} { xxx} & \multicolumn{ 2 } { c} { \multirow{ 2 } * { Avg Time} } \\
\multicolumn{ 2 } { c} { } & Average& Median& Average& Median& Average& Median& Average& Median& \multicolumn{ 2 } { c} { } \\
\midrule
\multicolumn{ 2 } { c} { xxx} & xxx& $\textbf{ xxx} $& xxx& $\textbf{ xxx} $& xxx& $\textbf{ xxx} $& xxx& $\textbf{ xxx} $& \multicolumn{ 2 } { c} { xxx} \\
\bottomrule
\end{ tabular}
\begin{ tablenotes}
\item[ 1 ] xxx
\end{ tablenotes}
\end{ table* }
// 复杂三线表单栏居中
\begin{ table} [ ! t]
\caption{ xxx}
\label{ xxx}
\centering
\begin{ tabular} { cccccc}
\toprule
\multirow{ 2 } * { Threshold} & \multicolumn{ 2 } { c} { xxx} & \multicolumn{ 2 } { c} { xxx} \cr
\cmidrule ( lr) { 2 - 5 }
& AArTRE & MMrTRE & AArTRE & MMrTRE\cr
\midrule
xxx & xxx & xxx & xxx & xxx \\
\bottomrule
\end{ tabular}
\end{ table}
Latex使用其他注意事项
使用Tex Live编译时,有时会出现 File ended while scanning use of @writefile的问题。 解决方法:删除编译文件夹内.aux扩展名结尾的文件,重新用Latex命令进行编译,自动生成正确的aux文件,完成错误的修复。如果还不行,就把除.tex以外的文件均删除掉,如:.bbl,.blg,.dvi,.log等