TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like the elements in my math environment to be left aligned, so that each element stands over each other, like in the given example below. I have managed it using \hspace and \qquad, but thought there is a more elegant way to do this. Can anyone suggest a better solution?

enter image description here

&\gamma(0)=\quad\alpha_1\gamma(1)\hspace{27pt}+\quad\alpha_2\gamma(2)\hspace{27pt}+\quad\dots\quad+\quad\alpha_p\gamma(p)\quad+\quad\sigma^2 \\
&\gamma(1)=\quad\alpha_1\gamma(0)\hspace{27pt}+\quad\alpha_2\gamma(1)\hspace{27pt}+\quad\dots\quad+\quad\alpha_p\gamma(p-1) \\
&\vdots \\

share|improve this question
Wasn't my answer good enough? :( – Svend Tveskæg Feb 11 '14 at 10:44
I think you adapted your answer to that by Thorsten Donig, didn't you? So I suggest his war slightly better. – DatamineR Feb 11 '14 at 10:51
No. I just moved some curly brackets in order to remove the ampersands. I have a feeling that Thorsten took my code and used it. (At least all of his code--minus the ampersands--in the aligned environment is exactly the same as mine, and I posted mine first.) P.S. I haven't got any problem with Thorsten's answer at all. – Svend Tveskæg Feb 11 '14 at 10:59
Are you sure he copied your code? – DatamineR Feb 11 '14 at 12:14
No. As I said, I think he did. – Svend Tveskæg Feb 11 '14 at 12:16
up vote 7 down vote accepted

If you want to keep one single equation number, you can use the alignedat environment inside equation.

\usepackage{mathtools}  % loads »amsmath«

      \gamma(0) &= \alpha_1\gamma(1) &&+ \alpha_2\gamma(2) &&+ \cdots &&+ \alpha_p\gamma(p)&&+ \sigma^2 \\
      \gamma(1) &= \alpha_1\gamma(0) &&+ \alpha_2\gamma(1) &&+ \cdots &&+ \alpha_p\gamma(p-1) \\
      &\vdotswithin{=} \\
      \gamma(p) &= \alpha_1\gamma(p-1)&&+ \alpha_2\gamma(p-2) &&+ \cdots &&+\alpha_p\gamma(0)

enter image description here

share|improve this answer
Why load fontenc? – Svend Tveskæg Feb 10 '14 at 16:52
Probably, but the other answer was posted earlier. Unfortunately cannot accept two answers but upvote... – DatamineR Feb 10 '14 at 16:55
@SvendTveskæg: I simply always load it. Just a habit when writing in another language than English and for better font quality. Not mandatory here. – Thorsten Donig Feb 10 '14 at 17:06

Here is a possible solution:




  \gamma(0) &= \alpha_1\gamma(1)   &&+ \alpha_2\gamma(2)   &&+ \cdots &&+ \alpha_p\gamma(p)  &&+ \sigma^2 \\
  \gamma(1) &= \alpha_1\gamma(0)   &&+ \alpha_2\gamma(1)   &&+ \cdots &&+ \alpha_p\gamma(p-1)&& \\
            &\vdotswithin{=} \\
  \gamma(p) &= \alpha_1\gamma(p-1) &&+ \alpha_2\gamma(p-2) &&+ \cdots &&+ \alpha_p\gamma(0)  &&



share|improve this answer

The accepted answer is definitely the way to go, but if ever you're stuck on a desert island and you don't have the amsmath package, an array environment can do some of the work- there are deficiencies (such as the alignment of the \vdots and the need for extra {}), but it does get some of the job done.


% arara: pdflatex
% !arara: indent: {overwrite: on}
        \gamma(0) & {}=\alpha_1\gamma(1)    & {}+\alpha_2\gamma(2)   & {}+{}\cdots {} &   & {}+\alpha_p\gamma(p)   & {}+\sigma^2 \\
        \gamma(1) & {} =\alpha_1\gamma(0)   & {}+\alpha_2\gamma(1)   & {}+{}\cdots {} &   & {}+\alpha_p\gamma(p-1) &             \\
                  & \vdots                  &                        &                &   &                        &             \\
        \gamma(p) & {} =\alpha_1\gamma(p-1) & {}+\alpha_2\gamma(p-2) & {}+{}\cdots {} &   & {}+\alpha_p\gamma(0)   &
share|improve this answer
Looks good, thanks! – DatamineR Feb 10 '14 at 16:36
The alignment of the plusses are wrong. Also, the horizontal dots should be \cdots and the \vdots is also aligned wrong. – Svend Tveskæg Feb 10 '14 at 16:39

This is using the under-development tabstackengine package, first introduced here at Writing a table with equally spaced columns, based on the widest column (source code available at Measuring align).

The package extends the stackengine package by adding tabbing capability. This answer, Can I tab inside of align environment?, gives some of the syntax of the package. I apologize that I have been lax in completing the package and getting it out the door, so the only way to see it in action is by searching this site for tabstackengine.

The spacing between columns is set by \setstacktabbedgap{1em}. The interline spacing by \setstackgap{L}{1.4\baselineskip}.

\gamma(0)&=\alpha_1\gamma(1)&+\alpha_2\gamma(2)&+&\dots&+\alpha_p\gamma(p)&+\sigma^2 \\
\gamma(1)&=\alpha_1\gamma(0)&+\alpha_2\gamma(1)&+&\dots&+\alpha_p\gamma(p-1) \\
\protect\raisebox{-2.5pt}{\vdots} \\

enter image description here

If one wanted the \vdots under the equal sign, at the expense of an additional package (mathtools), the third row of the tabbed stack could be made as

&\protect\raisebox{-2.5pt}{$\protect\vdotswithin{=}$} \\

to achieve a result that looks like

enter image description here

share|improve this answer
Your suggestion brings the desired output but I would prefer not using additional package. – DatamineR Feb 10 '14 at 16:41
@JohnnyB Understood. It is always a trade-off. I eliminated amsmath from my answer, but you will most likely employ it for your other math needs. – Steven B. Segletes Feb 10 '14 at 16:42
The aligment points and the dots are wrong. – Svend Tveskæg Feb 10 '14 at 16:43
@SvendTveskæg If you mean the \vdots are out of vertical kilter, I see that and have fixed it. What else to you mean by "alignment points"? Do you mean that the ... should be centered between the two plus signs? I fixed that, too. – Steven B. Segletes Feb 10 '14 at 16:48
I think it looked different when I posted the previous comment; now it is only the \vdots. Shouldn't they be aligned under = as in Thorsten's and my answers? – Svend Tveskæg Feb 10 '14 at 16:54

If you feel brave enough (and have recently read Ch. 22 of the TeXbook) you can always try doing it the plain TeX way.

\vcenter{\openup6pt\halign{\hfil$\gamma(#)={}$&$#$\hfil &&${}+#\hfil$\cr
0 & \alpha_1\gamma(1) & \alpha_2\gamma(2) & \cdots & \alpha_p\gamma(p) & \sigma^2 \cr
1 & \alpha_1\gamma(0) & \alpha_2\gamma(1) & \cdots & \alpha_p\gamma(p-1)\cr
\omit \hfil$\vdots$\enspace\cr
p & \alpha_1\gamma(p-1) & \alpha_2\gamma(p-2) & \cdots & \alpha_p\gamma(0)\cr

Notice how you can move repeated parts of the display into the preamble, and that you can use \omit to omit the boiler plate where you don't want it. enter image description here

share|improve this answer
Really cool solution! – Svend Tveskæg Feb 11 '14 at 0:23

Your Answer


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.