定理、证明与专业公式
使用 amsthm 定义定理、引理和定义环境,使用 proof 排版证明。amsmath 和 amssymb 则提供常用算子、集合字体与数学符号。
EasyLaTeX 编译器设置:XeLaTeX + ctex;需加载 amsmath、amsthm 和 amssymb。
定义定理环境
在导言区用 \newtheorem 声明环境。下面的写法让定理按节编号,例如“定理 1.1”:
\usepackage{amsthm}
\newtheorem{theorem}{定理}[section]
\newtheorem{lemma}[theorem]{引理}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{定义}
[section] 表示每个 \section 重新开始编号;[theorem] 表示引理和定义与定理共用同一序列。根据文档要求选择一种稳定编号方案,不要在同一论文中随意混用。
定理、引理与定义
定义完成后,在正文中使用对应EasyLaTeX 编译器设置:
\begin{theorem}[勾股定理]
直角三角形两直角边的平方和等于斜边的平方。
\end{theorem}
\begin{definition}
若集合 \(A\) 的元素个数有限,则称 \(A\) 为有限集。
\end{definition}
方括号中的“勾股定理”是定理标题,可省略。amsthm 的 definition 样式通常使用直立正文,适合定义、例和备注。
证明环境
amsthm 提供 proof 环境,并在末尾自动加入证毕符号:
\begin{proof}
由假设 \(a=b\),两边同时加上 \(c\) 可得 \(a+c=b+c\)。
\end{proof}
若证明以独立公式结束,证毕符号可能需要手动放入公式中:
\begin{proof}
\[
(a+b)^2 = a^2 + 2ab + b^2. \qedhere
\]
\end{proof}
\qedhere 让证毕符号出现在公式行末,避免另起一行。
常用算子与集合
数学算子应使用内置命令,而不是把名字逐字母斜体输入:
\[
\sin x + \log y = \lim_{n \to \infty} a_n.
\]
常用集合可用 \mathbb 表示:
\[
\mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C}.
\]
\mathbb 由 amssymb 提供。概率、期望、秩等没有统一的单字母惯例时,应在文档中首次定义含义。
自定义算子
对于经常使用的多字母算子,在导言区用 \DeclareMathOperator 定义:
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator*{\argmax}{arg\,max}
带星号的版本会在显示公式中把上下限放到算子正下方或正上方:
\[
\argmax_{x \in \mathbb{R}} f(x).
\]
不要反复写 \mathrm{rank} 伪造算子;它不能像真正算子一样处理间距与上下标位置。
常见问题
环境未定义
出现 Environment theorem undefined 或 Environment proof undefined 时,确认导言区已加载 \usepackage{amsthm},且 \newtheorem 写在正文开始前。
中文定理标题样式不合适
先确认 ctex 与 amsthm 的默认输出是否符合学校模板。模板已有定理定义时,不要再次声明同名环境;应复用模板的名称和编号规则。
\mathbb 未定义
加载 \usepackage{amssymb}。同样地,符号或命令未定义时,应先查它属于哪个宏包,而不是复制多个未知的宏包配置。
完整示例
\documentclass[UTF8,a4paper,12pt]{ctexart}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\newtheorem{theorem}{定理}[section]
\theoremstyle{definition}
\newtheorem{definition}[theorem]{定义}
\DeclareMathOperator{\rank}{rank}
\begin{document}
\section{示例}
\begin{definition}
若 \(A \subseteq \mathbb{R}\),则称 \(A\) 为实数集合的子集。
\end{definition}
\begin{theorem}
对任意实数 \(a\) 与 \(b\),有 \((a+b)^2=a^2+2ab+b^2\)。
\end{theorem}
\begin{proof}
直接展开 \((a+b)(a+b)\) 即得
\[
(a+b)^2 = a^2 + 2ab + b^2. \qedhere
\]
\end{proof}
\end{document}