3666 字
18 分钟
初识Latex: 从安装到撰写比赛计划书

最近打了商业精英挑战赛, 需要经常写计划书协作, 那么问题来了, linux写word并不太方便, libreoffice还是太拉了, 并且每次协作都需要重新排格式, 涉及到的公式还非常难排, 本文介绍了基于linux系统latex的安装和在计划书撰写方面的尝试

参考文章

我的设备:

  • 系统 Linux Mint 22.2 Zara
  • 内核 6.14.0-29-generic

安装#

本文主要针对Linux系统安装TeX Live作介绍, 其他系统可查看上方参考文章

“首先我推荐在 Linux 平台安装 TeX Live(Mac 不在本文的讨论之列)。出于各种原因,Linux 下程序的编译速度可以达到 Windows 下的数倍。根据我的经验,对于 LaTeX 项目,Linux 可以获得至少 5 倍的编译加速。“

下载安装镜像#

到某个国内的 CTAN 镜像站下载最新版的 TeX Live 镜像,比如 清华大学开源软件镜像站

目前最新的 TeX Live 版本为 2026,该文件夹下包含 3 个 .iso 文件,这 3 个文件仅有文件名不同,内容完全相同,你可以任选一个下载。该文件夹下还包含有 md5 摘要文件,你也可以下载下来以备校验。

iso可以放在任意位置, 后文将使用挂载镜像的安装方式, 默认安装到/usr/local/texlive/2026

校验安装镜像#

这一步是可选的,主要是检查下载过程中镜像有没有出现损坏,以及镜像是否被第三方篡改过。实际上现在的网络条件很好了,一般不会出问题的。如果从正规的镜像站下载,也不必担心篡改的问题。

在 Shell(如 bash)中切换到镜像所在的文件夹,然后执行

Terminal window
md5sum texlive2026.iso

md5 计算需要完整读取整个镜像文件,因此计算会持续一段时间,取决于你机器的运算速度和硬盘读取速度,请耐心等待。

你应该可以得到 TeX Live 2026 镜像文件的 md5 值 f5872cb2dec838670f91ed5c62493553

挂载安装镜像#

进入 Shell 并执行

Terminal window
sudo mkdir /mnt/texlive
sudo mount 你的镜像存放路径/texlive2026.iso /mnt/texlive

运行安装程序#

Terminal window
sudo /mnt/texlive/install-tl

你应该能够看到如下内容:

Terminal window
======================> TeX Live installation procedure <=====================
======> Letters/digits in <angle brackets> indicate <=======
======> menu items for actions or customizations <=======
= help> https://tug.org/texlive/doc/install-tl.html <=======
Detected platform: GNU/Linux on x86_64
<B> set binary platforms: 1 out of 15
<S> set installation scheme: scheme-full
<C> set installation collections:
40 collections out of 41, disk space required: 8779 MB (free: 970330 MB)
<D> set directories:
TEXDIR (the main TeX directory):
/usr/local/texlive/2025
TEXMFLOCAL (directory for site-wide local files):
/usr/local/texlive/texmf-local
TEXMFSYSVAR (directory for variable and automatically generated data):
/usr/local/texlive/2025/texmf-var
TEXMFSYSCONFIG (directory for local config):
/usr/local/texlive/2025/texmf-config
TEXMFVAR (personal directory for variable and automatically generated data):
~/.texlive2025/texmf-var
TEXMFCONFIG (personal directory for local config):
~/.texlive2025/texmf-config
TEXMFHOME (directory for user-specific files):
~/texmf
<O> options:
[ ] use letter size instead of A4 by default
[X] allow execution of restricted list of programs via \write18
[X] create all format files
[X] install macro/font doc tree
[X] install macro/font source tree
[ ] create symlinks to standard directories
[X] after install, set CTAN as source for package updates
<V> set up for portable installation
Actions:
<I> start installation to hard disk
<P> save installation profile to 'texlive.profile' and exit
<Q> quit
Enter command:

调整安装配置#

这一节是可选的。实际上 TeX Live 中有许多组件是很少用的,为了节省磁盘空间,我们精简一些组件。如果你的硬盘足够大,不在乎空间占用,可以直接进入下一步。

这一节参考了 TeX Live宏包集合和自定义安装

TeX Live 的打包策略为体系(scheme)——集合(collection)——软件包/宏包三层。其中可定制安装的是集合层次。TeX Live 2025 包括了 41 个集合。针对这些集合的解释可以参考上面的链接,这里就不赘述了。

Linux 的安装路径不建议改,否则之后出问题查文档可能会雪上加霜。Windows 随意,但路径不能带有非 ASCII 字符,而且不要太深,否则容易出问题。

在安装程序中输入 C 并回车,进入安装组件定制页面。

