How to typeset a system of linear equations in LaTeX?
Solution based on array
:
\documentclass{article}
\begin{document}
\[
\begin{array}{@{}*{7}{c@{}}}
a_{11} x_1 & {}+{} & a_{12} x_2 & {}+ \cdots +{} & a_{1n} x_n & {}={} & b_1\\
a_{21} x_1 & {}+{} & a_{22} x_2 & {}+ \cdots +{} & a_{2n} x_n & {}={} & b_2\\[-2pt]
\vdots & & \vdots & & \vdots & & \vdots\\
a_{m1} x_1 & {}+{} & a_{m2} x_2 & {}+ \cdots +{} & a_{mn} x_n & {}={} & b_m
\end{array}
\]
\end{document}
Remarks:
- The curly braces in
{}+{}
and{}={}
ensure the proper spacing around binary and relational operators. [-2pt]
makes\vdots
a little more symmetrical.@{}
in the array specification removes the column sep.- It is not clear to me, what "without symbol { " means.
With autoaligne
(and some trickery), see How to align operators using alignat or someother environment?
\documentclass{article}
\usepackage{amsmath}
\usepackage{autoaligne}
%% A trick for an empty delimiter
\newcommand{\makeempty}[1]{%
\begingroup\lccode`~=`#1 \lowercase{\endgroup\def~}{\mathbin{\phantom{+}}}%
\mathcode`#1="8000
}
\begin{document}
\[
%\aavcoeff{2.5}
\makeempty{V}
\newcommand{\cvdots}{\hfill\vdots\hfill}
\definirseparateurs{\\}{+||-||V||=}{}
\autoaligne{
a_{11}x_1 + a_{12}x_2 + \dotsb + a_{1n}x_n = b_1 \\
a_{21}x_1 + a_{22}x_2 + \dotsb + a_{2n}x_n = b_2 \\
\cvdots V \cvdots VV \cvdots V \cvdots \\
a_{n1}x_1 + a_{n2}x_2 + \dotsb + a_{nn}x_n = b_n
}
\]
\end{document}
Here's another array
-based solution. By setting up the columns carefully, you're saved the tedium of having to enter x_1
, x_2
, thru x_n
repeatedly in the body of the array
environment.
\documentclass{article}
\usepackage{array} % for \newcolumntype macro
\newcolumntype{C}{>{{}}c<{{}}} % for columns with binary operators
\newcommand\vv{\multicolumn{1}{c}{\vdots}}
\usepackage{newtxtext,newtxmath} % for Times Roman fonts
\begin{document}
\[
\setlength{\arraycolsep}{0pt}
\begin{array}{c<{x_1} C c<{x_2} C c C c<{x_n} C l}
a_{11} & + & a_{12} & + & \cdots & + & a_{1n} & = & b_1 \\
a_{21} & + & a_{22} & + & \cdots & + & a_{2n} & = & b_2 \\
\vv & & \vv & & & & \vv & & \vdots\\
a_{m1} & + & a_{m2} & + & \cdots & + & a_{mn} & = & b_m \\
\end{array}
\]
\end{document}