Space in array system equations

You can better exploit array:

\documentclass{article}
\usepackage{amsmath,array,cancel}

\newenvironment{system}[1]
 {%
  \left|\setlength{\arraycolsep}{0pt}
  \begin{array}{ @{} *{\numexpr2*#1\relax}{ >{{}} r <{{}} } l @{} }%
 }
 {\end{array}\right.}

\begin{document}

$\begin{system}{3}
 2x &+& 3y &-& \cancel{z} &=& 4 \\
 3x &+& 2y &+& \cancel{z} &=& 6
 \end{system}
 \rightarrow
 5x+5y=10
 \rightarrow
 x+y=2
 \rightarrow
 \begin{system}{3}
  x &-&  y &+& 2z &=& 2 \\
 3x &+& 2y &-&  z &=&4 \mid .2
 \end{system}$

\end{document}

This way the unknowns are perfectly aligned to each other. The argument to system specifies the number of unknowns.

enter image description here


Rather than eliminating the space, I propose working instead to align columns in the systems of equations. Also, by making it one big math expression, the spacing also takes on a more natural appearance.

\documentclass{article}
\usepackage{array,amsmath,cancel,tabstackengine}
\setstacktabulargap{0pt}
\TABstackMath
\begin{document}
  \noindent Example 1: 
  \\
     $\left| \tabularCenterstack{rrrl}{
        2x+&3y-&\cancel{z}=&4 \\
        3x+&2y+&\cancel{z}=&6 
    }\right.
    \rightarrow
     5x+5y=10 \rightarrow 
     x+y=2;
     \left| \tabularCenterstack{rrrl}{ 
    x-&y+&2z=&2 \\
    3x+&2y-&z=&4 | .2 
    }\right.
    \rightarrow$
\end{document}

enter image description here


It is quite simple to type it with the systeme package:

\documentclass{article}
\usepackage{amsmath, cancel, systeme}

\begin{document}

   \[ \sysdelim | .
   \systeme{2x + 3y-\cancel z = 4,3x + 2y + z = 6} \longrightarrow 5x + 5y = 10 \longrightarrow x + y = 20 \longrightarrow \systeme{x-y + 2z = 2, 3x + 2y - z = 4|. 2} \]%

\end{document}

enter image description here

Tags:

Arrays