main.tex 文件:用于存放所有文档编辑的代码
1.序言部分preamble:文档的类别(类型)以及具体的细节
- \documnetclass[12pt,letterpaper]{article} 创建文档类(定义字体大小和页面类型)
- \usepackage{graphicx} 定义想要使用的加载包
- \title{My first LaTeX document} 定义文章名
- \author{Luck-leaf\thanks{Funded by the Overleaf team.}} 定义作者(感谢机构)
- \date{March 2023} 定义日期
2.正文部分
\begin{document}
\begin{abstract} 摘要
comment
\end{abstract}
\section{Introduction} 1.1
\section{Second Section} 1.2
\subsection{First Subsection} 1.2.1
\section*{Unnumbered Section} 无标号节
\end{document}
如下图所示:
- recompile 将修改结果更新到overleaf右侧
- \maketitle 命令位于正文中,排版主题作者和日期
文本部分
- \textbf{…} 加粗
- \textit{…} Italics
- \underline{…} 下划线
- \emph{argument} 取决于上下文,强调某部分
- 新建段落:按两次 "enter "键创建一个新段落,结束当前行并插入一个后续的空行;在不开始新段落的情况下,通过使用\命令插入手动换行,也就是双反斜杠来开始新的一行;或者,使用\newline命令。
图像部分
如果想在文档中引入图片,我们需要在project中新建一个文件夹用于专门存放图片。
在代码中,首先在序言部分添加:
- \usepackage{graphicx} 引入图像包
- \graphicspath{{images/}} 给定图像文件夹所在的路径 !!!注意路径这里有两层大括号
- 正文中输入命令即可显示图像\includegraphic{image name}
- 添加题注
\begin{figure}[h]
\centering
\includegraphics[width=0.75\textwidth]{mesh}
\caption{A nice plot.}
\label{fig:mesh1}
\end{figure} - 文中引用图像和图像所在页数:As you can see in figure \ref{fig:mesh1}, the function grows near the origin. This example is on page \pageref{fig:mesh1}.
有序或无序列表
添加列表采用命令 \item
- 无序列表命令格式
\begin{itemize}
\item comment1
\item comment2
\end{itemize} - 有序列表命令格式
\begin{enumerate}
\item comment1
\item comment2
\end{enumerate}
数学公式
\usepackage{amsmath}% For the equation* environment
- 行内嵌入公式:
( … ),
$ … $
\begin{math} … \end{math} - 单行公式:
[ … ],
\begin{displaymath} … \end{displaymath}
\begin{equation} … \end{equation} - 其他(项与项之间用空格分隔,每个独立个体超过两个字符就加{})
下标用_
上标用^
点点点用 \dots
积分号用 \int
上下形式的分数 \frac
罗马数字 \alpha \beta \delta \omega
正余弦及对数函数 \sin \cos \log
表格部分
- Table \ref{table:data} 在文中引用表格名称
- 具体表格设置举例
\begin{table}[h!]
\centering 每列中的文字必须居中
\begin{tabular}{||c c c c||} 表明表格有三列,。你也可以用r来右对齐文本,用l来左对齐文本。
\hline
Col1 & Col2 & Col2 & Col3 \ [0.5ex]
\hline\hline
1 & 6 & 87837 & 787 \
2 & 7 & 78 & 5415 \
3 & 545 & 778 & 7507 \
4 & 545 & 18744 & 7560 \
5 & 88 & 788 & 6344 \ [1ex]
\hline
\end{tabular}
\caption{Table to test captions and labels.} 表格标签
\label{table:data}
\end{table}
注意:
对齐符号&用于划分表格行中的各个单元
新行命令\\结束表格
\hline 为水平规则,明确当前位置有横向横线划分上下表格行
\begin{tabular}{||c c c c||} 其中的|为垂直规则,表明当前位置有竖线划分表格左右列
参考:overleaf学习
文中出现图片均引自该链接