本文针对overleaf在线使用latex的情况编写。
文章目录
- 文档结构
- 要点
- 导入图片
- 使用表格
- 添加引用
- 参考资料
文档结构
- 文档类型设置
\documentclass[12pt,article]{book} % []中设置文档格式,文档字体大小默认为10pt,article指定文档用纸类型,其他常用类型还包括a4paper、legalpaper;
% {}设置文档类型,常用类型包括book,report,article
- 添加作者
\author{wangzai}\thanks{thanks **}
- 添加日期
\date{\today} % 设置写作的具体日期,\today显示今天的日期
- 文档体
latex中正文内容需要被document
包裹起来,类似html中的body标签的作用,如下:
\begin{document}
\end{document}
- 添加标题
latex中添加标题需要两个设置:
1)文档(document)前设置标题名称
\title{Latex quickstart tutorial} % 设置标题名称
该内容设置在\begin{document}
前。
2) 文档(document)中添加标题
\maketitle % 添加标题
该内容被\begin{document} \end{document}
包裹。
- 添加摘要
\begin{abstract}
the is abstract
\end{abstract}
- 添加目录
\tableofcontents
- 添加章节
\chapter{chp1 name}
章节和小节一般不在同一个文档中重复使用。
- 添加小节
\section{section1 text} % latex会自动给文档中的小节编号
\subsection{subsection name}
\section*{section without number} % \section*{}表示该小节取消数字编号
- 添加段落
\paragraph{paragraph1}
\subparagraph{subparagraph 1}
要点
- 无序要点
\begin{enumerate} % enumerate显示无序要点
\item the enumerate denotes the ordered item
\item where you can see item is the same
\end{enumerate}
- 有序要点
\begin{itemize} % itemize显示有序要点
\item the itemize include unordered list
\item the figure
\end{itemize}
导入图片
latex中导入图片分三个要设置的内容:
1)导入图片包:
\usepackage{graphicx}% LaTeX package to import graphics
2) 指定图片在overleaf环境下的目录路径:
\graphicspath{{image/}} % configuring the graphicx package, {image/} is the image folder
- 文章部分指定图片相对路径载入图片:
\includegraphics{image/linuxroadmap.png} % {} is the relative path of image
若要设置图片显示的格式,可通过{figure}包括includegraphics的方式设置:
\begin{figure}
\centering % 设置对齐方式
\includegraphics[width=0.85\textwidth]{image/linuxroadmap.png}
% 设置图片宽度为文本宽度的0.85
\caption{this is the figure title} % 设置图片标题
\label{fig:fig1} % 设置图片标签
\end{figure}
设置了标签的图片,后文可以通过\ref
引用,如:
There's a picture reference \ref{fig:fig1}
使用表格
表格通过\begin{tabular}
,\end{tabular}
的方式导入:
\section{tables}
\begin{center} % 设置表格居中
\begin{tabular}{|c |r l} % {}设置单元格对齐方式,c表示居中,r表示向右对齐,l表示向左对齐
\hline\hline % 添加横线,一个\hline表示表格对应位置添加一个横线
cell1&cell2&cell3\\ % \\表示换行;&表示分隔单元格
cell1&cell2&cell3\\
cell1&cell2&cell3\\
\hline
\end{tabular}
\end{center}
效果如图所示:
添加引用
latex中引用要输入四个命令:
1)
\usepackage{biblatex} % 导入引用包
\addbibresource{sample.bib} %导入要引用的参考文献的引文数据
\cite{einstein} % 在文档中引用
\printbibliography % 生成引文
参考资料
- overleaf30分钟latex入门教程:https://www.overleaf.com/learn/latex/Learn_LaTeX_in_30_minutes
- NIPS提交论文的latex格式源码: https://neurips.cc/Conferences/2014/PaperInformation/StyleFiles
- overleaf document : https://www.overleaf.com/learn
- https://www.overleaf.com/learn/latex/Bibliography_management_in_LaTeX