前言

使用对象:Latex入门初学者。
博客内容概述:
Latex作为撰写论文的工具,深受广大科研工作者的喜爱,本文为个人的Latex入门总结,特此记录。


一、Latex和Word的优缺点对比

在这里插入图片描述
知乎高赞:LaTex 比 Word 好在哪?

二、Latex项目组成文件格式

以IEEE的Latex模板为例,进行介绍。IEEE的Latex的模板在网站http://ras.papercept.net/conferences/support/tex.php中可下载。其一为latex文档压缩包,其一为bibtex参考文献压缩包。

.tex文件,为论文正文文件;下面代码为latex的开头部分,关于设置论文格式,使用包,题目和感谢的内容。

\documentclass[letterpaper, 10 pt, conference]{ieeeconf}  % Comment this line out if you need a4paper

%\documentclass[a4paper, 10pt, conference]{ieeeconf}      % Use this line for a4 paper

\IEEEoverridecommandlockouts                              % This command is only needed if 
                                                          % you want to use the \thanks command

\overrideIEEEmargins                                      % Needed to meet printer requirements.

\usepackage[T1]{fontenc}                                  % LaTeX Error: Command \DH unavailable in encoding OT1.

% The following packages can be found on http:\\www.ctan.org
\usepackage{graphicx} % for pdf, bitmapped graphics files
%\usepackage{epsfig} % for postscript graphics files
%\usepackage{mathptmx} % assumes new font selection scheme installed
%\usepackage{times} % assumes new font selection scheme installed
\usepackage{amsmath} % assumes amsmath package installed, for equation aligned
%\usepackage{amssymb}  % assumes amsmath package installed
%\setcounter{secnumdepth}{4} %subsubsection
\usepackage{pdfcomment} % PDF document contents

\title{\LARGE \bf
Cloth Manipulation
}

\author{XXX$^{1}$% <-this % stops a space
\thanks{*This work was not supported by any organization}% <-this % stops a space
%\thanks{$^{2}$Bernard D. Researcheris with the Department of Electrical Engineering, Wright State University,
%        Dayton, OH 45435, USA
%        {\tt\small b.d.researcher@ieee.org}}%
}

\begin{document}

.eps文件,为latex指定的图片插入格式;在导入图片之前,最好将图片先转换为.eps格式文件;

.bib文件,为参考文献的一种格式;在百度学术以及Google学术均可一键获取引用对应文献的bib格式代码。

.bst为参考文献的格式文件;

以上格式中内容还会在下文中介绍。


三、Latex插入图片

向LaTeX插入图片的时候,一直使用.jpg格式,编译出来效果很不好,稍微放大就显得很模糊。后来采用.eps(Encapsulated Post Script)格式的图片,因为是矢量图,即使放大也不会失真,效果很好,推荐使用。

jpg/png格式图片转eps格式的方法总结
http://blog.sina.com.cn/s/blog_5410e7b50101lme2.html

Overleaf——LaTeX插图命令使用教程
https://zhuanlan.zhihu.com/p/143529262

一般情况下我们很少会把图片直接插入到我们的文本当中,而是会使用浮动体的格式。浮动体的环境为figure,如下述代码所示。

\begin{figure}[htbp]
  \centering
  \includegraphics[scale=0.3]{figs/1introduction.eps}
  \caption{Inductance of oscillation winding on amorphous magnetic core versus DC bias magnetic field}
  \label{introduction}
\end{figure}
  • figure表示图片是浮动的;后面加*号表示打通排版;
  • htbp表示图片的排版是自动排版;h–here; t–top; b–bottom; p–page;
  • centering表示居中显示 ;
  • scale设置缩放比例;其后为指定的文件路径;
  • caption为图注;
  • label为自定义的标签,用于在正文中引用的时候使用;

在正文中引用图片的编号方式为如下,此处的introduction即为自定义的标签。

Fig. \ref{introduction} shows a scene wherein shoes are being packaged. 

Latex自带画图宏包。
科研画图都用什么软件?
https://www.zhihu.com/question/29557377/answer/99175627
LaTeX—Tikz 宏包入门使用教程
https://zhuanlan.zhihu.com/p/127155579
http://pgfplots.sourceforge.net/gallery.html

四、Latex插入公式

插入公式包括行内公式和行间公式

行内公式的插入:

$F_f \leq F_N \mu_1$

中文显示为: F f ≤ F N μ 1 F_f \leq F_N \mu_1 FfFNμ1

行间公式的插入:

\begin{equation}\label{eq4}
    F_f + F_{in} = F_{\tau}
\end{equation}

正文显示为:
F f + F i n = F τ F_f + F_{in} = F_{\tau} Ff+Fin=Fτ

五、Latex插入参考文献

在插入参考文献之前,首先要将所要引用的参考文献.bib引用格式代码复制到.bib文件中,如下述代码所示为一篇文献的.bib引用格式代码,其中第一行大括号后面的“yin2021modeling”表示这篇文献的标签,便于后面在正文中引用这篇文献。

@article{yin2021modeling,
  title={Modeling, learning, perception, and control methods for deformable object manipulation},
  author={Yin, Hang and Varava, Anastasia and Kragic, Danica},
  journal={Science Robotics},
  volume={6},
  number={54},
  year={2021},
  publisher={Science Robotics}
}

在Latex

\bibliographystyle{./IEEEtran} % use IEEEtran.bst style
\bibliography{./IEEEabrv,./IEEEexample}

\end{document}

在正文中引用参考文献的方式如下,yin2021modeling为要引用的参考文献的标签。

\cite{yin2021modeling}

六、Latex生成带目录PDF文档

这里只给出一种方法,在正文开始之前加上如下代码片段:

\usepackage{pdfcomment} % PDF document contents

七、Latex的error整理

error1:
[Latex] Command \DH unavailable in encoding OT1
https://www.jianshu.com/p/7832e477ce09
前文部分添加\usepackage[T1]{fontenc}

error2:
Latex “Paragraph ended before \Gin@iii was complete” — solution
It hapens when simply inserting a figure. Solution is to change the package from {graphics} to {graphicx}.

总结

以上就是今天要讲的内容,本文仅仅简单介绍了latex的使用,而更多的关于latex的使用方法在写作时,边学边用,效率更高。

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