Post

LaTeX Basic Notes

LaTeX Basic Notes

1. LaTeX 是什么

LaTeX 是一种基于文本的排版系统。和 Word 不同,LaTeX 通常不是直接“所见即所得”地拖动格式,而是通过源码描述文档结构,然后通过编译生成 PDF。

对于初学者来说,可以先把 LaTeX 理解成:

1
LaTeX 源码 + 模板/宏包 + 编译器 = PDF 文档

一个简单的 LaTeX 文件通常长这样:

1
2
3
4
5
6
7
\documentclass{article}

\begin{document}

Hello, LaTeX!

\end{document}

其中:

  • \documentclass{article} 表示使用 article 这种文章模板
  • \begin{document} 和 \end{document} 之间是真正的正文内容
  • 编译之后会生成 PDF 文件

a. LaTeX 和 Word 的区别

Word 更像是直接编辑最终排版结果,而 LaTeX 更像是写代码生成文档。

工具特点
Word所见即所得,适合快速写普通文档
LaTeX源码驱动,适合论文、公式、引用、复杂排版
Markdown更轻量,适合笔记、网页、README
LaTeX比 Markdown 更复杂,但排版能力更强

LaTeX 的优势在于:

  • 数学公式非常好写
  • 图、表、公式编号和引用比较方便
  • 参考文献管理比较规范
  • 适合论文、课程报告、技术文档
  • 模板统一,尤其适合 IEEE、ACM、Springer 等论文模板

LaTeX 的缺点在于:

  • 入门比 Word 难
  • 报错信息有时候不直观
  • 需要理解编译流程
  • 图片、表格位置有时不完全受自己控制

对于初学者,不需要一开始就学会所有 LaTeX 语法。最重要的是先能写出一篇包含标题、摘要、章节、公式、图片、表格和参考文献的简单论文。

b. LaTeX 的基本思想

LaTeX 的核心思想是内容和格式分离。

例如在 Word 中,我们可能会手动设置某一行字体大一些、加粗一些,让它看起来像标题。而在 LaTeX 中,我们通常写:

1
\section{Introduction}

LaTeX 会根据模板自动决定这个标题应该多大、是否加粗、和上下文距离是多少。

这意味着我们写文章时主要关注:

  • 这是什么结构?
  • 这是标题、正文、公式、图片还是表格?
  • 这段内容应该引用哪篇文献?

而不是手动调整每一行的字体和间距。


2. 一个 LaTeX 文件的基本结构

一篇最简单的 LaTeX 论文可以从下面这个结构开始:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
\documentclass{article}

\title{A Simple LaTeX Report}
\author{Your Name}
\date{\today}

\begin{document}

\maketitle

\begin{abstract}
This is a simple abstract.
\end{abstract}

\section{Introduction}

This is the introduction.

\section{Method}

This is the method section.

\section{Results}

This is the results section.

\section{Conclusion}

This is the conclusion.

\end{document}

a. 导言区和正文区

LaTeX 文件可以分成两个部分:

1
2
3
4
5
6
7
8
9
\documentclass{article}

% 这里是导言区 preamble

\begin{document}

% 这里是正文区 document body

\end{document}

i. 导言区

导言区通常用来设置文档类型、加载宏包、设置标题作者等信息。

例如:

1
2
3
4
5
6
7
8
\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}

\title{A Simple Report}
\author{Your Name}
\date{\today}

ii. 正文区

正文区是真正显示在 PDF 里的内容。

例如:

1
2
3
4
5
6
7
8
9
\begin{document}

\maketitle

\section{Introduction}

This is the introduction.

\end{document}

\begin{document} 之前的内容一般不会直接显示在 PDF 里,而是用于设置文档格式和功能。

b. documentclass

\documentclass 决定整个文档的基础类型。

常见的文档类型有:

document class用途
article普通文章、课程报告、短论文
report较长报告、毕业论文草稿
book书籍
IEEEtranIEEE 论文模板
beamer幻灯片

最常见的写法是:

1
\documentclass{article}

也可以添加参数:

1
\documentclass[12pt,a4paper]{article}

其中:

  • 12pt 表示正文字号
  • a4paper 表示纸张大小

c. package

LaTeX 的很多功能需要通过 package 提供。package 可以理解成 LaTeX 的插件或者库。

常见 package 如下:

