LaTeX学习-day10
教程链接:B站
使用环境:
- 系统:Windows 10
- TeX 系统:TeX Live (官网下载)(清华源)
- IDE:Tex Studio
多行数学公式
1. 代码:
%导言区
\documentclass{ctexart}
\usepackage{amssymb}
\usepackage{amsmath}
%正文区
\begin{document}
LaTeX中多行数学公式
% gather 和 gather* 环境(可以使用\\换行)
% 带编号
\begin{gather}
a+b=b+a \\
ab=ba
\end{gather}
% 不带编号
\begin{gather*}
3+5=5+3=8 \\
3 \times 5 = 5 \times 3
\end{gather*}
% 在\\前使用\notag 阻止编号
\begin{gather}
3^2 + 4^2 = 5^2 \notag \\
5^2 + 12^2 = 13^2 \notag \\
a^2 + b^2 = c^2
\end{gather}
%align和align* 环境(用 & 进行对齐)
%允许公式按等号或其他关系符对齐,在关系符前加 &表示对齐;
%允许排列多列对齐公式,列与列之间使用& 分隔;
% 带编号
\begin{align}
x & = t + \cos t + 1 \\
y & = 2\cos t
\end{align}
% 不带编号
\begin{align*}
x & = t & x &= \cos t & x &= t \\
y & = 2t & y &= \sin(t+1) & y &= t
\end{align*}
%split环境(对齐采用split环境的方式,编号在中间)
\begin{equation}
\begin{split}
\cos 2x &= \cos^2 x - \sin^2 x \\
&= 2\cos^2 x - 1
\end{split}
\end{equation}
%cases环境
%每行公式中使用 & 分隔为两部分,
%通常表示值和后面的条件
\begin{equation}
D(x) = \begin{cases}
1, & \text{如果} x \in \mathbb{Q}; \\
0, & \text{如果} x \in \mathbb{R}\setminus\mathbb{Q}.
\end{cases}
\end{equation}
\end{document}