今天早些時候問了一個問題,了解到subequations
amsmath提供的環境沒有進入數學模式: 在子方程式環境中使用 \frac 時缺少 $ 插入錯誤?
根據文件但是,align 應該進入數學模式(請參閱第 10 頁)。那麼,為什麼下面的 MNWE(最小不工作範例)不起作用呢?
\documentclass[12pt,letterpaper]{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}
\section{Hello World}
\begin{subequations}
\begin{align}
\frac{a}{b} &= 0 \\
x + y &= \frac{a}{b} \\
\end{align}
\end{subequations}
\end{document}
產生的錯誤似乎再次顯示align不是數學模式環境?
line 14: Missing $ inserted I've inserted a begin-math/end-math symbol since I think
line 15: Missing \endgroup inserted x + y &
line 15: Missing $ inserted x + y &= \frac{a}{b}
line 15: Extra }, or forgotten $ x + y &= \frac{a}{b}
line 16: Misplaced \cr \end{align}
line 16: Missing $ inserted \end{align}
line 16: Missing } inserted \end{align}
line 16: Misplaced \noalign \end{align}
line 16: Extra }, or forgotten \endgroup \end{align}
line 16: Missing $ inserted \end{align}
line 0: Display math should end with $$
特別要注意第 14 行的錯誤:「我認為因此我插入 $?」。好吧,拋開所有笑話,這裡有什麼?我沒有正確理解文件嗎?
答案1
這甚至比你的答案(現在評論)還要多。在任何形式的數學模式中,\par
以及等效形式(例如空白行)都會導致錯誤。原因在第 16 章第 12 頁。 135 的教材
相反,數學模式下不允許使用空白行或 \par。這為 TeX 提供了另一種從丟失的 $ 中恢復的方法;此類錯誤將僅限於發生錯誤的段落。