package作用
amsmath增强数学公式
amssymb提供更多数学符号
graphicx插入图片
booktabs更好看的表格线
hyperref生成 PDF 超链接
geometry设置页边距
caption修改图表标题
subcaption插入子图
cite改善引用格式

常用写法:

1
2
3
4
5
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{hyperref}

初学者不需要记住所有 package。一般可以先从 amsmath、graphicx、booktabs、hyperref 开始。


3. 章节和正文

LaTeX 中的章节结构通常使用:

1
2
3
\section{Introduction}
\subsection{Background}
\subsubsection{Motivation}

对于 article 类型的文档,常见层级是:

LaTeX 命令含义
\section{}一级章节
\subsection{}二级章节
\subsubsection{}三级章节
\paragraph{}更小一级标题

例如:

1
2
3
4
5
6
7
8
9
10
11
\section{Introduction}

This is the introduction.

\subsection{Background}

This is the background.

\subsection{Motivation}

This is the motivation.

a. 段落

LaTeX 中段落之间需要空一行。

1
2
3
This is the first paragraph.

This is the second paragraph.

如果只是换行但不空行,LaTeX 通常仍然会把它当作同一段。

1
2
This is the first line.
This is still in the same paragraph.

b. 加粗、斜体和等宽字体

常用文本格式如下:

1
2
3
4
5
\textbf{bold text}

\textit{italic text}

\texttt{code style text}

效果分别是:

  • \textbf{}:加粗
  • \textit{}:斜体
  • \texttt{}:等宽字体,常用于代码、文件名、命令

例如:

1
2
3
The proposed method uses \textbf{convolutional neural networks}.

The variable \texttt{learning_rate} controls the training speed.

c. 列表

无序列表使用 itemize:

1
2
3
4
5
\begin{itemize}
    \item First item
    \item Second item
    \item Third item
\end{itemize}

有序列表使用 enumerate:

1
2
3
4
5
\begin{enumerate}
    \item Load the dataset.
    \item Train the model.
    \item Evaluate the result.
\end{enumerate}

4. 数学公式

LaTeX 最大的优势之一就是数学公式。

a. 行内公式

行内公式使用 $...$。

1
The voltage is denoted as $V_{DD}$.

例如:

1
The loss function is $L = y - \hat{y}$.

b. 独立公式

独立公式可以使用 equation 环境:

1
2
3
\begin{equation}
    y = wx + b
\end{equation}

如果不想编号,可以使用:

1
2
3
\[
    y = wx + b
\]

在论文中,如果之后需要引用这个公式,建议使用 equation;如果只是临时展示,可以使用 \[...\]。

c. 常见数学写法

目标LaTeX 写法
下标x_i
上标x^2
分式\frac{a}{b}
平方根\sqrt{x}
求和\sum_{i=1}^{N} x_i
积分\int_0^1 f(x)\,dx
希腊字母\alpha, \beta, \gamma
约等于\approx
小于等于\leq
大于等于\geq
不等于\neq

例如:

1
2
3
\begin{equation}
    \text{MSE} = \frac{1}{N}\sum_{i=1}^{N}(y_i - \hat{y}_i)^2
\end{equation}

d. 多行公式

多行公式通常使用 align,需要加载 amsmath:

1
\usepackage{amsmath}

然后写:

1
2
3
4
\begin{align}
    y &= wx + b \\
    L &= \frac{1}{N}\sum_{i=1}^{N}(y_i - \hat{y}_i)^2
\end{align}

其中:

  • & 表示对齐位置
  • \\ 表示换行

如果不想编号,可以使用:

1
2
3
4
\begin{align*}
    y &= wx + b \\
    L &= \frac{1}{N}\sum_{i=1}^{N}(y_i - \hat{y}_i)^2
\end{align*}

5. 图片

插入图片需要使用 graphicx package:

1
\usepackage{graphicx}

a. 插入一张图片

假设图片路径是:

1
figures/model.png

则可以写:

1
2
3
4
5
6
\begin{figure}[htbp]
    \centering
    \includegraphics[width=0.7\textwidth]{figures/model.png}
    \caption{The proposed model architecture.}
    \label{fig:model}
\end{figure}

其中:

  • figure 是图片环境
  • [htbp] 是图片位置建议
  • \centering 表示居中
  • width=0.7\textwidth 表示图片宽度是正文宽度的 70%
  • \caption{} 是图片标题
  • \label{} 是图片标签,方便后文引用

