59

I am trying to align a multiline equation using array within the equation but it turns out it doesn't do very well. The code I am using is as follows:

\begin{equation}    \begin{array}{lcl}
\mathcal{L}^{-1}\left\{f(d)\right\} &= \mathcal{L}^{-1}\left\{f_1(\delta).f_2(\delta)\right\} \\
& = exp(mt) \star \left\{\frac{l}{2\sqrt{\pi t^3}} exp(-l^2/{4t})\right\} \\
& = F_1 * F_2
\end{array}
\end{equation}

Can anyone suggest better way to deal with it ?

3 Answers 3

81

array is not designed for aligning equations, it is designed for arrays and matrices. The amsmath package has a host of alignment environments, I give a couple of examples:

enter image description here

\documentclass{article}

\usepackage{amsmath}


\begin{document}

\begin{align}
\mathcal{L}^{-1}\left\{f(d)\right\} &= \mathcal{L}^{-1}\left\{f_1(\delta).f_2(\delta)\right\} \\
& = \exp(mt) \star \left\{\frac{l}{2\sqrt{\pi t^3}} \exp(-l^2/{4t})\right\} \\
& = F_1 * F_2
\end{align}

or

\begin{equation}
\begin{aligned}
\mathcal{L}^{-1}\left\{f(d)\right\} &= \mathcal{L}^{-1}\left\{f_1(\delta).f_2(\delta)\right\} \\
& = \exp(mt) \star \left\{\frac{l}{2\sqrt{\pi t^3}} exp(-l^2/{4t})\right\} \\
& = F_1 * F_2
\end{aligned}
\end{equation}

\end{document}

note that exp is a multi-letter identifier so shouldn't be set in math italic.

6
  • @ David: That was very quick and works perfect. Thank you so much for your time and effort. I found this post and tried to follow that kogler.wordpress.com/2008/03/21/…
    – Jdbaba
    Mar 27, 2013 at 23:00
  • The second example works better in this case. If I use \begin{align} then it would put three equations on three lines. I just want only one.
    – Jdbaba
    Mar 27, 2013 at 23:02
  • @Jdbaba yes you can suppress two of the three numbers in aligned (\notag) sometimes things are clearly one long equation that you need to wrap, for chained = you can think of it as lots of equations or one long one, anyway it's your document you can get to choose (there are other choices such as gathered and split as well...) Mar 27, 2013 at 23:08
  • The following equation do not align using aligned. Is there any reason ? \begin{equation} \begin{aligned} F_1 \star F_2 = \int_0^t e^{m(t-\tau)} \frac{l}{2\sqrt{\pi t^3}} e^{\frac{-l^2}{4t}} \& = \frac{l e^{mt}}{2\pi^{1/2}}\int_0^t \frac{e^{(-(m\tau+l^2/{4t}))}}{\tau ^{3/2}} \end{aligned} \end{equation}
    – Jdbaba
    Mar 27, 2013 at 23:12
  • 1
    don't you want a & before the first = ? Mar 27, 2013 at 23:14
8

David's solution is the correct way to go for this case, but you can use array for this and sometimes it does come in handy:

enter image description here

So, the changes required are:

  • Your second column should have been left aligned, not right aligned.
  • You need to eliminate the inter column spacing using @{}, and use &{}= to get the proper math spacing around the equal signs.
  • You should use \exp instead of exp as that is an operator and not a variable.
  • Perhaps use \cdot instead of . (unless the lower dot notation is something I am not familiar with).

As David Carlisle commented, this formulas are displayed in the cramped \textstyle. If you desire the \displaystyle you need to add \displaystyle where it is needed (in this case the second line) to obtain:

enter image description here

Or, if you include the array pacakge then you can include the >{\displaystyle} style to the column specification (as illustrated in last part of MWE).


Code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\begin{document}\noindent
Without \verb|\displaystyle|:
\begin{equation}
\begin{array}{l@{}l}
\mathcal{L}^{-1}\left\{f(d)\right\} 
    &{}= \mathcal{L}^{-1}\left\{f_1(\delta) \cdot f_2(\delta)\right\} \\
    &{}= \exp(mt) \star \left\{\frac{l}{2\sqrt{\pi t^3}} \exp(-l^2/{4t})\right\} \\
    &{}= F_1 * F_2
\end{array}
\end{equation}
With \verb|\displaystyle|:
\begin{equation}
\begin{array}{l@{}l}
\mathcal{L}^{-1}\left\{f(d)\right\} 
    &{}= \mathcal{L}^{-1}\left\{f_1(\delta) \cdot f_2(\delta)\right\} \\
    &{}= \displaystyle\exp(mt) \star \left\{\frac{l}{2\sqrt{\pi t^3}} \exp(-l^2/{4t})\right\} \\
    &{}= F_1 * F_2
\end{array}
\end{equation}
With \verb|\displaystyle| and \verb|array| package:
\begin{equation}
\begin{array}{l@{}>{\displaystyle}l}
\mathcal{L}^{-1}\left\{f(d)\right\} 
    &{}= \mathcal{L}^{-1}\left\{f_1(\delta) \cdot f_2(\delta)\right\} \\
    &{}= \exp(mt) \star \left\{\frac{l}{2\sqrt{\pi t^3}} \exp(-l^2/{4t})\right\} \\
    &{}= F_1 * F_2
\end{array}
\end{equation}
\end{document}

You can eliminate the need for using &{}= by burying that in the array column spec:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{equation}
\begin{array}{l@{{}={}}l}
\mathcal{L}^{-1}\left\{f(d)\right\} 
    & \mathcal{L}^{-1}\left\{f_1(\delta).f_2(\delta)\right\} \\
    & \exp(mt) \star \left\{\frac{l}{2\sqrt{\pi t^3}} \exp(-l^2/{4t})\right\} \\
    & F_1 * F_2
\end{array}
\end{equation}
\end{document}
3
  • 2
    Note that this will set the equation in \textstyle not \displaystyle Mar 27, 2013 at 23:13
  • @DavidCarlisle: Wow, can't believe I have never noticed that yet. I got me some checking to do in my docs. :-) Mar 27, 2013 at 23:16
  • 1
    You can use array package and >{\displaystyle}l... Mar 27, 2013 at 23:17
3

I always need to line up equals signs outside of a math environment, the best thing I found was to use center and tabular. This was best for lining up my equals signs in proofs, and in variable descriptions.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
\int_{a}^{b} f(x) dx \approx h \left[ \dfrac{f(a)}{2} + \sum_{i=1}^{\eta} f(x_i) + 
\dfrac{f(b)}{2}\right]
\end{equation}

where

\begin{center}\begin{tabular}{ccl}\
$a, b$ & = & bounds of integration (endpoints of interval) \\
$f(x)$ & = & function \\
$h$ & = & step size \\
$\eta$ & = & number of trapezoids
\end{tabular}\end{center}

enter image description here

1
  • 1
    Welcome to TeX.SE! The empty lines before and after the word "where" are wrong. Apart from that, this does not really answer the question. Your answer has more to do with tex.stackexchange.com/q/95838/82917.
    – campa
    Feb 5, 2020 at 16:40

You must log in to answer this question.

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