4

I got this code:

$$\begin{array}{lcr}
a_{11}\cdot x_1+a_{12}\cdot x_2 &+ … + &a_{1n}\cdot x_n=\alpha_1 \\
a_{21}\cdot x_1+a_{22}\cdot x_2 &+…+&a_{2n}\cdot x_n=\alpha_2 \\
&\vdots & \\
a_{m1}\cdot x_1+a_{m2}\cdot x_2 &+…+&a_{mn}\cdot\ x_n=\alpha_m 
\end{array}$$

And I want to put a label outside to the right, giving the following PDF output:

Eq    =    my number
Eq2   =        umber  (2.2)
Eq3   =      two xer 

How can I achieve this? It is important that the first column is left-aligned, the middle-column is centered, and the third-column is right-aligned.

David Carlisle
  • 757,742

2 Answers2

2

The following is an ordinary equation, which allows for the labelling:

enter image description here

\documentclass{article}
\begin{document}
Here is some text.
\begin{equation}
  \begin{array}{l@{}c@{}r}
    a_{11}\cdot x_1+a_{12}\cdot x_2 + \cdots + a_{1n}\cdot x_n & {}={} & \alpha_1 \\
    a_{21}\cdot x_1+a_{22}\cdot x_2 + \cdots + a_{2n}\cdot x_n & {}={} & \alpha_2 \\
    & \vdots & \\
    a_{m1}\cdot x_1+a_{m2}\cdot x_2 + \cdots + a_{mn}\cdot x_n & {}={} & \alpha_m
  \end{array} \label{myeqns}
\end{equation}
Here is some more text. See~(\ref{myeqns}).
\end{document}

The column specification l@{}c@{}r ensures a left, centre, right alignment but also removes any inter-column space around the c-column. However, using {}={} corrects for the spacing around the =.

See Why is \[ … \] preferable to $$? and Are \( and \) preferable to $? for more information on the use of LaTeX-style math delimiters (avoiding $$), unless you're using plain TeX (which would make this answer useless).

Moriambar
  • 11,466
Werner
  • 603,163
0

Use \begin{equation} and \end{equation} rather than plain TeX style $$.

For equations that are not to be numbered you can use \[ and \], or, if the amsmath package is loaded, \begin{equation*} and \end{equation*} You might find the answers to Why is [ … ] preferable to $$? useful.

Ian Thompson
  • 43,767