LaTeX常用操作快速上手

什么是LaTeX

  • LaTeX(/ˈlɑːtɛks/,常被读作/ˈlɑːtɛk/或/ˈleɪtɛk/,写作“LATEX”),是一种基于TEX的排版系统,由美国计算机科学家莱斯利·兰伯特在20世纪80年代初期开发,利用这种格式系统的处理,即使用户没有排版和程序设计的知识也可以充分发挥由TEX所提供的强大功能,不必一一亲自去设计或校对,能在几天,甚至几小时内生成很多具有书籍质量的印刷品。对于生成复杂表格和数学公式,这一点表现得尤为突出。因此它非常适用于生成高印刷质量的科技和数学、物理文档。这个系统同样适用于生成从简单的信件到完整书籍的所有其他种类的文档。

  • LaTeX遵循呈现与内容分离的设计理念,以便作者可以专注于他们正在编写的内容,而不必同时注视其外观。在准备LaTeX文档时,作者使用章(chapter)、节(section)、表(table)、图(figure)等简单的概念指定文档的逻辑结构,并让LaTeX系统负责这些结构的格式和布局。因此,它鼓励从内容中分离布局,同时仍然允许在需要时进行手动排版调整。

LaTeX环境配置

  • 本地:本地推荐使用 TeXstudio(前端编辑器) + MiKTeX (后端开源工具包)。
  • 在线: 强烈推荐Overleaf,其中囊括了大量的期刊模板,可以快速开始草稿的撰写,并且可以与包括IEEE,Springer, Taylor & Francis在内的等多家出版社的投稿系统对接,可以实现一键投稿(我没这么干过 哈哈哈)。

论文LaTeX模板下载

  • 一般去期刊投稿网站上都有。例如我常用的是IEEE的模板:IEEE 会议模板,IEEE 期刊模板。
  • 下载好之后,一般包含4个文件, 举例:
conference.pdf  //tex文件编译后的pdf
conference.tex  //正文tex文件
IEEEtran.cls  //LaTeX Class文件
IEEEtran_HOWTO.pdf  //IEEEtran.cls的使用方法

cls文件

  • cls文件是latex格式文件,它决定了latex源文件的排版布局。最一般的cls文件就是我们常用的article.cls,这表现在\documentclass{article}这一句里面。如果出版方提供了cls文件,我们可以下面两个方法使用(假如cls文件名为xxx.cls):
    cls文件和你自己的latex文件放到同一个文件夹里面,在源文件里面用 \documentclass{xxx}

宏包

  • 查找宏包 http://www.ctex.org/documents/packages/
  • 举例:
\usepackage{cite}%引用
\usepackage{graphicx}%图片
\usepackage{subfigure}%有小图
\usepackage{amsmath,bm}%数学公式+加粗
\usepackage{flushend}%解决最后一页两边不平衡问题

%针对黄色高亮
\usepackage{color, soul} 
\soulregister\cite7 % 针对\cite命令
\soulregister\citep7 % 针对\citep命令
\soulregister\citet7 % 针对\citet命令
\soulregister\ref7 % 针对\ref命令
\soulregister\pageref7 % 针对\pageref命令

%算法流程图
\usepackage{algorithmicx,algorithm}
\usepackage[noend]{algpseudocode}

%跨行跨列表格
\usepackage{makecell}
\usepackage{multirow}

一个最简单的LaTeX示例

\documentclass{article}

\begin{document}

\begin{abstract} %摘要
I am abstract.
\end{abstract}

\begin{IEEEkeywords}%关键词
Camera model......
\end{IEEEkeywords}

\section{introduction}  %建立新的章节
\label{sec:intro}    %章节的label,方便被引用
I am very happy.    %正文文本

\subsection{subA}    %建立子章节
OK.This is \ref{sec:intro}   %引用章节

\end{document}

添加参考文献

  • 可以使用这个bib文件管理所有的参考文献,例如我使用的ref.bib。则可以在正文末尾添加:
\bibliographystyle{IEEEtran} %参考文件格式
\bibliography{ref}%bib文件名

ref.bib文件保存所有的要引用参考文献的信息,可以从谷歌学术、百度学术、各期刊网站导出。例如:

@article{corke2007simple,
    title={A simple and systematic approach to assigning Denavit--Hartenberg parameters},
    author={Corke, Peter I},
    journal={IEEE transactions on robotics},
    volume={23},
    number={3},
    pages={590--594},
    year={2007},
    publisher={IEEE}
}
@inproceedings{aghakhani2013task,
    title={Task control with remote center of motion constraint for minimally invasive robotic surgery},
    author={Aghakhani, Nastaran and Geravand, Milad and Shahriari, Navid and Vendittelli, Marilena and Oriolo, Giuseppe},
    booktitle={2013 IEEE international conference on robotics and automation},
    pages={5807--5812},
    year={2013},
    organization={IEEE}
}
@book{corke2017robotics,
    title={Robotics, vision and control: fundamental algorithms in MATLAB{\textregistered} second, completely revised},
    author={Corke, Peter},
    volume={118},
    year={2017},
    publisher={Springer}
}
@misc{LabelImg,
    author = {Tzutalin},
    year = {2015},
    url = {https://github.com/tzutalin/labelImg},   
    title = {LabelImg}
}

在文中引用的话,只需\cite{corke2017robotics},如果一次进行多个引用,可以用逗号隔开。例如\cite{corke2017robotics,LabelImg,aghakhani2013task}

  • 添加图片
  1. 单个图片
\begin{figure}
    \centering
    \includegraphics[width=1\linewidth]{image/cameramodel}
    \caption{The principle of pinhole camera model.}
    \label{fig:cameramodel}
\end{figure}
  1. 一排2张图片
\begin{figure}
    %   \includegraphics[width=1\linewidth]{image/image3}
    \begin{minipage}[t]{0.5\linewidth}
        \centering
        \subfigure[]{
            \label{Tracking an instrument}
            \includegraphics[width=0.9\textwidth]{image/1}}
        
    \end{minipage}%
    \begin{minipage}[t]{0.5\linewidth}
        \centering
        \subfigure[]{
            \label{Tracking two instruments}
            \includegraphics[width=0.9\textwidth]{image/2}}
        
    \end{minipage}
    \caption{Tracking schematic diagram. (a) Tracking an instrument. (b) Tracking two instruments.}
    \label{fig:tracking1}
\end{figure}
  1. 2排每排2个
\begin{figure}
    \begin{minipage}[t]{0.5\linewidth}
        \centering
        \subfigure[]{
            %\label{sim2stj1}
            \includegraphics[width=1\textwidth]{image/Vmax/distance}}
        
    \end{minipage}%
    \begin{minipage}[t]{0.5\linewidth}
        \centering
        \subfigure[]{
            %   \label{s2_distance}
            \includegraphics[width=1\textwidth]{image/Vmax/trj}}
        
    \end{minipage}
    \begin{minipage}[t]{0.5\linewidth}
        \centering
        \subfigure[]{
            %\label{sim2stj1}
            \includegraphics[width=1\textwidth]{image/Vmax/speed}}
        
    \end{minipage}%
    \begin{minipage}[t]{0.5\linewidth}
        \centering
        \subfigure[]{
            %   \label{s2_distance}
            \includegraphics[width=1\textwidth]{image/Vmax/camera}}
        
    \end{minipage}
    \caption{Performance comparison. (a) Distance between the projection point and the image center. (b) Pixel trajectory of the projection point. (c) Camera speed. (d) Camera trajectory.}
    \label{Vmax}    
\end{figure}

以此类推

插入表格

  • 普通表格
\begin{table}[!t]

% increase table row spacing, adjust to taste
\renewcommand{\arraystretch}{1.3}
\caption{\hl{The parameters settings of each simulation}}
\label{table_II}
\centering
% Some packages, such as MDW tools, offer better commands for making tables
% than the plain LaTeX2e tabular which is used here.
\begin{tabular}{ccccc}%c表示居中,l表示左对齐,r表示右对齐(c|c|:这种方式可以添加竖线)
    \hline\hline%添加横线
        \rowcolor{yellow}\textbf{Section}   & $\bm{V_{max}}$\textbf{(mm/s)} &$\bm{R}$\textbf{(pixel)}&$\bm{r}$\textbf{(pixel)}&  $\bm{K}$\\ 
    \hline
        \rowcolor{yellow}Section IV.A&50,100,200&300&20&0.08\\ 
    \hline 
    \rowcolor{yellow}Section IV.B&300&150,200,300&20&0.1\\ 
    \hline 
    \rowcolor{yellow}Section IV.C&100&300&20,80,150&1\\ 
    \hline 
    \rowcolor{yellow}Section IV.D&100&300&150&0.3,1,10\\ 
    \hline \hline
\end{tabular} 
\end{table}
  • 跨行表格
    使用宏包\usepackage{multirow}
\begin{table}
    \centering
    \begin{tabular}{|c|c|c|c|}
        \hline
        \multirow{2}*{合并两行一列} & 二 & 三 & 四 \\
        ~ & 2 & 3 & 4 \\
        \hline
    \end{tabular}
\end{table}
  • 跨列表格
    合并1行多列可以使用\multicolumn{cols}{pos}{text}来实现
\begin{table}
    \centering
    \begin{tabular}{|c|c|c|c|}
        \hline
        \multicolumn{2}{|c|}{合并一行两列} & 三 & 四 \\
        \hline
        1 & 2 & 3 & 4 \\
        \hline
    \end{tabular}
\end{table}

对于部分期刊,如IEEE,有双栏的情况,如果希望跨栏,则将{table}环境修改为{table*}即可;

公式

  • 插入行内公式
    $A=B+C$
  • 插入行间公式
\begin{equation}
   \label{eq1}
   a^2=b^2+c^2
\end{equation}

^:上标
_:下标
\bm:加粗
\dot:字母上面加点
\|:绝对值
\frac{分子}{分母}:分数
\leq:小于等于
\geq:大于等于
\sum_{}^{}:求和
\lim\limits_{xx\to +\infty}:取极限xx到正无穷
\sqrt开根号
\exitst:存在
\forall:对于任意

  • 插入矩阵:
\begin{equation}
\bm{T}_{EEF}^0=\left[\begin{array}{cccc}
0& -1 & 0 & 250 \\ 
-1& 0 & 0 & -250 \\ 
0& 0 & -1 & 50 \\ 
0& 0 & 0 & 1
\end{array} \right].
\end{equation}
  • 常用希腊字母

更多内容请参考常用数学符号的 LaTeX 表示方法


  • Spring期刊参考文献格式
  1. spbasic.bst文件中1571行和1624行的两个SORT,默认是开启的,代表文章后面参考文献列表是按作者名字首字母和年份排序的。如果用%%将其屏蔽代表参考文献是按引用的顺序排序的。

\usepackage{natbib}

\bibliographystyle{spbasic.bst}

句首引用的时候用citet{} 句末引用的时候用(citealt{})

特殊字符

image.png

俄语的输入

% !TeX program = pdfLaTeX
% !TeX encoding = UTF-8
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}

\begin{document}

\section{Русский язык}
Русский язык

\end{document}

你可能感兴趣的:(LaTeX常用操作快速上手)