Terminal window
===============================================================================
Select collections:
a [X] Essential programs and files w [X] Italian
b [X] BibTeX additional styles x [X] Japanese
c [X] TeX auxiliary programs y [X] Korean
d [X] ConTeXt and packages z [X] Other languages
e [X] Additional fonts A [X] Polish
f [X] Recommended fonts B [X] Portuguese
g [X] Graphics and font utilities C [X] Spanish
h [X] Additional formats D [X] LaTeX fundamental packages
i [X] Games typesetting E [X] LaTeX additional packages
j [X] Humanities packages F [X] LaTeX recommended packages
k [X] Arabic G [X] LuaTeX packages
l [X] Chinese H [X] MetaPost and Metafont packages
m [X] Chinese/Japanese/Korean (base) I [X] Music packages
n [X] Cyrillic J [X] Graphics, pictures, diagrams
o [X] Czech/Slovak K [X] Plain (La)TeX packages
p [X] US and UK English L [X] PSTricks
s [X] Other European languages M [X] Publisher styles, theses, etc.
t [X] French N [ ] Windows-only support programs
u [X] German O [X] XeTeX and packages
v [X] Greek
P [X] Mathematics, natural sciences, computer science packages
S [X] TeXworks editor; TL includes only the Windows binary
Actions: (disk space required: 8315 MB)
<-> deselect all
<+> select all
<R> return to main menu
<Q> quit
Enter letter(s) to (de)select collection(s):

输入集合对应的字母可以选中/取消选中。支持批量输入。可以不装的组件有:

d [ ] ConTeXt and packages
e [ ] Additional fonts // 各种字体,空间大头
g [ ] Graphics and font utilities
i [ ] Games typesetting // 排版游戏用的
j [ ] Humanities packages // 人文科学类宏包,按需安装即可
E [ ] LaTeX additional packages // 空间大头
H [ ] MetaPost and Metafont packages
I [ ] Music packages // 排版乐谱用的
K [ ] Plain (La)TeX packages
L [ ] PSTricks // 老旧技术
M [ ] Publisher styles, theses, etc. // 各种学术、毕业论文模板,需要学术写作可以装一下
N [ ] Windows-only support programs // linux不支持,默认取消勾选
S [ ] TeXworks editor; TL includes only the Windows binary

各种语言集合上面省略了,根据需要选择即可。如果不需要外语支持,语言类集合中仅选择 ChineseChinese/Japanese/Korean (base)US and UK English 即可。

注意,如果需要中文支持,那么 ChineseChinese/Japanese/Korean (base)(这三种语言的首字母形成了有名的缩写:CJK)都是必不可少的。同理 Japanese 和 Korean 集合也都依赖 CJK base。

TeXworks 是一个简单的 LaTeX 编辑器,我们将会使用 VSCode 来编辑 LaTeX ,因此这个组件可以不装。另外只有 Windows 平台提供有编译好的二进制文件,Linux 平台估计要手动编译。

即使有些宏包在上面精简了,后期仍然可以使用 tlmgr 工具来单独安装它们。因此不用太担心。

我把可以不装的包的序号写在下面,可以直接复制粘贴然后回车:

deghijkstuvwxyznoABCEHIKLMNS

我这里经过一番精简后,原本需要的 8779 MB 空间精简到了 2713 MB

这样精简之后,编译有些模板时可能会报错说找不到宏包。此时可以使用tlmgr 从 CTAN 单独安装它们。

确认无误后,输入 R 并回车,回到主界面。

使用#

参考链接:

从一个最小骨架开始#

任何 LaTeX 文档都由两部分组成:导言区(preamble,\documentclass\begin{document} 之间)和正文区(body,\begin{document}\end{document} 之间)。导言区负责全局设置、加载宏包;正文区负责实际内容。

最精简的文档长这样——已经可以编译了:

\documentclass[oneside]{ctexart}
\title{Hello, \LaTeX!}
\author{Mint}
\date{\today}
\begin{document}
\maketitle
Hello, \LaTeX{}! 这是我的第一篇 \LaTeX{} 文档。
\end{document}

这里选择了 ctexart 文档类(CTeX 提供的 article 中文适配版),选项 oneside 表示单面打印——如果写计划书、课程报告,单面就够用;写论文需要双面打印时换成 twoside

导言区:加载你需要的宏包#

LaTeX 的核心理念是”按需加载”——用到什么功能,就 \usepackage 引入对应的宏包。以下是我在计划书撰写中最常用的几个:

宏包用途一句话说明
zhlipsum生成中文占位文字写草稿时填充内容看排版效果
graphicx插入图片支持 png/jpg/pdf,\includegraphics
booktabs学术风格三线表提供 \toprule \midrule \bottomrule
caption自定义图表标题控制标题与内容的间距
fancyhdr自定义页眉页脚比默认页面风格灵活得多
hyperref超链接与 PDF 书签目录、引用自动变成可点击链接
\usepackage{zhlipsum}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{fancyhdr}
\usepackage[bookmarksnumbered=true, colorlinks=true, linkcolor=black]{hyperref}
% 单栏文档(默认就是单栏,显式声明更清晰)
\onecolumn
% 表格标题与上方内容的间距
\captionsetup[table]{skip=10pt}

小提示hyperref 通常放在导言区最后加载,避免与其他宏包冲突。colorlinks=true 让链接有颜色但不加框;linkcolor=black 让目录和交叉引用的链接变成黑色,打印友好。

页眉页脚:用 fancyhdr 自定义#

默认的 LaTeX 页眉只有章节名和页码,用 fancyhdr 可以自由定制。下面定义了一个 myfancy 页面风格——页眉左中右分别显示章节名、文章标题、小节名,页脚居中显示页码:

\fancypagestyle{myfancy}{%
\pagestyle{fancy}
\lhead{\leftmark} % 页眉左:当前章节(section)名
\chead{\thetitle} % 页眉中:文章标题
\rhead{\rightmark} % 页眉右:当前小节(subsection)名
\lfoot{} % 页脚左:留空
\cfoot{\thepage} % 页脚中:页码
\rfoot{} % 页脚右:留空
}

\leftmark\rightmark 是 LaTeX 自动维护的标记——章节标题会自动填入。但是 \chead{\thetitle} 需要我们自己定义 \thetitle 变量,详见下文”标题页”一节。

fancyhdr 对页眉高度有要求。如果编译时警告”headheight is too small”,加上这两行即可:

\setlength{\headheight}{12.64723pt}
\addtolength{\topmargin}{-0.64723pt}

正式文档通常让标题页和目录页不显示页眉,所以在导言区最后把默认页面风格设为 empty

\pagestyle{empty}

等到正文开始再切换到 \pagestyle{myfancy}

正文区:从标题页到致谢#

下面按顺序讲解正文区的每一个部分。

1. 标题页#

\begin{document}
\makeatletter
\let\thetitle\@title % 把内部变量 \@title 的值保存到自定义命令 \thetitle
\makeatother
\maketitle

\@title 是 LaTeX 内部存储标题的变量,正常情况不能在导言区外直接访问。\makeatletter / \makeatother 之间的代码可以”借用”内部命令,把标题值捕获到 \thetitle,供后续页眉使用。

\maketitle 生成标题区域,包含标题、作者、日期。

2. 摘要与目录(前导页)#

正式文档的前几页通常用罗马数字页码,与正文的阿拉伯数字页码区分:

\section*{摘要}
\pagenumbering{Roman}
\addcontentsline{toc}{section}{摘要}
Hello, \LaTeX{}! 这是我的第一篇 \LaTeX{} 文档。
\zhlipsum[1-3] % 占位文字,写正式内容时删掉
\newpage
\thispagestyle{empty}
\tableofcontents % 生成目录
\listoffigures % 生成插图清单(可选)
\listoftables % 生成表格清单(可选)
命令说明
\section*{摘要}* 的章节不会自动编号,也不会进入目录
\addcontentsline{toc}{section}{摘要}手动把”摘要”加入目录
\pagenumbering{Roman}页码切换为罗马数字
\tableofcontents自动从章节标题生成目录
\thispagestyle{empty}当前页(目录页)不显示页眉页脚

提示\zhlipsum[1-3] 生成第 1~3 段中文占位文字,方便预览排版效果。写正式内容时删掉即可。

3. 进入正文#

\cleardoublepage % 确保正文从奇数页开始
\pagestyle{myfancy} % 切换到自定义页眉页脚
\setcounter{page}{1} % 页码重置为 1
\pagenumbering{arabic} % 切换为阿拉伯数字

\cleardoublepage 对于双面打印很重要——它保证新的一章始终从右页(奇数页)开始。如果只写电子版文档,用 \newpage 也可以。

4. 章节层级#

LaTeX 的章节命令从高到低依次为:

\section{一级标题}
\subsection{二级标题}
\subsubsection{三级标题}

编号自动递增,目录也自动更新。写计划书时,一般用 \section 划分大板块(市场分析、财务预测等),\subsection 细分具体内容。

5. 插入图片#

\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{img/ba.png}
\caption{示例图片}\label{fig:example}
\end{figure}
如图~\ref{fig:example}所示,这是一个示例图片。

逐行解释:

