\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}
我想它仍然可以改進,但是這裡的參與者比我更有能力指出這些改進!