Latex\TexStudio多行数学公式排版

导入宏包\usepackage{amsmath} \usepackage{amssymb}

gather

gather

	% 带编号
	% gather 实现多行排版同时对公式进行编号
	\begin{gather}
		a + b = b + a \\
		abba
	\end{gather}

在这里插入图片描述

gather*

	\begin{gather*}
		3 + 5  = 5 + 3 = 8 \\
		3 \times 5  = 5 \times 3
	\end{gather*}

在这里插入图片描述

notag

	% 不带编号
	% 在 \\ 前使用\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\sin t
	\end{align}

在这里插入图片描述

align*

	% 不带编号
	\begin{align*}
		x &= t & x &= \cos t & x &= t \\
		y &= 2t & y &= \sin(t+1) & y &= \sin t
	\end{align*} 

在这里插入图片描述

split

	% split将一个公式分成多行排版
	% split 环境,一定要equation环境中(对齐采用align环境的方式,编号在多个式子中间)
	\begin{equation}
		\begin{split}
			\cos 2x &= \cos^2 x - \sin^2 x \\
			&= 2\cos^2 x -1
		\end{split}
	\end{equation}

在这里插入图片描述

cases

	% cases 环境
	% 每行公式中使用 & 分隔为两部分,
	% 通常表示值和后面的条件
	\begin{equation}	
		D(x) = \begin{cases}
			1, & \text{如果} x \in \mathbb{Q}; \\	 % \in 表示属于  \text表示输出文本模式,在数学模式中处理中文
			0, & \text{如果} x \in \mathbb{R} \setminus \mathbb{Q}	% \mathbb输出花体字符,需要amssymb宏包支持
		\end{cases} 
	\end{equation}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42173136/article/details/121002575