There are solutions to aligning a system unnumbered system of linear equations here: Aligning system of equations with zero coefficients I want a similar solution to numbered system of linear equations. I have also posted a question on using syteme for this here: How to do cross reference in systeme package? However, I find the cross-reference in systeme too painful to use. How to align a system of linear equations with other packages with the standard latex cross reference interface like alignat?
-
1Do you need/want a curly bracket (or brace) to encompass the system of equations?– Werner ♦Commented Feb 12, 2021 at 6:02
-
I don't want curly brackets. I want the equations separately numbered so that I could use cross reference.– S. VenkataramanCommented Feb 12, 2021 at 6:06
1 Answer
It's fairly straight forward to put a system of linear equations in an alignat
if you consider the following basic setup:
Each alignment point
&
has ar
ight-&
-l
eft (orr&l
) alignment structure;Keep variables, operators and relations in their own "column";
Add
{}
around operators/relations to ensure proper spacing (as in{}+{}
,{}-{}
and{}={}
);x variables requires x+1 alignment points (so, for 3 variables, you need
\begin{alignat}{4}
).
In the examples below I've marked the r
ight-alignment point with numbers, which translates to the value used with alignat
:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
% 3 variables ~ 4 alignment points
\begin{alignat}{4}
% 1 | 2 | 3 | 4
2x & {}+{} & y & {}-{} & 2z & {}={} & 3 \\
x & {}-{} & y & {}-{} & z & {}={} & 0 \\
x & {}+{} & y & {}+{} & 3z & {}={} & 12
\end{alignat}
% 3 variables ~ 4 alignment points
\begin{alignat}{4}
% 1 | 2 | 3 | 4
x & & & {}+{} & z & {}={} & 6 \\
& {}-{} & 3y & {}+{} & z & {}={} & 7 \\
2x & {}+{} & y & {}+{} & 3z & {}={} & 15
\end{alignat}
% 4 variables ~ 5 alignment points
\begin{alignat}{5}
% 1 | 2 | 3 | 4 | 5
x & {}+{} & y & {}+{} & z & {}+{} & w & {}={} & 13 \\
2x & {}+{} & 3y & & & {}-{} & w & {}={} & -1 \\
-3x & {}+{} & 4y & {}-{} & z & {}+{} & 2w & {}={} & 10 \\
x & {}+{} & 2y & {}-{} & z & {}+{} & w & {}={} & 1
\end{alignat}
\end{document}
With the above structure in place, you can \label
-\ref
whatever you need in the usual way.