30 分钟学会 LaTeX
LaTeX 是一种排版系统:用带命令的纯文本写作,再编译成精美的 PDF。接下来的 30 分钟里,你将写出并编译一份完整的文档,包含小节、数学公式、图片、表格和列表。这里的每个示例都可以直接在 LetX 编辑器中运行,无需安装。
1. 第一个文档
每个 LaTeX 文档都需要指定一个文档类,然后将内容置于 \begin{document} 与 \end{document} 之间。
\documentclass{article}
\begin{document}
Hello, world! My first LaTeX document.
\end{document}2. 标题与小节
添加标题块并将内容划分为带有编号的小节。LaTeX 会自动为它们编号。
\documentclass{article}
\title{My Report}
\author{Your Name}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
This section is numbered automatically.
\subsection{Background}
A nested subsection.
\end{document}3. 文本格式化
\textbf{bold}, \textit{italic}, \underline{underlined},
and \emph{emphasis}.4. 数学公式
行内公式写在 $ … $ 中;如需更多功能可加载 amsmath。左侧为源码,右侧为结果:
\[ E = mc^2 \]\[ \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \]5. 图片
加载 graphicx,然后将上传的图片放入 figure 环境中。
\usepackage{graphicx} % preamble
% ...
\begin{figure}[ht]
\centering
\includegraphics[width=0.7\linewidth]{image.png}
\caption{A caption.}
\end{figure}6. 表格
\begin{tabular}{l c r}
Item & Qty & Price \\
Pen & 3 & 1.50
\end{tabular}7. 列表
\begin{itemize}
\item A bullet
\end{itemize}
\begin{enumerate}
\item A numbered item
\end{enumerate}8. 编译与导出
编译会将源码转换为 PDF。在 LetX 中点击“编译”(或按 Ctrl/Cmd+Enter),PDF 几秒钟即可更新;点击下载即可将其导出。
常见问题
真的能在 30 分钟内学会 LaTeX 吗?
是的。只需大约 30 分钟,就能掌握足够的 LaTeX 知识来编写包含小节、数学公式、图片和表格的结构化文档。本快速入门涵盖了这些核心基础;完整课程则会对每个主题做更深入的讲解。
需要安装任何软件吗?
不需要。借助像 LetX 这样的在线编辑器,直接在浏览器中编写和编译即可。无需安装 TeX 发行版。只需打开项目并粘贴示例即可。
接下来应该学习什么?
可以学习免费的《LaTeX 完整课程》,深入了解文档结构、数学公式、插图、表格和参考文献,或者浏览快速指南和常见问题修复方案。