錯誤:\item 在數學模式下無效

錯誤:\item 在數學模式下無效

我想在正則表達式中添加一個垂直線,但是當我輸入\mid.你能幫我嗎?

\item \textbf{Give a regular expression for the language accepted by the automaton~$A$.} \\\\
(0 \mid 1)*01)0 \mid 1)*\\
 \item \textbf{Explain what makes the automaton~$A$ non-deterministic.}\\\\
 The reason automaton~$A$ is non-deterministic is because in the state q0 reading a 0 can either lead to $q_0$ or $q_1$.

答案1

\mid導致 tex 切換到數學模式,並且當它到達下一個時它仍然處於數學模式\item,因此出現意外的錯誤訊息。

而不是你所擁有的,用\mid未編號的數學顯示來製作該行:

\item \textbf{Give a regular expression for the language accepted by the automaton~$A$.}
\[ (0 \mid 1)*01)0 \mid 1)* \]
 \item \textbf{Explain what makes the automaton~$A$ non-deterministic.}

 The reason automaton~$A$ is non-deterministic is because in the state $q_0$ reading a $0$
 can lead to either $q_0$ or $q_1$.

正如已經評論過的,使用雙反斜線不是一個好的做法。看 何時使用 \par 以及何時使用\\ 了解更多。

編輯:根據關於什麼是數學、什麼不是數學的評論,我調整了原始程式碼;為了清楚起見,我還將「編輯鉛筆」應用到「任一」的位置。 (對我的假設表示歉意;請參閱我的用戶個人資料以了解我為什麼這麼挑剔。)

相關內容