增广矩阵的水平对齐

增广矩阵的水平对齐

有没有办法对齐增强矩阵中的垂直线(使它们位于对齐方程的下方)?当矩阵中的符号发生变化时,它会变得扭曲,我正在寻找一种更好的视觉表示。

在此处输入图片描述

\begin{align*}
    \rightsquigarrow
    &\left( \begin{array}{rrr|rrr}
       2 & 4 & 3 & 1 & 0 & 0\\
       2 & 1 & 2 & 0 & 1 & 0\\
       2 & 4 & 2 & 0 & 0 & 2\\
    \end{array}\right)
    \rightsquigarrow\\
    \text{II} - \text{I}, \text{III}-\text{I}\rightsquigarrow
    &\left( \begin{array}{rrr|rrr}
       2 & 4 & 3 & 1 & 0 & 0\\
       0 & -3 & -1 & -1 & 1 & 0\\
       0 & 0 & -1 & -1 & 0 & 2\\
    \end{array}\right)
    \rightsquigarrow
\end{align*}

答案1

该包提供了一个带有键的nicematrix环境。在该环境中,所有环境(、、等)的所有列都将具有相同的宽度。您需要多次编译。{NiceMatrixBlock}auto-columns-widthnicematrix{NiceMatrix}{NiceArray}{NiceTabular}

\documentclass{article}

\usepackage{nicematrix}
\usepackage{amssymb}

\begin{document}

\begin{NiceMatrixBlock}[auto-columns-width]

\begin{align*}
    \rightsquigarrow
    &\begin{pNiceArray}{rrr|rrr}
       2 & 4 & 3 & 1 & 0 & 0\\
       2 & 1 & 2 & 0 & 1 & 0\\
       2 & 4 & 2 & 0 & 0 & 2\\
    \end{pNiceArray}
    \rightsquigarrow\\
    \text{II} - \text{I}, \text{III}-\text{I}\rightsquigarrow
    &\begin{pNiceArray}{rrr|rrr}
       2 & 4 & 3 & 1 & 0 & 0\\
       0 & -3 & -1 & -1 & 1 & 0\\
       0 & 0 & -1 & -1 & 0 & 2\\
    \end{pNiceArray}
    \rightsquigarrow
\end{align*}

\end{NiceMatrixBlock}

\end{document}

上述代码的输出

答案2

根据您是否希望列也对齐,我建议两种方法:

第一种方式:

在此处输入图片描述

第二种方式:

在此处输入图片描述

第一个输出的代码:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}

\begin{document}

\begin{alignat*}{3}
  & \rightsquigarrow
  & \left( \begin{array}{rrr}
             2 & 4 & 3 \\
             2 & 1 & 2 \\
             2 & 4 & 2 \\
  \end{array} \right|
  &
    \left. \begin{array}{@{}rrr}
             1 & 0 & 0 \\
             0 & 1 & 0 \\
             0 & 0 & 2 \\
           \end{array} \right)
  && \rightsquigarrow\\
  \text{II} - \text{I}, \text{III}-\text{I}
  & \rightsquigarrow
  & \;                          % add a little space after the arrow
    \left( \begin{array}{rrr}
             2 &  4 &  3 \\
             0 & -3 & -1 \\
             0 &  0 & -1 \\
           \end{array}\right|
  &
    \left. \begin{array}{@{}rrr}
              1 & 0 & 0 \\
             -1 & 1 & 0 \\
             -1 & 0 & 2 \\
           \end{array} \right)
  &&\rightsquigarrow
\end{alignat*}

\end{document}

第二个输出的代码:

\documentclass{article}
\usepackage{array}
\usepackage{amsmath}
\usepackage{amsfonts}

% Let's have fun and spare one skip register.
\makeatletter
\newcommand*{\@@mydefineColType}[2]{%
  \newcolumntype{#2}{>{$}W{r}{#1}<{$}}%
}
\newcommand*{\@mydefineColType}[2]{%
  \expandafter\@@mydefineColType\expandafter{\the#1}{#2}%
}
\newcommand*{\mydefineColType}[2]{%
  \expandafter\@mydefineColType\my@exchange{#1}{#2}%
}
\newcommand{\my@exchange}[2]{{#2}{#1}}
\makeatother

\begin{document}

\newlength{\mylength}%
\settowidth{\mylength}{$-3$}%
% For columns containing at least one negative number
\mydefineColType{N}{\mylength}% stores the current value of \mylength
\settowidth{\mylength}{$3$}%
% For columns containing no negative number
\mydefineColType{P}{\mylength}% stores the current value of \mylength

\begin{alignat*}{3}
  & \rightsquigarrow \; % add a little space after the arrow
  & \left( \begin{array}{PNN}
             2 & 4 & 3 \\
             2 & 1 & 2 \\
             2 & 4 & 2 \\
  \end{array} \right|
  &
    \left. \begin{array}{@{}NPP}
             1 & 0 & 0 \\
             0 & 1 & 0 \\
             0 & 0 & 2 \\
           \end{array} \right)
  && \rightsquigarrow\\
  \text{II} - \text{I}, \text{III}-\text{I}
  & \rightsquigarrow \; % add a little space after the arrow
  & \left( \begin{array}{PNN}
             2 &  4 &  3 \\
             0 & -3 & -1 \\
             0 &  0 & -1 \\
           \end{array}\right|
  &
    \left. \begin{array}{@{}NPP}
              1 & 0 & 0 \\
             -1 & 1 & 0 \\
             -1 & 0 & 2 \\
           \end{array} \right)
  &&\rightsquigarrow
\end{alignat*}

\end{document}

答案3

\MoveEqLeft使用来自 的命令的可能性mathtools。通过反复试验找到了可选参数的值:

\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}

\begin{document}

\begin{align*}
    \rightsquigarrow
   \MoveEqLeft[-1.55]\left( \begin{array}{rrr|rrr}
       2 & 4 & 3 & 1 & 0 & 0\\
       2 & 1 & 2 & 0 & 1 & 0\\
       2 & 4 & 2 & 0 & 0 & 2\\
    \end{array}\right)
    \rightsquigarrow\\
    \text{II} - \text{I}, \text{III}-\text{I}\rightsquigarrow
    &\left( \begin{array}{rrr|rrr}
       2 & 4 & 3 & 1 & 0 & 0\\
       0 & -3 & -1 & -1 & 1 & 0\\
       0 & 0 & -1 & -1 & 0 & 2\\
    \end{array}\right)
    \rightsquigarrow
\end{align*}

\end{document} 

在此处输入图片描述

相关内容