b. 图片位置参数

[htbp] 中每个字母的意思是:

参数含义
hhere,尽量放在当前位置
ttop,放在页面顶部
bbottom,放在页面底部
ppage,放在单独的浮动页

LaTeX 中的图片和表格属于 floating object,也就是浮动体。LaTeX 会根据页面空间自动调整位置,所以图片不一定正好出现在源码所在的位置。

如果图片位置和自己想的不一样,不一定是错误。LaTeX 会尝试避免图片把页面排得很难看。

c. 引用图片

如果图片中写了:

1
\label{fig:model}

那么正文中可以这样引用:

1
As shown in Figure~\ref{fig:model}, the proposed model contains three layers.

建议 Figure~\ref{fig:model} 中间使用 ~,这样 Figure 和编号不会被换行分开。


6. 表格

LaTeX 中最基础的表格使用 tabular 环境。

a. 一个简单表格

1
2
3
4
5
6
7
8
9
10
11
12
13
\begin{table}[htbp]
    \centering
    \caption{Experimental results.}
    \label{tab:results}
    \begin{tabular}{ccc}
        \hline
        Method & Accuracy & Loss \\
        \hline
        Method A & 90.1\% & 0.25 \\
        Method B & 92.3\% & 0.18 \\
        \hline
    \end{tabular}
\end{table}

其中:

  • table 是表格浮动体环境
  • tabular 是真正的表格内容
  • {ccc} 表示三列,每列居中
  • & 用于分隔列
  • \\ 用于换行
  • \hline 表示横线

b. 表格列格式

tabular 中常见列格式如下:

格式含义
lleft,左对齐
ccenter,居中
rright,右对齐
p{3cm}固定宽度列

例如:

1
\begin{tabular}{lcr}

表示三列,第一列左对齐,第二列居中,第三列右对齐。

c. 更好看的表格

论文中更推荐使用 booktabs package:

1
\usepackage{booktabs}

然后写:

1
2
3
4
5
6
7
8
9
10
11
12
13
\begin{table}[htbp]
    \centering
    \caption{Experimental results.}
    \label{tab:results}
    \begin{tabular}{lcc}
        \toprule
        Method & Accuracy & Loss \\
        \midrule
        Method A & 90.1\% & 0.25 \\
        Method B & 92.3\% & 0.18 \\
        \bottomrule
    \end{tabular}
\end{table}

相比 \hline,booktabs 的表格通常更适合论文排版。

d. 引用表格

如果表格中写了:

1
\label{tab:results}

正文中可以这样引用:

1
Table~\ref{tab:results} shows the experimental results.

7. 交叉引用

LaTeX 的交叉引用通常使用:

1
2
\label{}
\ref{}

常见用法如下:

对象label 命名习惯
章节sec:introduction
图片fig:model
表格tab:results
公式eq:loss

a. 引用章节

1
2
3
4
\section{Method}
\label{sec:method}

As described in Section~\ref{sec:method}, the proposed method contains three steps.

b. 引用公式

1
2
3
4
5
6
\begin{equation}
    L = \frac{1}{N}\sum_{i=1}^{N}(y_i - \hat{y}_i)^2
    \label{eq:mse}
\end{equation}

The loss function is defined in Equation~\ref{eq:mse}.

c. 为什么有时引用显示问号

如果 PDF 中出现:

1
Figure ??

或者:

1
Reference undefined

通常不是语法错,而是需要重新编译。

LaTeX 的引用编号需要通过中间文件记录,因此有时候需要编译两次甚至更多次。

使用 latexmk 时,一般可以自动处理多次编译。


8. 参考文献

论文中通常需要引用参考文献。LaTeX 中常见的参考文献方式有两种:

  • 直接在 .tex 文件里写 thebibliography
  • 使用 .bib 文件管理参考文献

对于初学者,建议先学 .bib 文件,因为这是更常见的论文写法。

a. 在正文中引用文献

正文中可以写:

1
Deep residual networks were proposed in \cite{he2016resnet}.

其中 he2016resnet 是参考文献的 citation key。

b. 创建 references.bib 文件

新建一个文件:

1
references.bib

内容可以写成:

