%20%E5%98%97%E8%A9%A6%E4%BD%BF%E7%94%A8%E3%80%8Caligned%E3%80%8D%E6%81%A2%E5%BE%A9.png)
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{#1}}
\makeatother
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{indentfirst}
\title{Test}
\author{Nguyen Van Manh \\ HE170552}
\date{}
\begin{document}
\maketitle
\section{Ex1}
\textbf{A1}
The augmented matrix of the system:
\[\left[\begin{alignat*}
1&2&-2&7\\
-2&1&-1&1\\
0&3&a&b
\end{alignat*}\right]\]
\[\displaystyle\begin{bmatrix}[cc|c]
1&2&3\\
2&-9&17
\end{bmatrix}\]
\end{document}
我收到錯誤:Package amsmath:方程式結構嵌套錯誤;\n(amsmath) 嘗試使用「對齊」恢復。
其原因何在?如何修復它?
我被嘗試過:
\[\left[\begin{alignedat}{4}
&1&&2&&-2&&7\\
&-2&&1&&-1&&1\\
&0&&3&&a&&b
\end{alignedat}\right]\tag{1}\]
我目前沒有收到上述錯誤,但看起來它沒有對齊
答案1
在行
\[\left[\begin{alignat*}
並啟動獨立顯示數學模式\[
。\begin{alignat*}
那可不太順利;因此出現錯誤訊息。
我認為你需要做的是替換\begin{alignat*}
為\begin{array}{rrrr}
,並在幾行下面替換\end{alignat*}
為\end{array}
。
鑑於您已經重新定義了低階\env@matrix
宏,您也可以分別將\left[\begin{alignat*}
和替換\end{alignat*}\right]
為\begin{bmatrix}[rrrr]
和\end{bmatrix}
。
附錄為了解決OP的主張
\[\left[\begin{alignedat}{4}
&1&&2&&-2&&7\\
&-2&&1&&-1&&1\\
&0&&3&&a&&b
\end{alignedat}\right]\tag{1}\]
應該管用」。事實並非如此——列的對齊方式很差。什麼會工作是
\[\left[\begin{alignedat}{5}
1&\quad&&2&\quad&&-2&\quad&&7\\
-2&&&1&&&-1&&&1\\
0&&&3&&&a&&&b
\end{alignedat}\right]\tag{1}\]
但是,我認為沒有人應該更喜歡這個
\[\begin{bmatrix}[rrrr]
1&2&-2&7\\
-2&1&-1&1\\
0&3&a&b
\end{bmatrix}\]
即,我之前的解決方案。