13

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.

4
  • 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.
    – jub0bs
    Dec 8, 2013 at 19:05
  • 2
    Why? These is not much reason to align more than one place in this set of equations
    – daleif
    Dec 8, 2013 at 19:19
  • Very similar to tex.stackexchange.com/q/35174/15925 Dec 8, 2013 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, 2013 at 20:22

4 Answers 4

18

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 to 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 around the +.

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*}
1
  • 1
    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, 2013 at 2:54
10

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}
0
9

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.

2

It is possible to use also systeme.

enter image description here

\documentclass{article}
\usepackage{systeme,mathtools}
\sysdelim..
\newlength\mylen
\settowidth\mylen{$x_2'(t)$}
\begin{document}
\[
\systeme{
x_1'(t) \hspace{-\mylen} = x_1(t)+2 x_2(t),
x_2'(t)  = 3 x_1(t)}
\]
\end{document}
2
  • Dear Mico, thanks a lot for your suggestion. You are authorized to change my answer. Could you please do that? Often I do not understand the technical and suggestions because for me are new indications.
    – Sebastiano
    Oct 4, 2017 at 6:08
  • 1
    I've gone ahead and edited your answer per my earlier suggestion.
    – Mico
    Oct 4, 2017 at 6:17

You must log in to answer this question.

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