9

Hello.

I was trying to typeset the following system of equations:

system of equations

I used the following code in order to do it:

\begin{equation*}
    \left\{
    \begin{alignedat}{9}
        & b_{1,1} x_2 &&{} + {}&& b_{1,2} x_2 &&{} + {}&& \cdots &&{} + {}&& b_{1,9} x_9 &&{} = {}&& c_1 \\
        & b_{2,1} x_2 &&{} + {}&& b_{2,2} x_2 &&{} + {}&& \cdots &&{} + {}&& b_{2,9} x_9 &&{} = {}&& c_2 \\
        &&& \: \: \vdots &&&& \: \: \vdots &&&& \: \: \vdots &&&& \:\: \vdots \\
        & b_{9,1} x_2 &&{} + {}&& b_{9,2} x_2 &&{} + {}&& \cdots &&{} + {}&& b_{9,9} x_9 &&{} = {}&& c_9
    \end{alignedat}
    \right.
\end{equation*}

Now, I have 2 questions:

  1. Is there a more natural way to add the spacing between the columns?
  2. Why does {} + {} work (that is, adds the spaces around the + sign)? I got it by accident (desperate times call for desperate measures), but have no idea how/why it works.
2
  • 1
    Welcome to TeX.SX! Why don't you use macros for spacing such as \quad or \qquad for add space?
    – Aradnix
    Sep 30, 2014 at 22:05
  • 4
    As to the {}+{}, a plus sign can indicate an operation, as in a + b or it can be a sign as in +b. The spacing is different for these two cases. Adding the braces indicates to TeX that the plus should be taken as within an operation. Sep 30, 2014 at 22:10

2 Answers 2

9

The code {}+{} works because it adds empty atoms at either side of the operation, ensuring correct spacing.

However, you can input more easily this formula with array:

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

\begin{document}

\begin{equation*}
\left\{
\setlength{\arraycolsep}{0pt}% no padding
\newcolumntype{B}{>{{}}c<{{}}}
\begin{array}{ l B l B l B l B l }
b_{1,1} x_2 & + & b_{1,2} x_2 & + & \cdots & + & b_{1,9} x_9 & = & c_1 \\
b_{2,1} x_2 & + & b_{2,2} x_2 & + & \cdots & + & b_{2,9} x_9 & = & c_2 \\
  & \vdots && \vdots && \vdots &&  \vdots \\
b_{9,1} x_2 & + & b_{9,2} x_2 & + & \cdots & + & b_{9,9} x_9 & = & c_9
\end{array}
\right.
\end{equation*}

\end{document}

Here the {}+{} trick is used as well, but hidden in the temporary column type B (for Binary).

enter image description here

8

You don't need so many alignment points. Actually, the number of alignment points essentially depends on the number of vertical dots you want to align. I give two possibilities, with 4 or 2 alignment points (7 or 3 ampersands). The alignment itself uses the \vdotswithin command, from mathtools, and the braces come from the empheq package (which loads mathtools). You don't need an alignedat environment nested in an equation*, alignat* will do the job.

    \documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage[overload]{empheq}

\begin{document}

\begin{alignat*}{4}[left =\empheqlbrace]
     b_{1,1} x_2 &{}+ {}& b_{1,2} x_2 &{} + ⋯ +{} & b_{1,9} x_9 & ={} & c_1 \\
 b_{2,1} x_2 &{}+{} & b_{2,2} x_2 &{} + ⋯ + {}& b_{2,9} x_9 & = & c_2 \\[-1.5ex]
  \vdotswithin{b_{2,1} x_2}&& \vdotswithin{b_{2,2} x_2} && \vdotswithin{b_{2,9} x_9 } &&\vdotswithin{c_2} \\[-1ex]
     b_{9,1} x_2 &{}+ {}& b_{9,2} x_2 &{} + ⋯ + {}& b_{9,9} x_9 & = & c_9
\end{alignat*}

\begin{alignat*}{2}[left =\empheqlbrace]
     b_{1,1} x_2 &{}+ b_{1,2} x_2 + ⋯ + b_{1,9} x_9 & ={} & c_1 \\
 b_{2,1} x_2 &{}+ b_{2,2} x_2 + ⋯ + b_{2,9} x_9 & = {}& c_2 \\[-1.5ex]
  \vdotswithin{b_{2,1} x_2} && \vdotswithin{ = {}} \\[-1ex]
     b_{9,1} x_2 &{}+ b_{9,2} x_2 + ⋯ + b_{9,9} x_9 & = {}& c_9
\end{alignat*}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .