LaTeX 无法识别 \end{array}

LaTeX 无法识别 \end{array}

以下代码

... \begin{align}
\begin{array}
1 & 2 & 3\\
1 & 2 & 3
\end{array}
\end{align}...

导致大量错误:

 - Argument of \array has an extra }   (line 0)
 - Missing $ inserted \end{align}
 - Missing \endgroup inserted \end{align} 
 - Extra }, or forgotten $ \end{align} 
 - \begin{align} on input line 101 ended by \end{array}. \end{align} 
 - Misplaced alignment tab character & \end{align}   (2x, same line) 
 - Misplaced \omit \end{align} 
 - Misplaced \cr \end{align}
 - Misplaced alignment tab character & \end{align} (2x)
 - Misplaced \cr \end{align} 
 - Extra }, or forgotten $ \end{align} (2x)
 - Missing number, treated as zero \end{align}
 - Illegal unit of measure (pt inserted) \end{align}
 - Missing number, treated as zero (3x, line 0)
 - Missing $ inserted \end{align} 
 - Display math should end with $$ (line 0)
 - Missing $ inserted \end{align}
 - Missing \endgroup inserted \end{align}
 - Extra }, or forgotten $ \end{align} 
 - Missing $ inserted \end{align} 
 - Too many }'s \end{align} 
 - \begin{document} ended by \end{array}. (line 0) 
 - Misplaced \noalign \end{align} (2x)
 -  Too many }'s \end{align}
 - \begin{document} ended by \end{align}. \end{align} 
 - Display math should end with $$ (line 0)

当然,没有这个的代码也可以编译得很好。

除第 0 行的错误外,所有错误都出现在第 109 行 ( \end{align})。

矩阵环境(例子) 编译时也会出错,但错误较少。这些错误包括:

 - Paragraph ended before \array was complete I've inserted a
   begin-math/end-math symbol since I think

 - Missing \right. inserted I've inserted something that you may have
   forgotten.

 - Missing \endgroup inserted

我在 Ubuntu 上使用 TexStudio。我也尝试使用 Geany,但它会抛出相同的错误。

答案1

您需要指定array格式;例如:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{align}
\begin{array}{ccc}
1 & 2 & 3\\
1 & 2 & 3
\end{array}
\end{align}

\end{document}

在此处输入图片描述

评论中给出了一些新的信息;问题来自于同时使用arrayjobamsmath包,如下例所示:

\documentclass{article}
\usepackage{arrayjob}
\usepackage{amsmath}

\begin{document}

\begin{align}
\begin{array}{ccc}
1 & 2 & 3 \\
1 & 2 & 3
\end{array}
\end{align}

\end{document}

处理上述文档会触发错误

! Argument of \array has an extra }.
<inserted text> 
                \par 
l.12 \end{align}

冲突源于\array使用的宏名称arrayjob与 中的宏冲突amsmatharrayjobx包(arrayjob 的改进版本)改用宏解决了此问题\arrayx。因此,为了防止包arrayjob和之间的冲突amsmath,请使用arrayjobx而不是arrayjob

\documentclass{article}
\usepackage{arrayjobx}
\usepackage{amsmath}

\begin{document}

\begin{align}
\begin{array}{ccc}
1 & 2 & 3\\
1 & 2 & 3
\end{array}
\end{align}

\end{document}

我知道在回答中用arrayinside是没有意义的;如果唯一目的是获得显示(编号)表达式,则环境将是更好的选择;如果不需要显示编号,则就足够了。我保留了原始内容,只是希望 OP 的实际表达式值得使用。alignequation\[...\]align

相关内容