
Eu tenho algumas gauss
matrizes em um align*
ambiente, assim:
\documentclass{article}
\usepackage{amsmath}
\usepackage{gauss}
\newcommand{\BAR}{%
\hspace{-\arraycolsep}%
\strut\vrule % the `\vrule` is as high and deep as a strut
\hspace{-\arraycolsep}%
}
\begin{document}
\begin{align*}
= &\begin{gmatrix}[p]
1 & 0 & 1 & \BAR & 5 \\
0 & 1 & - 2 & \BAR & -2 \\
0 & 0 & 1 & \BAR & 3 \\
0 & 0 & 3 & \BAR & 9
\rowops
\add[-2]{1}{0}
\add[-4]{1}{2}
\add[-3]{1}{3}
\end{gmatrix} \\
= &\begin{gmatrix}[p]
1 & 0 & 0 & \BAR & 2 \\
0 & 1 & 0 & \BAR & 4 \\
0 & 0 & 1 & \BAR & 3 \\
0 & 0 & 0 & \BAR & 0
\rowops
\end{gmatrix}
\end{align*}
\end{document}
As matrizes estão alinhadas, mas também quero manter as larguras das colunas iguais para todas as matrizes. Como eu seria capaz de fazer isso?
Responder1
Fiz uma macro \addwd[]{}
que pode ser colocada em qualquer linha da coluna que precise de ampliação. Faz com que o argumento obrigatório tenha a largura do argumento opcional. Por padrão, o argumento opcional tem a largura de "-0".
(Observe que alterei “-2” no final da segunda linha para “-25” para demonstrar o método para colunas de largura maior)
\documentclass{article}
\usepackage{amsmath}
\usepackage{gauss}
\usepackage{calc}
\newcommand{\BAR}{%
\hspace{-\arraycolsep}%
\strut\vrule % the `\vrule` is as high and deep as a strut
\hspace{-\arraycolsep}%
}
\newcommand\addwd[2][-0]{\makebox[\widthof{$#1$}]{$#2$}}
\begin{document}
\begin{align*}
= &\begin{gmatrix}[p]
1 & 0 & 1 & \BAR & 5 \\
0 & 1 & - 2 & \BAR & -25 \\
0 & 0 & 1 & \BAR & 3 \\
0 & 0 & 3 & \BAR & 9
\rowops
\add[-2]{1}{0}
\add[-4]{1}{2}
\add[-3]{1}{3}
\end{gmatrix} \\
= &\begin{gmatrix}[p]
1 & 0 & \addwd{0} & \BAR & \addwd[-25]{2} \\
0 & 1 & 0 & \BAR & 4 \\
0 & 0 & 1 & \BAR & 3 \\
0 & 0 & 0 & \BAR & 0
\rowops
\end{gmatrix}
\end{align*}
\end{document}