代码说明
\begin{figure}[htbp]浮动体环境,[htbp] 控制图片放置优先级:here→top→bottom→单独一页
\centering图片居中
\includegraphics[width=0.8\textwidth]{...}插入图片,宽度为页面文字宽度的 80%,高度等比例缩放
\caption{...}图片标题,自动编号
\label{fig:example}给图片贴标签,供交叉引用
\ref{fig:example}引用标签,编译后自动替换为对应编号
~不可断行空格,防止”如图”和”1”分处两行

浮动体是 LaTeX 的一大特色——图片和表格不会死板地卡在代码位置,而是浮动到排版最优的地方。用 [htbp] 可以调整浮动偏好;如果坚持”图片就要在这里”,可以用 [H](需加载 float 宏包)。

6. 插入表格#

\begin{table}[htbp]
\centering
\caption{示例表格}\label{tab:example}
\begin{tabular}{ccc}
\toprule
列1 & 列2 & 列3 \\
\midrule
数据1 & 数据2 & 数据3 \\
\bottomrule
\end{tabular}
\end{table}
代码说明
\begin{tabular}{ccc}三列均居中(c=center),换成 l 左对齐、r 右对齐
\toprule表格顶部粗线(booktabs 宏包提供)
\midrule表头与数据之间的细线
\bottomrule表格底部粗线
&列分隔符
\\行分隔符

三线表是学术写作的标准格式,简洁干净。booktabs 宏包提供的就是这种风格,比 LaTeX 默认的 \hline 好看得多。

交叉引用表格的语法与图片完全一致:\label{tab:xxx} 贴标签,\ref{tab:xxx} 引用。建议用前缀区分类型——fig: 表示图,tab: 表示表,eq: 表示公式。

7. 致谢#

\newpage
\thispagestyle{empty}
\section*{致谢}
\addcontentsline{toc}{section}{致谢}
感谢所有支持我的人!
\end{document}

和摘要一样,\section* 确保不自动编号,\addcontentsline 手动加入目录。

完整模板#

把以上所有片段组合起来,就是一份可以直接编译的计划书模板:

\documentclass[oneside]{ctexart}
\title{Hello, \LaTeX!}
\author{Mint}
\date{\today}
\usepackage{zhlipsum}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{fancyhdr}
\usepackage[bookmarksnumbered=true, colorlinks=true, linkcolor=black]{hyperref}
\onecolumn
\captionsetup[table]{skip=10pt}
\fancypagestyle{myfancy}{%
\pagestyle{fancy}
\lhead{\leftmark}
\chead{\thetitle}
\rhead{\rightmark}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
}
\setlength{\headheight}{12.64723pt}
\addtolength{\topmargin}{-0.64723pt}
\pagestyle{empty}
\begin{document}
\makeatletter
\let\thetitle\@title
\makeatother
\maketitle
\section*{摘要}
\pagenumbering{Roman}
\addcontentsline{toc}{section}{摘要}
Hello, \LaTeX{}! 这是我的第一篇 \LaTeX{} 文档。
\zhlipsum[1-3]
\newpage
\thispagestyle{empty}
\tableofcontents
\listoffigures
\listoftables
\cleardoublepage
\pagestyle{myfancy}
\setcounter{page}{1}
\pagenumbering{arabic}
\section{第一章}
\subsection{概述}
\subsubsection{如何xxx}
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{img/ba.png}
\caption{示例图片}\label{fig:example}
\end{figure}
如图~\ref{fig:example}所示,这是一个示例图片。
\zhlipsum[1-4]
\subsubsection{然后xxx}
\zhlipsum[1-4]
\begin{table}[htbp]
\centering
\caption{示例表格}\label{tab:example}
\begin{tabular}{ccc}
\toprule
列1 & 列2 & 列3 \\
\midrule
数据1 & 数据2 & 数据3 \\
\bottomrule
\end{tabular}
\end{table}
如表~\ref{tab:example}所示,这是一个示例表格。
\zhlipsum[1-8]
\newpage
\thispagestyle{empty}
\section*{致谢}
\addcontentsline{toc}{section}{致谢}
感谢所有支持我的人!
\end{document}

使用提示:复制模板后,把 \zhlipsum[...] 替换成你的实际内容,调整图片路径,修改章节标题——一份格式规范的计划书就出来了。后续协作时,团队成员只需要关注正文内容,格式由 LaTeX 自动搞定,再也不用反复手动排版了。

初识Latex: 从安装到撰写比赛计划书
https://www.mintlab.top/posts/learn/latex_setup/
作者
Mint
发布于
2026-04-03
许可协议
CC BY-NC-SA 4.0
发表评论

输入用户名和邮箱后自动检查登录状态。登录后用户名和邮箱将被绑定, 只可以修改头像和主页链接。

未登录
昵称
邮箱
填写头像链接与主页链接

头像链接为空默认使用gravatar头像

头像
主页
人机验证
评论列表

以下是可爱的评论们:

暂无评论, 呜呜, 快来评论喵!