1
2
3
4
5
6
7
@inproceedings{he2016resnet,
    title={Deep Residual Learning for Image Recognition},
    author={He, Kaiming and Zhang, Xiangyu and Ren, Shaoqing and Sun, Jian},
    booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
    pages={770--778},
    year={2016}
}

c. 在 tex 文件中加入参考文献

在正文最后,也就是 \end{document} 前面加入:

1
2
\bibliographystyle{IEEEtran}
\bibliography{references}

其中:

  • IEEEtran 是参考文献格式
  • references 表示使用 references.bib 文件
  • 不需要写 .bib 后缀

完整示例:

1
2
3
4
5
6
7
8
\section{Conclusion}

This paper presents a simple method.

\bibliographystyle{IEEEtran}
\bibliography{references}

\end{document}

d. 常见 bibliography style

style特点
plain按字母排序
unsrt按引用顺序排序
IEEEtranIEEE 风格
apalike类 APA 风格

如果使用会议或期刊模板,一般不要自己随便改 bibliography style,而应该使用模板要求的格式。


9. 编译 LaTeX

LaTeX 不是保存后直接得到 PDF,而是需要编译。

a. 常见编译器

编译器特点
pdfLaTeX最传统,英文论文常用
XeLaTeX更适合中文和系统字体
LuaLaTeX功能更现代,但初学者不一定需要
BibTeX用于处理参考文献
latexmk自动管理多次编译

对于英文论文,通常可以使用:

1
pdfLaTeX + BibTeX

对于中文文档,通常更推荐:

1
XeLaTeX

b. 为什么要编译多次

LaTeX 中的目录、引用、参考文献通常不是一次编译就能全部得到。

例如:

  1. 第一次编译:生成正文和辅助文件
  2. BibTeX 编译:生成参考文献
  3. 第二次 LaTeX 编译:更新引用编号
  4. 第三次 LaTeX 编译:确保所有交叉引用正确

如果手动编译,可能需要:

1
2
3
4
$ pdflatex main.tex
$ bibtex main
$ pdflatex main.tex
$ pdflatex main.tex

如果使用 latexmk,通常只需要:

1
$ latexmk -pdf main.tex

清理中间文件可以使用:

1
$ latexmk -c

c. 常见中间文件

LaTeX 编译时会生成很多中间文件。

文件作用
.aux存储引用、label 等辅助信息
.log编译日志
.out超链接书签等信息
.toc目录信息
.bblBibTeX 生成的参考文献内容
.blgBibTeX 日志
.synctex.gz源码和 PDF 同步信息

通常真正重要的是:

1
2
3
.tex
.bib
.pdf

其他大部分是编译生成的中间文件。


10. Cursor / VSCode 中的 LaTeX 写作

在 Cursor 或 VSCode 中写 LaTeX,通常需要安装:

  • TeX 发行版
  • LaTeX Workshop 插件

a. TeX 发行版

TeX 发行版相当于 LaTeX 的完整工具链,包含编译器、宏包、字体支持等。

常见选择:

系统推荐
macOSMacTeX
WindowsMiKTeX 或 TeX Live
LinuxTeX Live

b. LaTeX Workshop

LaTeX Workshop 是 VSCode / Cursor 里常用的 LaTeX 插件,主要功能包括:

  • 编译 .tex
  • 预览 PDF
  • 正向搜索:从源码跳到 PDF
  • 反向搜索:从 PDF 跳到源码
  • 显示编译错误
  • 自动补全 LaTeX 命令

c. 类似 Overleaf 的体验

Overleaf 的核心体验包括:

  • 左边写源码
  • 右边看 PDF
  • 编译后 PDF 更新
  • 源码和 PDF 可以相互定位

在 Cursor / VSCode 中,可以通过 LaTeX Workshop 实现类似体验。

常见操作是:

  1. 打开 .tex 文件
  2. 使用 LaTeX Workshop 编译
  3. 打开 PDF preview
  4. 将编辑器和 PDF preview 分屏
  5. 使用 SyncTeX 实现源码和 PDF 之间跳转

如果希望正向搜索和反向搜索正常工作,编译时需要启用 SyncTeX。常见参数是 -synctex=1。


11. 一篇简单论文的完整模板

下面是一个适合初学者的简单英文论文模板。

文件名可以叫:

1
main.tex

内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
\documentclass[12pt,a4paper]{article}

% Packages
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{hyperref}
\usepackage{geometry}

