\documentclass{article}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
\begin{align}
\hat{\alpha} &= \begin{cases}
\tan^{-1}\frac{\hat{\alpha_1}}{\hat{\alpha_2}}, \, &\text{if } \hat{\alpha_1}>0 \, \hat{\alpha_2}>0 \\
\tan^{-1}\frac{\hat{\alpha_1}}{\hat{\alpha_2}}+\pi, \, &\text{if } \hat{\alpha_1}<0 \\
\tan^{-1}\frac{\hat{\alpha_1}}{\hat{\alpha_2}}+2\pi, \, &\text{if }\hat{\alpha_2}<0 \, \hat{\alpha_1} >0 \\
\text{undefined}, & \hat{\alpha_2}=0 \, \hat{\alpha_1}=0
\end{cases}
\end{align}
\end{document}
我需要对这些案例进行编号,但是当我输入对齐代码时,文件无法编译,因为 \par .... 出了什么问题,请帮帮我,我尝试用各种方法来解决这个问题
答案1
不要在数学环境中插入空行。(顺便说一句,请提供完整的最小示例,即重现问题的示例和可以“开箱即用”地执行,例如\documentclass{}
,,\begin{document}
等等。)
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\hat{\alpha} &=
\begin{cases}
\tan^{-1}\frac{\hat{\alpha_1}}{\hat{\alpha_2}}, \, &\text{if } \hat{\alpha_1}>0 \, \hat{\alpha_2}>0 \\
\tan^{-1}\frac{\hat{\alpha_1}}{\hat{\alpha_2}}+\pi, \, &\text{if } \hat{\alpha_1}<0 \\
\tan^{-1}\frac{\hat{\alpha_1}}{\hat{\alpha_2}}+2\pi, \, &\text{if }\hat{\alpha_2}<0 \, \hat{\alpha_1} >0 \\
\text{undefined}, & \hat{\alpha_2}=0 \, \hat{\alpha_1}=0
\end{cases}
\end{align}
\end{document}
我还建议对此公式进行一些改进,如下所示:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\hat{\alpha} &=
\begin{cases}
\tan^{-1}\frac{\hat{\alpha_1}}{\hat{\alpha_2}} &\text{if } \hat{\alpha_1}>0\ \hat{\alpha_2}>0, \\
\tan^{-1}\frac{\hat{\alpha_1}}{\hat{\alpha_2}}+\pi &\text{if } \hat{\alpha_1}<0, \\
\tan^{-1}\frac{\hat{\alpha_1}}{\hat{\alpha_2}}+2\pi &\text{if }\hat{\alpha_2}<0\ \hat{\alpha_1} >0, \\
\text{undefined} & \text{if }\hat{\alpha_2}=0,\ \hat{\alpha_1}=0.
\end{cases}
\end{align}
\end{document}
我猜它还可以改进,但是这里的参与者比我更有能力指出这些改进!