Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 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).

share|improve this answer
1  
Wouldn't aligned be easier? –  egreg Dec 16 '12 at 17:10
    
@egreg: But the alignment (rcl) would not be the way the OP requested (lcr). –  Werner Dec 16 '12 at 17:57
    
Oops! Didn't see that. Then either array or alignedat. –  egreg Dec 16 '12 at 19:03

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.