% Page setup
\geometry{margin=1in}

% Title information
\title{A Simple LaTeX Paper Template}
\author{Your Name}
\date{\today}

\begin{document}

\maketitle

\begin{abstract}
This is a simple abstract. The abstract should briefly summarize the motivation, method, result, and conclusion of the paper.
\end{abstract}

\section{Introduction}
\label{sec:introduction}

This section introduces the background and motivation of the work. A paper usually starts by explaining the problem and why the problem is important.

For example, deep learning has been widely used in image classification, natural language processing, and signal processing. However, many models require large datasets and high computational cost.

\section{Method}
\label{sec:method}

This section describes the proposed method. A method section should be clear enough so that other people can understand and reproduce the work.

The model can be represented as a simple linear function:
\begin{equation}
    y = wx + b
    \label{eq:linear}
\end{equation}

where $w$ is the weight, $x$ is the input, and $b$ is the bias.

The loss function is defined as:
\begin{equation}
    L = \frac{1}{N}\sum_{i=1}^{N}(y_i - \hat{y}_i)^2
    \label{eq:mse}
\end{equation}

Equation~\ref{eq:mse} is the mean squared error loss.

\section{Experiment}
\label{sec:experiment}

This section describes the experimental setup, including dataset, metrics, baseline methods, and implementation details.

\subsection{Dataset}

The dataset contains training samples and testing samples. Each sample includes an input feature and a target label.

\subsection{Evaluation Metrics}

The model is evaluated using accuracy and loss.

\section{Results}
\label{sec:results}

Table~\ref{tab:results} shows the experimental results.

\begin{table}[htbp]
    \centering
    \caption{Experimental results.}
    \label{tab:results}
    \begin{tabular}{lcc}
        \toprule
        Method & Accuracy & Loss \\
        \midrule
        Baseline & 88.5\% & 0.32 \\
        Proposed Method & 92.3\% & 0.18 \\
        \bottomrule
    \end{tabular}
\end{table}

Figure~\ref{fig:model} shows an example model architecture.

\begin{figure}[htbp]
    \centering
    \includegraphics[width=0.7\textwidth]{figures/model.png}
    \caption{An example model architecture.}
    \label{fig:model}
\end{figure}

\section{Discussion}
\label{sec:discussion}

This section discusses the meaning of the results. For example, the proposed method achieves higher accuracy than the baseline method. However, it may also require more computational resources.

\section{Conclusion}
\label{sec:conclusion}

This paper presents a simple LaTeX paper template. The template includes title, abstract, sections, equations, tables, figures, and references.

\bibliographystyle{IEEEtran}
\bibliography{references}

\end{document}

同时新建一个文件:

1
references.bib

内容如下:

1
2
3
4
5
6
7
@inproceedings{he2016resnet,
    title={Deep Residual Learning for Image Recognition},
    author={He, Kaiming and Zhang, Xiangyu and Ren, Shaoqing and Sun, Jian},
    booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
    pages={770--778},
    year={2016}
}

如果正文中需要引用这篇文献,可以写:

1
Deep residual networks were proposed in \cite{he2016resnet}.

12. 一篇论文通常应该怎么组织

一篇简单论文通常包含以下结构:

部分作用
Title标题
Abstract摘要
Introduction背景、问题、贡献
Related Work相关工作
Method方法
Experiment实验设置
Results结果
Discussion分析
Conclusion总结
References参考文献

a. Abstract

摘要通常简要回答:

  • 研究什么问题?
  • 为什么这个问题重要?
  • 使用了什么方法?
  • 得到了什么结果?
  • 最终结论是什么?

一个简单摘要可以按这个逻辑写:

1
2
3
4
This paper studies ...
The main challenge is ...
To address this problem, we propose ...
Experimental results show that ...

b. Introduction

Introduction 通常包含:

  • 研究背景
  • 当前问题
  • 为什么已有方法不够好
  • 本文方法
  • 本文贡献

常见写法是:

1
2
3
4
Recently, ...
However, ...
To address this problem, ...
The main contributions of this paper are as follows:

c. Method

Method 部分应该写清楚:

  • 方法整体结构
  • 输入是什么
  • 输出是什么
  • 关键公式
  • 关键算法步骤

如果有模型结构图,通常放在 Method 部分。

d. Experiment

