Latex + Overleaf 论文写作新手笔记

Overleaf 的项目是由一个或多个 .tex 文件和其他相关的文件组成的

Overleaf 官方教程

.tex 文件

.tex 文章组成:

  • 导言区 preamble
    \documentclass{article}\begin{document}
  • 正文区 document body
    \begin{document}\end{document}

.tex 文章的组成可以分为两个部分:导言区和正文区。

  • 导言区 是文档的开头部分,用于定义文档的类型、调用宏包、设置格式等。
  • 正文区是文档的主要内容部分,用于编写文档的结构、文字、图表等。
  • 导言区和正文区之间用 \begin{document}\end{document} 命令来分隔。

main.tex 文件

main.tex项目的主文件,也就是 LaTeX 首先编译的文件

  • 它包含了文档的 类型、标题、作者、日期等信息,以及 文档的正文内容
  • 它也可以调用其他的文件,例如类文件、宏包文件、章节文件等,来实现文档的功能和格式。

main.tex 文件的一般结构如下:

\documentclass[选项]{
   文档类型} % 定义文档的类型和选项,例如 article, report, book 等 
\usepackage[选项]{
   宏包名} % 调用需要的宏包,例如 graphicx, amsmath, subfiles 等 
% 其他的导言区设置,例如定义命令、设置页面、设置字体等 

\begin{
   document} % 文档的开始 
\title{
   标题} % 定义文档的标题 
\author{
   作者} % 定义文档的作者 
\date{
   日期} % 定义文档的日期 
\maketitle % 生成标题页 
\tableofcontents % 生成目录 
% 文档的正文内容,可以使用 \section, \subsection, \subsubsection 等命令来创建层次结构 
% 可以使用 \include, \input, \subfile 等命令来调用其他的文件,例如章节文件、图形文件等 
\end{
   document} % 文档的结束

Latex 的文档层次结构

Latex 的文档层次结构是指 文档中的不同部分,如 章节、小节、段落 等,以及它们之间的关系和编号。

LaTeX可以组织、编号和索引文档的章节和部分。根据文档类定义部分多达 7 个级别:

在这里插入图片描述

不同文档类型的层次结构

Latex 的文档层次结构取决于文档的类型,例如 article, report, book 等。不同的文档类型有不同的层次结构,如下表所示:

文档类型 层次结构
article part, section, subsection, subsubsection, paragraph, subparagraph
report part, chapter, section, subsection, subsubsection, paragraph, subparagraph
book part, chapter, section, subsection, subsubsection, paragraph, subparagraph

在 Latex 中,可以使用以下命令来创建文档的层次结构:

  • \part{标题}:部分,用于书籍。
  • \chapter{标题}:章节,用于 report 和 book。
  • \section{标题}小节,是 最常用的层次结构命令
  • \subsection{标题}:子小节,用于细分 section 的内容。
  • \subsubsection{标题}:子子小节,继续细分。
  • \paragraph{标题}:段落,是内容。
  • \subparagraph{标题}:子段落,细分 paragraph 的内容。

这些命令会 自动为文档的层次结构进行编号,也可以通过在命令后加上 * 号来 取消编号,例如 \section*{标题}

将未编号的部分添加到目录中,使用 \addcontentsline 命令:\addcontentsline{toc}{section}{Title of the section},如下所示:

\addcontentsline{
   toc}{
   section}{
   Unnumbered Section}
\section*{
   Unnumbered Section}
An unnumbered section

report 6 层结构实例

\documentclass{report} 的顶级命令是创建章节 \chapter{title},以这 6 层举例:

chaptersectionsubsectionsubsubsectionparagraphsubparagraph

  • 代码展示:
\documentclass{
   report}
\title{
   Sections and Chapters}
\author{
   Overleaf}
\date{
   \today}

\begin{
   document}
\maketitle
\tableofcontents
\chapter{
   An Introduction to Lua\TeX}

\section{
   What is it—and what makes it so different?}
Lua\TeX{
   } is a \textit{
   toolkit}—it contains sophisticated software tools and components with which you can construct (typeset) a wide range of documents. The sub-title of this article also poses two questions about Lua\TeX: What is it—and what makes it so different? The answer to “What is it?” may seem obvious: “It’s a \TeX{
   } typesetting engine!” Indeed it is, but a broader view, and one to which this author subscribes, is that Lua\TeX{
   } is an extremely versatile \TeX-based document construction and engineering system.

\subsection{
   Explaining Lua\TeX: Where to start?}
The goal of this first article on Lua\TeX{
   } is to offer a context for understanding what this TeX engine provides and why/how its design enables users to build/design/create a wide range of solutions to complex typesetting and design problems—perhaps also offering some degree of “future proofing” 

