3

How is it possible to sort equations align with their = like this:

a*b*c = d*e*f
  g*h = i*j
    k = l*m*n
o*p*q = r

I've seen it before but I don't know how to find that!

5
  • I found something like want I seek in this answer tex.stackexchange.com/questions/43536/… but not sure if it's the answer.
    – sajjadG
    Aug 5, 2013 at 14:37
  • 2
    Are your asking for alignment of equations? Standard latex has eqnarray, which is better replaced by the align from amsmath. Aug 5, 2013 at 14:37
  • 3
    Take a look at Stefan Kottwitz's blog post at texblog.net/latex-archive/maths/eqnarray-align-environment, which compares different methods of aligning equations (in a nutshell: use \begin{align} with \usepackage{amsmath})
    – Jake
    Aug 5, 2013 at 14:38
  • 2
    The word align is the right word. The amsmath package provides the align environment (amongst others). Insert an ampersand & before every = and add \\ after every line and you’re good to go. For more, check the amsmath manual or the align tag. Aug 5, 2013 at 14:38
  • @AndrewSwann yes alignment was what I was looking for. thanks for mentioning eqnarry.@Jake Thanks man. The link was awesome. nothings better than a simple example which was on that site.@Qrrbrbirlbel Thanks you. you mentioned the pitfalls. very good. Thanks all you guys I solved my problem with your comments.
    – sajjadG
    Aug 5, 2013 at 14:52

2 Answers 2

5

You're looking for the align environment which is provided by amsmath.

In the code below, an ampersand (&) denotes a vertical alignment point. Every line in the align environment will be aligned such that all ampersands are vertically aligned.

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
    a*b*c &= d*e*f\\
    g*h &= i*j\\
    k &= l*m*n\\
    o*p*q &= r% \\ is not needed in this line!
\end{align}

\end{document}
1
1

If you need equation numbers, there are 2 options as follows.

An equation number for each line

\documentclass[preview,border=10pt]{standalone}% change it back to
%\documentclass{article}

\usepackage{amsmath}

\begin{document}
\abovedisplayskip=0pt\relax% for my own purpose, remove this line!

\begin{align}
    a*b*c &= d*e*f\\
    g*h &= i*j\\
    k &= l*m*n\\
    o*p*q &= r% no \\ in this line!
\end{align}

\end{document}

enter image description here

An equation number for the whole as a group

\documentclass[preview,border=10pt]{standalone}% change it back to
%\documentclass{article}

\usepackage{amsmath}

\begin{document}
\abovedisplayskip=0pt\relax% for my own purpose, remove this line!

\begin{equation}
\begin{split}
    a*b*c &= d*e*f\\
    g*h &= i*j\\
    k &= l*m*n\\
    o*p*q &= r% no \\ in this line!
\end{split}
\end{equation}

\end{document}

enter image description here

But if you don't need equation numbers, replace align with align* or equation with equation*. \[ ... \] can also be used for the latter case!

Note: equation+split versus equation+aligned can be found here.

2
  • 1
    For the latter equation + split is better. aligned is for inline mode (not inline math-mode but inline alignment). See also this answer of mine. And no, I have no better source to support that. Aug 23, 2013 at 9:00
  • 1
    To handle the case of a single number for the entire set of equations for which only one alignment point is needed, I'd say you're better off using the split environment instead of the aligned environment.
    – Mico
    Aug 23, 2013 at 9:11

You must log in to answer this question.

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