First of all, I show you my effort as follows. It seems to be too complicated in coding with unsatisfied output.
\documentclass[border=12pt,12pt,varwidth]{standalone}
\usepackage{mathtools}
\begin{document}
$
\begin{aligned}
\!
\begin{aligned}
3x +2y &=7 \\
9x +8y &=22
\end{aligned}
\left|
\!
\begin{aligned}
\times 3\\
\times 1
\end{aligned}
\right|
&\!
\begin{aligned}
9x +6y &=21 \\
9x +8y &=22
\end{aligned}\\
&\!
\begin{aligned}
-2y &=-1 \\
y &=1/2
\end{aligned}
\end{aligned}
$
\end{document}
What I want to achieve are
- The coding must use as minimal number of keystrokes as possible.
-
The output should look as follows,
where all spaces are well balanced, all equal signs are well aligned, the horizontal line exists to show the process of subtraction or addition, the sign of the process can be changed to either plus or minus, and the vertical lines are tall enough just to separate the left and right equations (no excessive vertical line).
How is the most elegant way to get such a diagram?
Best Answer
An elementary
array
implementation:One can play with the rule length in or to reduce the overhang on the right. For this, perhaps use
\rlap{$-1$}
and\rlap{1/2}
.