\chapter{
   Lua\TeX: Background and history}
\section{
   Introduction}
Lua\TeX{
   } is, in \TeX{
   } terms, “the new kid on the block” despite having been in active development for over 10 years.

\subsection{
   Lua\TeX: Opening up \TeX’s “black box”}
Knuth’s original \TeX{
   } program is the common ancestor of all modern \TeX{
   } engines in use today and Lua\TeX{
   } is, in effect, the latest evolutionary step: derived from the pdf\TeX{
   } program but with the addition of some powerful software components which bring a great deal of extra functionality.
\end{
   document}
  • 编译效果展示:
    在这里插入图片描述

article 5 层结构实例

\section\documentclass{article} 文档中的顶级文档命令,以这 5 层举例:

sectionsubsectionsubsubsectionparagraphsubparagraph

  • 代码展示:
\documentclass{
   article}
   \title{
   USTC}                   %———总标题
   \author{
   USTCer}
\begin{
   document}
   \maketitle                                  % —— 显示标题
\tableofcontents                               %—— 制作目录(目录是根据标题自动生成的)
   \section{
   China}                             %——一号子标题  China is in East Asia.
     \subsection{
   Anhui}                      %——二号子标题  Beijing is the capital of China.
       \subsubsection{
   Hefei}                    %——三号子标题
         \paragraph{
   USTC}is a famous university.  %{
   }中的内容加粗显示
           \subparagraph{
   Mathematics and physics} is the best institute of USTC.
       \subsection{
   State Key Laboratory of ISN }
         \paragraph{
   USTC} is the best university in quantum information. 
\end{
   document}
  • 编译效果展示:
    在这里插入图片描述
  • 项目展示
    在这里插入图片描述

Latex 语法

图表插入与引用

使用 figure 环境来插入图片

\begin{figure}[h]
  \centering
  \includegraphics[width=0.7\textwidth]{前向过程和后向过程.png} %---.png是图片文件的相对路径
  \caption{扩散模型的前向过程和后向过程} %caption是图片的标题
  \label{fig:forward_backward} %此处的label相当于一个图片的专属标志,目的是方便上下文的引用
\end{figure}
  • h 表示图片应该放置在当前位置,而不是浮动到页面的顶部或底部。
  • \centering 命令将图片居中。
  • \includegraphics 命令用于插入图片。
  • width 选项指定图片的宽度,0.5\textwidth 表示图片的宽度为文本宽度的一半。
  • \caption 命令用于添加图片标题,
  • \label 命令用于添加标签,以便在文本中引用图片。

使用 ref 命令来引用已有的图

要引用一张图片,需要在插入图片时使用 \label 命令为其添加一个标签,然后在需要引用该图片的地方使用 \ref 命令并提供该标签的名称。

\begin{figure}[h]
  \centering
  \includegraphics[width=0.7\textwidth]{前向过程和后向过程.png}
  \caption{扩散模型的前向过程和后向过程}
  \label{fig:forward_backward}
\end{figure}

如图 \ref{fig:forward_backward} 所示,这是扩散模型的前向过程和后向过程。

\label 命令用于为图片添加标签,\ref 命令用于引用该标签。

在引用图片时,可以使用 \ref 命令并提供标签名称,如 \ref{fig:my_label}。这将在文本中生成一个链接,指向该图片的位置。

效果如图所示,

在这里插入图片描述

表格的插入与引用

\section{
   三线表}

三线表是《撰写手册》推荐使用的格式,如表\ref{
   tab:exampletable}\begin{
   table}[h]
  \centering
  \caption{
   表号和表题在表的正上方}
  \label{
   tab:exampletable}
  \begin{
   tabular}{
   cl}
    \toprule
    类型   & 描述                                       \\
    \midrule
    挂线表 & 挂线表也称系统表、组织表,用于表现系统结构 \\
    无线表 & 无线表一般用于设备配置单、技术参数列表等   \\
    卡线表 & 卡线表有完全表,不完全表和三线表三种       \\
    \bottomrule
  \end{
   tabular}
  \note{
   注:表注分两种,第一种是对全表的注释,用不加阿拉伯数字排在表的下边,
    前面加“注:”;第二种是和表内的某处文字或数字相呼应的注,
    在表里面用带圈的阿拉伯数字在右上角标出,然后在表下面用同样的圈码注出来}
\end{
   table}

在这里插入图片描述

代码块

在 LaTeX 中,可以使用 listings 宏包来放置代码块。下面是一个简单的示例:

\usepackage{
   listings}