Experiment 部分通常写:

  • 使用什么数据集
  • 和什么 baseline 比较
  • 使用什么评价指标
  • 训练参数是什么
  • 实验环境是什么

例如:

1
The model is trained for 100 epochs with a batch size of 64. The Adam optimizer is used with a learning rate of 0.001.

e. Results

Results 部分通常使用表格和图片展示结果。

例如:

1
Table~\ref{tab:results} shows that the proposed method outperforms the baseline method.

f. Conclusion

Conclusion 不应该简单重复摘要,而应该总结本文完成了什么、结果说明了什么、未来还能怎么改进。

常见写法是:

1
2
3
In this paper, we proposed ...
Experimental results show that ...
In future work, we plan to ...

13. 常见错误

a. Undefined control sequence

错误类似:

1
Undefined control sequence

通常说明 LaTeX 不认识某个命令。

常见原因:

  • 命令拼错
  • 忘记加载 package
  • 使用了当前编译器不支持的命令

例如使用 \includegraphics 前需要:

1
\usepackage{graphicx}

b. Missing $ inserted

错误类似:

1
Missing $ inserted

通常是因为数学符号写在了普通文本模式中。

错误写法:

1
x_i is the input feature.

正确写法:

1
$x_i$ is the input feature.

c. Citation undefined

错误类似:

1
Citation `xxx' undefined

常见原因:

  • .bib 文件中没有这个 citation key
  • citation key 拼写不一致
  • 没有运行 BibTeX
  • 需要重新编译多次

例如正文中写:

1
\cite{he2016resnet}

那么 .bib 文件中必须有:

1
2
3
@inproceedings{he2016resnet,
    ...
}

d. Reference undefined

错误类似:

1
Reference `fig:model' undefined

常见原因:

  • 没有写 \label{fig:model}
  • \ref{} 中名字拼错
  • 需要重新编译

e. 图片找不到

错误类似:

1
File `figures/model.png' not found

常见原因:

  • 图片路径写错
  • 图片文件名大小写不一致
  • 图片不在对应文件夹里
  • 编译的主文件路径和自己想的不一致

f. Overfull hbox

错误类似:

1
Overfull \hbox

这通常不是严重错误,而是某一行内容太长,超出了页面边界。

常见原因:

  • URL 太长
  • 公式太长
  • 表格太宽
  • 单词太长无法换行

可以先忽略,最后排版时再处理。


14. 初学者建议

学习 LaTeX 时不建议一开始背命令大全,而是建议按照论文需求逐步学习。

最重要的顺序是:

  1. 会写基本文档结构
  2. 会写章节和正文
  3. 会写公式
  4. 会插入图片
  5. 会插入表格
  6. 会使用 \label 和 \ref
  7. 会使用 .bib 管理参考文献
  8. 会看懂基础报错
  9. 会使用模板

对于初学者,最推荐的工作方式是:

1
2
3
4
5
先找一个能编译通过的模板
然后一点点修改内容
每次只改一小部分
改完立刻编译
如果报错,就回退到刚才能工作的版本

LaTeX 的学习曲线比 Word 陡,但是一旦掌握基本结构,写论文时会非常稳定。尤其是公式、图表编号和参考文献管理,LaTeX 会比 Word 更适合长期维护。


15. 最小可用模板

如果只是想快速开始,可以先使用下面这个最小模板:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
\documentclass[12pt,a4paper]{article}

\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{hyperref}
\usepackage{geometry}

\geometry{margin=1in}

\title{Paper Title}
\author{Your Name}
\date{\today}

\begin{document}

\maketitle

\begin{abstract}
This is the abstract.
\end{abstract}

\section{Introduction}

This is the introduction.

\section{Method}

The main equation is:
\begin{equation}
    y = wx + b
\end{equation}

\section{Results}

\begin{table}[htbp]
    \centering
    \caption{Results.}
    \begin{tabular}{lcc}
        \toprule
        Method & Accuracy & Loss \\
        \midrule
        Baseline & 88.5\% & 0.32 \\
        Proposed & 92.3\% & 0.18 \\
        \bottomrule
    \end{tabular}
\end{table}

\section{Conclusion}

This is the conclusion.

\end{document}

只要能理解并修改这个模板,就已经可以开始写一篇简单的课程论文或技术报告了。

Notes, Development Tools, LaTeX
This post is licensed under CC BY 4.0 by the author.