# Matrix syntax in LaTeX [duplicate]

I know the basic matrix syntax in LaTeX but I am having problems with the type I have shown in the image . If anyone can help me with the encircled items it would be great:

So far I have this:

$$(3)(2)(1)\ \begin{vmatrix} {x}+{y}+ & {z}=33\\ 3{x}-8{y} & +7{z}=26\\ 5{y} & -3{z}=19 \end{vmatrix}$$


and it gives this result:

## marked as duplicate by egreg, Stefan Pinnow, Andrew Swann, Mensch, SchweinebackeFeb 17 '17 at 12:18

• Welcome to TeX.SX! Please post what you've got so far as MWE. – TeXnician Feb 17 '17 at 6:40
• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. If you don't know what a MWE is, see here: minimal working example (MWE). – CarLaTeX Feb 17 '17 at 6:42
• @TeXnician please check the post now – Aaqib Khan Feb 17 '17 at 6:48
• I assume you're using some form of MathJax? – Werner Feb 17 '17 at 6:52
• Sorry i didnot get what you asked? – Aaqib Khan Feb 17 '17 at 6:55

two possible solution: with array and with matrix extended with solution in matrix with vertical and horizontal lines :

\documentclass{article}
\usepackage{array}
\usepackage{mathtools}

\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
\hskip -\arraycolsep
\let\@ifnextchar\new@ifnextchar
\array{#1}}
\makeatother

\setlength\arraycolsep{1pt}
\begin{document}
$\begin{matrix} (1) \\ (2) \\ (3) \end{matrix} \left|\begin{array}{rr rr} x & y & z & = 33 \\ 3x & -8y & +7z & =26 \\ & 5y & -3z & =19 \end{array}\right|$

$\begin{matrix} (1) \\ (2) \\ (3) \end{matrix} \begin{vmatrix}[rr rr] x & y & z & = 33 \\ 3x & -8y & +7z & =26 \\ & 5y & -3z & =19 \end{vmatrix}$
\end{document}


Edit: As egreg notice, above solution treats + and - as unary rather than as binary operators. For later can be obtained with introduction of new columns for math operators in matrix as well as in array:

$\begin{matrix} (1) \\ (2) \\ (3) \end{matrix} \left|\begin{array}{rc rc rr} x & & y & & z & = 33 \\ 3x & - &8y & +& 7z & =26 \\ & &5y & -& 3z & =19 \end{array}\right|$

$\begin{matrix} (1) \\ (2) \\ (3) \end{matrix} \begin{vmatrix}[rc rc rr] x & & y & & z & = 33 \\ 3x & - &8y & +& 7z & =26 \\ & &5y & -& 3z & =19 \end{vmatrix}$


• Your method treats + and - as unary rather than as binary operators. – Mico Feb 17 '17 at 11:04

This case is straightforward with a TABstack and also gets the proper spacing around operators.

\documentclass[a4paper]{article}
\usepackage{tabstackengine}
\stackMath
\setstackgap{L}{1.2\normalbaselineskip}
\begin{document}
$\Centerstack{(1)\\(2)\\(3)}\quad \vertMatrixstack[r]{ x + & y + & z =& 33\\ 3x - & 8y + & 7z =& 26\\ & 5y - & 3z =& 19 }$
$\Centerstack[r]{-3\cdot(1) + (2)\rightarrow(4)\\(3)}\quad \vertMatrixstack[r]{ -11y + & 4z =& -73\\ 5y - & 3z =& 19 }\quad \Centerstack[r]{\cdot3\\\cdot4}$
\end{document}