# A matrix with breaking line and matrix transformations

I learned how to write a matrix with a breaking line, using the array:

\left[ \begin{array}{ccc;{2pt/2pt}c} 1 & 2 & 3 & -2 \\
0 & 5 & 10 & -5 \\
3 & 4 & 5 & 0
\end{array} \right]


The result is this:

Now, I would like to write down the matrix transformations on this type of matrix. By searching some of the answered questions on this website, I found that the best solution would be this:

\begin{gmatrix}[b]
1 & 2 & \BAR & 3 \\
4 & 5 & \BAR & 6 \\
7 & 8 & \BAR & 9
\rowops
\swap{0}{1}
\mult{0}{\cdot 7}
\end{gmatrix}


To make this work, it is necessary to add \usepackage{gauss} as well as

\newcommand{\BAR}{%
\hspace{-\arraycolsep}%
\strut\vrule
\hspace{-\arraycolsep}%
}


The outcome depends on the enviroment that I am using. If I write down the matrix by using , I get the full line, while it breaks within \begin{align*} \end{align*}. In respective order, the outcomes are

My goal is to keep matrix transformations, but instead of complete vertical line to have a broken line, just like in the first matrix of this post. Is that possible by keeping the commands from gauss package? If not, what is the best and the simplest solution to this?

Bonus question, if I happen to need it (or in case all of this is impossible to make): how to keep a vertical line in one piece by using \begin{align*} \end{align*}? Do I really need to change the environment for these matrices (I need it to write matrices in more than one line and having lines aligned the way I want)?

Thank you so much in advance! I truly hope someone has a simple answer to this.

The gmatrix environment uses low level table making functions, which are affected by the current baseline skip, which is increased in align.

An easy modification of https://tex.stackexchange.com/a/337481/4427 solves the problem. See the answer for more options to xgmatrix.

\documentclass{article}
\usepackage{amsmath}
\usepackage{gauss}
\usepackage{xparse}

\newcommand{\BAR}{%
\hspace{-\arraycolsep}%
\strut\vrule
\hspace{-\arraycolsep}%
}

\ExplSyntaxOn
\keys_define:nn { gauss }
{
type .tl_set:N = \l_gauss_type_tl,
type .initial:n = {},
right .code:n = \tl_set:cn { g@post } { \relax\$ },
right .value_forbidden:n = true,
colsep .dim_set:N = \l_gauss_colsep_dim,
colsep .initial:n = \arraycolsep,
}
\NewDocumentEnvironment{xgmatrix}{O{}}
{
\keys_set:nn { gauss } { #1 }
\setlength{\arraycolsep}{\l_gauss_colsep_dim}
\begin{gmatrix}[\l_gauss_type_tl]
}
{
\end{gmatrix}
}
\ExplSyntaxOff

\begin{document}

$\begin{gmatrix}[b] 1 & 2 & \BAR & 3 \\ 4 & 5 & \BAR & 6 \\ 7 & 8 & \BAR & 9 \rowops \swap{0}{1} \mult{0}{\cdot 7} \add[5]{1}{2} \end{gmatrix}$

\begin{align*}
\begin{gmatrix}[b]
1 & 2 & \BAR & 3 \\
4 & 5 & \BAR & 6 \\
7 & 8 & \BAR & 9
\rowops
\swap{0}{1}
\mult{0}{\cdot 7}
\end{gmatrix}
\end{align*}

\begin{align*}
\begin{xgmatrix}[type=b]
1 & 2 & \BAR & 3 \\
4 & 5 & \BAR & 6 \\
7 & 8 & \BAR & 9
\rowops
\swap{0}{1}
\mult{0}{\cdot 7}

• @Curiosity No broken line, sorry. One could try and make \BAR to do broken segments, but joining them sensibly would be tough. Another strategy could be adding the line to the last row, counting the number of them; I'd not undertake the task, TBH. Oh, and welcome to TeX.SX! – egreg Oct 4 '17 at 17:06