\begin{
   lstlisting}[language=Python]
# 这是一段 Python 代码
def hello_world():
    print("Hello, World!")
\end{
   lstlisting}

使用了 listings 宏包来放置一段 Python 代码。

  • 可以使用 language 参数来指定代码块的语言。
  • 如果不指定语言,listings 宏包将默认使用 TeX 语言。

列表

无序列表 itemize

无序列表是指不需要特定顺序的列表,通常用符号(如圆点)来标记每一项。

在 LaTeX 中,创建无序列表的方法是使用 itemize 环境,其中每一项都以 \item 命令开始,例如:

\begin{itemize}
	\item 第一项
	\item 第二项
	\item 第三项
\end{itemize}

这样就会生成如下的输出:

  • 第一项
  • 第二项
  • 第三项

如果想改变符号的样式,可以在 \item 命令后面加上自定义的符号,需要在 \item 后面加上 $ 符号,才能使用数学符号作为标记,例如:

\begin{itemize}
	\item[$-$] 破折号
	\item[$\ast$] 星号
	\item[$\heartsuit$] 爱心
\end{itemize}

这样就会生成如下的输出:

爱心

有序列表 enumerate

\begin{
   enumerate}
    \item 作者考虑的三个类中的每一个都包含超过一百万张图像。
    \item 数据集创建者发现,当由训练有素的专家测量时,整个 LSUN 数据集的标签准确率约为90%。
    \item 图片是从互联网上抓取的,尤其是 LSUN 猫的图片往往遵循“迷因”格式。
    \item 这些照片中偶尔会出现人类,包括面孔,尤其是在猫类中。
\end{
   enumerate}

在这里插入图片描述

学位论文项目实战

导入一个模板,没啥好说的,自己捣鼓捣鼓就会了。

在这里插入图片描述
无PDF,“此编译未生成PDF。。。。”

遇到这个报错,可能是由 PDF 文件的版本过高,导致 PdfLaTex 无法正确处理它。PdfLaTex 默认使用的是 PDF 1.5 的格式,而 XeLaTex 可以支持更高的 PDF 版本,例如 PDF 1.7。将默认的 PdfLaTex 编译器改为 XeLaTex,重新编译

在这里插入图片描述

项目里文件太多,可以创建不同文件夹,

  • bib 文件夹:存放 参考文献 的信息,通常是 .bib 格式的文件。可以使用 \cite 命令在文档中引用这些文献,然后使用 \bibliography 命令生成参考文献列表。
  • chapters 文件夹:存放 文档的各个章节,通常是 .tex 格式的文件。可以使用 \include 命令在主文件中插入这些章节,让项目更加清晰和有序。
  • figures 文件夹:存放 文档中使用的图形,通常是 .png.jpg.pdf 等格式的文件。可以使用 \includegraphics 命令在文档中插入这些图形,然后使用 \caption\label 命令给它们添加标题和标签。

相关推荐

  1. ChatGPT助力写作论文写作利器

    2024-01-08 23:06:01       21 阅读
  2. ChatGPT:突破写作限制,开启论文写作境界

    2024-01-08 23:06:01       21 阅读
  3. ChatGPT智能写作:开启论文写作视野

    2024-01-08 23:06:01       15 阅读
  4. ChatGPT引领论文写作潮流

    2024-01-08 23:06:01       20 阅读
  5. ChatGPT引领论文写作潮流

    2024-01-08 23:06:01       22 阅读
  6. ChatGPT畅想:论文写作境界

    2024-01-08 23:06:01       18 阅读
  7. ChatGPT改写:论文写作时代

    2024-01-08 23:06:01       16 阅读
  8. ChatGPT写作宝典:解锁论文创作技能

    2024-01-08 23:06:01       20 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-08 23:06:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-08 23:06:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-08 23:06:01       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-08 23:06:01       20 阅读

热门阅读

  1. 【Leetcode】242.有效的字母异位词

    2024-01-08 23:06:01       37 阅读
  2. 浅谈一些生命周期

    2024-01-08 23:06:01       41 阅读
  3. 预编译真的能完美防御SQL注入吗?

    2024-01-08 23:06:01       38 阅读
  4. 19.Linux Shell任务控制

    2024-01-08 23:06:01       36 阅读
  5. C++合并K个有序链表

    2024-01-08 23:06:01       29 阅读
  6. 一道经典的柯里化面试题

    2024-01-08 23:06:01       40 阅读
  7. 如何防护零日攻击

    2024-01-08 23:06:01       44 阅读
  8. 无缝衔接,完美对接:探索系统对接的最佳实践

    2024-01-08 23:06:01       32 阅读