2

folks! Sorry if this question has already been asked and answered, but I googled so hard I just can't find the right answer.

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:

enter image description here

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}
 \add[5]{1}{2}
\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

enter image description here

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.

2

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,
  spread .tl_set:N = \l_gauss_spread_tl,
  spread .initial:n = 1,
  colsep .dim_set:N = \l_gauss_colsep_dim,
  colsep .initial:n = \arraycolsep,
 }
\NewDocumentEnvironment{xgmatrix}{O{}}
 {
  \keys_set:nn { gauss } { #1 }
  \normalbaselines % <-----------  ADDED
  \linespread{\l_gauss_spread_tl}\selectfont
  \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}
 \add[5]{1}{2}
\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}
 \add[5]{1}{2}
\end{xgmatrix}
\end{align*}

\end{document}

enter image description here

  • Great job, man! This does the magic for my plan B. :) Do you just happen to know how to make that vertical line broken in parts, just as in the first example of my post? Thanks a lot for your effort and this solution! – Curiosity Oct 4 '17 at 16:36
  • @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
  • I understand, it might be impossible. I still hope there is an option... We will see. And thank you for the welcoming! Thank you for quick responses and a huge help! :) – Curiosity Oct 5 '17 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.