LaTeX小白入门及IEEE模板

老师要求用LaTeX写一版,故此开始学习LaTeX。

IEEE模板

因为发表IEEE论文,将模板附在此,使用overLeaf更方便。

排版代码块

一个文档基本由这样的结构构成

\documentclass{article}                %文件类型
\title{Title} %文件标题
\begin{document} %文档从此开始
\maketitle %构建标题命令
Hello world!, Let's start \LaTeX %普通文本
\end{document} %文件结束

作者

\renewcommand\Affilfont{\itshape\small}
\author[1]{Hao~Wang, Sherleen~Zhu \thanks{Happy everyday}}%
\author[2]{Turling Burling}
\affil[1]{Hefei University of Technology}
\affil[2]{University of Pittsburgh}
\maketitle

效果如下:

段落

摘要

\begin{abstract}
I am abstract
\end{abstract}

关键词

\begin{IEEEkeywords}
I am keywords
\end{IEEEkeywords}

小标题

小标题有依据的层级不同,包\section{},\subsection{},\subssubection{}等:

\section{Introduction}
\subsection{Overview of the proposed method}

附录

\section*{Acknowledgement}
\section*{Appendix}

分为列表和表格。

列表

包括无序号列表和有序号列表。

无序号列表

\begin{itemize}
\item item 1
\item item 2
\end{itemize}

效果:

有序号列表

\begin{enumerate}
\item item 1
\item item 2
\end{enumerate}

效果:

表格

三线表格

使用\hline命令来增加横线:

\begin{table}[]
\begin{tabular}{ c c c }
\hline
cell1 & cell2 & cell3 \\
\hline
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\hline
\end{tabular}
\end{table}

效果:

网格表格

只需要增加竖向内容控制符即可。
当还需要合并表格单元格时,使用\multicolumn或者\multirow来控制单元格,后接需要合并的行或者列数(如这里的{2}),之后再跟上控制内容(如这里的{|c|}和{*}),最后紧接着单元格内容。
注意,当使用了列合并时,一定要使用\usepackage{multirow}包,并控制合并行的线条,否则会出现渲染错误的问题。

\begin{table}[]
\begin{tabular}{|c|c|c|} %控制表格对其方式
\hline %划线
\multicolumn{2}{|c|}{cell1} & cell3 \\ \hline %合并行
cell4 & cell5 & \multirow{2}{*}{cell6} \\ \cline{1-2} %合并列,注意使用了\cline来控制合并后的线条
cell7 & cell8 & \\ \hline
\end{tabular}
\end{table}

效果:

标题及标签

对于表格而言,我们还需要的是标题和标签,以在正文中引用,我们使用\caption{}\lable{}来控制内容,注意只能将captionlabel标签放置于tabular结构体外部。

\begin{table}[]
\caption{I am sample table} %显示在表格上的标记
\label{tab1sample} %用于正文引用的标签
\begin{tabular}{|c|c|c|}
\hline
\multicolumn{2}{|c|}{cell1} & cell3 \\ \hline
cell4 & cell5 & \multirow{2}{*}{cell6} \\ \cline{1-2}
cell7 & cell8 & \\ \hline
\end{tabular}
\end{table}

效果:

调整表格和标题居中,可以使用\centering命令开控制{tabular}结构体:

\begin{table}[]
\caption{I am sample table}
\label{tab1sample}
\centering
\begin{tabular}{|c|c|c|}
\hline
\multicolumn{2}{|c|}{cell1} & cell3 \\ \hline
cell4 & cell5 & \multirow{2}{*}{cell6} \\ \cline{1-2}
cell7 & cell8 & \\ \hline
\end{tabular}
\end{table}

效果:

如果在正文中使用了表格,就以~\ref{label}方式来实现引用,如:

I will ref the table here~\ref{tab1sample}

效果如下:

在这里插入图片描述

图片

将所有的图都放到一个位置(如:pic文件夹),同时我们仍然可以使用\centering控制居中。当我们加载一个图片时,可以使用\includegraphics[大小控制]{图片源}来控制显示图片。

\begin{figure}[!t]
\centering
\includegraphics[width=1.13in]{pic/1-1}
\caption{I am sample figure.}
\label{fig1sample}
\end{figure}

脚注

可以使用\footnote命令来实现,如下所示:

\footnote{Hope must come true}.

效果如下:

算法

以algorithmic为例,注意包需要首先使用\usepackage{algorithm}包:

\begin{algorithm}
\caption{How to write algorithms}
\label{algo2}
\begin{algorithmic}[H]
\REQUIRE this text
\ENSURE how to write algorithm with \LaTeX
\WHILE{not at end of this document}
\STATE read current
\IF {understand}
\STATE go to next section
\STATE current section becomes this one
\ELSE
\STATE go back to the beginning of current section
\ENDIF
\ENDWHILE
\label{Algorithmsample}
\end{algorithmic}
\end{algorith

效果:

公式

行内公式

定义行内公式,使用$$即可如下:

I am a inline equation $a=b+c$

效果如下:

行间公式

对于多行公式则可以考虑使用equation环境来实现,同样可以使用label标签来实现引用

I am a inline equation $a=b+c$, and I am display equation: 
\begin{equation}
\label{eq1}
a^2=b^2+c^2
\end{equation}

效果如下:

带序号公式使用\( \),不带序号公式使用\[ \]

we can get a no number display equation:
\[ a^2=b^2+c^2\] I am an equation.
\(a^3=b^3+c^3\) ,Wow, me too

效果:

参考文献

在文件头部添加\usepackage{cite}后,使用bbl形式构建参考文献。

\begin{thebibliography}{1}
\bibitem{citekey}
H.~Kopka and P.~W. Daly, \emph{A Guide to \LaTeX}, 3rd~ed.\hskip 1em plus
0.5em minus 0.4em\relax Harlow, England: Addison-Wesley, 1999.
\end{thebibliography}

使用时,可以在正文如此引用:

Here, we will cite a reference~\cite{citekey}

效果如下:

其他命令

  1. 换行:\\
  1. 另起一段:\par

  2. 块内公式:$$$…$$$

------ 本文结束感谢您的阅读 ------