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.

How can I align my equations as in the image below?

enter image description here

I know

\begin{equation}
    \begin{split}
        x_1'(t) &= x_1(t)+2 x_2(t) \\
        x_2'(t) &= 3 x_1(t)
    \end{split}
\end{equation}

but it will only align the equal signs and not the variables.

share|improve this question
1  
Please make your code compilable (if possible), or at least complete it with \documentclass{...}, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. –  Jubobs Dec 8 '13 at 19:05
2  
Why? These is not much reason to align more than one place in this set of equations –  daleif Dec 8 '13 at 19:19
    
Very similar to tex.stackexchange.com/q/35174/15925 –  Andrew Swann Dec 8 '13 at 19:48
1  
@AndrewSwann - The \systeme approach mentioned in one of the answers in your link won't work in the present case, as it'll insist on placing the variables x_1'(t) and x_2'(t) in different columns... –  Mico Dec 8 '13 at 20:22

3 Answers 3

You can use

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{alignat*}{3}
  x_1'(t) &=  &x_1(t) &{}+{}& 2&x_2(t)\\
  x_2'(t) &= 3&x_1(t) &     &  &
\end{alignat*}

\end{document}

output

Notice that I have added three alignment points in case you need to vertically align the second factor on the right-hand side too.

I hope it's clear how to extend this is more than three alignment points. (Fore n alignment points, 2n-1 &'s are needed.)

P.S. Remember the use of {} to get the correct spacing.

Update

In case you don't need more than two alignment points, you can use the following:

\begin{alignat*}{2}
  x_1'(t) &={}&  &x_1(t) + 2x_2(t)\\
  x_2'(t) &={}& 3&x_1(t)
\end{alignat*}
share|improve this answer
    
In alignat, the columns are alternately right and left aligned. With the first example, the coefficients are left aligned and the variables are right aligned. This looks bad when coefficients have different numbers of digits, or if the x_1(t) needs to align with x_1(2t). In the second example, the extra & makes for better alignment in such cases. –  Dan Dec 9 '13 at 2:54
    
@Dan Thanks. I've updated my answer. –  Svend Tveskæg Dec 9 '13 at 14:08

Simple array:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
%    \begin{split}
\begin{array}{r@{\;}r@{}l}
        x_1'(t) =& x_1(t)&{}+2 x_2(t) \\
        x_2'(t) =& 3 x_1(t)&
%    \end{split}
\end{array}
\end{equation}
\end{document}

enter image description here

Probably vertical spacing needs some correction by adding a suitable length after \\. BTW: one can induce that an image in your example is an effect of just array, but without the correction of \arraycolsep. The spacing around + and = signs is too big.

share|improve this answer

Especially if your system of equations is fairly small -- as is the case with the example you've posted -- you could simply use \phantom directives: They insert whitespace equivalent to their arguments. (However, if the system of equations gets larger, it may be worth incurring the overhead associated with the other proposed methods.)

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
    \begin{split}
        x_1'(t) &= \phantom{3}x_1(t)+2 x_2(t) \\
        x_2'(t) &= 3 x_1(t)
    \end{split}
\end{equation}
\end{document}
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.