7

How to align equations as in the image below?

enter image description here

Update: I try using array but it takes so much work to align everything in order. For example, I need to know how many columns I need to perform the alignment.

Idonknow
  • 777
  • 9
    use the align environment from the amsmath package. there are many examples of its use in this forum. – barbara beeton Nov 10 '14 at 18:33
  • 4
    -1: This post does not show any research effort. As @barbarabeeton mentions, there are many examples of its use on this site. You may consider reviewing Herbert's mathmode document to familiarize yourself with the various align-like environments. – Werner Nov 10 '14 at 19:11
  • 3
    This question appears to be off-topic because it is about a matter that could be resolved by consulting a basic latex manual. – Ian Thompson Nov 10 '14 at 19:37
  • 8
    Please don't downvote below -1. A score of -1 is enough to show that the question needs work. On this site, multiple negative votes are typically reserved for vandalism or spam posts. Please give the poster a chance to revise their question by leaving helpful comments like barbara or Werner did, and not just piling on downvotes within an hour of the question being posted. Also, remember to come back and revert your downvote once the question is improved. – Jake Nov 10 '14 at 19:58
  • @Sveinung --- I didn't downvote. – Ian Thompson Nov 10 '14 at 22:59
  • 1
    @barbarabeeton How can this question be off-topic? It is a relevant question regarding formatting of equations! Be it that the OP could have shown more effort, but if a question is of topic because you can find the answer in a manual, egreg, David Carlisle, Heiko Oberdiek et. al may flag all questions at this site as off-topic. There is no item in the help centre that make this question off topic, as far as I can see. The OP ask for an alternative to the array-environment! – Sveinung Nov 11 '14 at 09:09
  • @Sveinung -- the real reason for putting this on hold is that it shows no evidence of research effort. as noted in my initial comment, there are many examples of its use in this forum. and the title contains the term "align", a good search term. however, the managers of this site have provided only a few reasons that can be chosen, and the (unfortunately) "best fit" is "off topic". see the comment by ian thompson. see also the discussion on the meta list, Text for 'off-topic' closure. – barbara beeton Nov 11 '14 at 13:24
  • @barbarabeeton But that is not a reason for closing according to the help centre. And giving a wrong reason for closing is a breach of the site policy, isn't it? – Sveinung Nov 11 '14 at 15:26
  • @Sveinung -- i'm merely a participant, albeit one with rather a lot of experience. i think this needs to be answered by the moderators. i'll pose the question on meta. – barbara beeton Nov 11 '14 at 15:47
  • 2
    @Sveinung For the record, I did *not* vote to close this as off-topic. I voted to close it as a duplicate. In my view, it is a significant weakness of the site software that it apparently takes account of conclusions but not reasons. (If you think it should have been left open, then we disagree. If you think it should not have been closed as off-topic, then I entirely agree.) – cfr Nov 11 '14 at 17:04
  • @barbarabeeton See comment above. (I can only ping one person at a time.) – cfr Nov 11 '14 at 17:05
  • 1
    @cfr The question seems to be a duplicate, I agree with you. But a duplicate is a duplicate, not off-topic. (Of course it can be both off-topic and a duplicate, but then you have two off-topic questions). But my real concern was the four down votes and the hash (unfriendly) tone in some of the comments. – Sveinung Nov 11 '14 at 19:17
  • @Sveinung I agree. I find it rather annoying that I'm on record as voting to close it as off-topic when I was deliberately not doing so! Agree about the harshness. 1 down-vote is sufficient. This one attracted a ridiculous number for no obvious reason. – cfr Nov 11 '14 at 21:47

2 Answers2

21

Using align and friends from amsmath:

enter image description here

\documentclass{article}
\usepackage{amsmath,mathpazo}
\newcommand{\deriv}[2][x]{\frac{\mathrm{d}#2}{\mathrm{d}#1}}
\begin{document}
\begin{align*}
  q u^{q-1} \deriv{u} &= p x^{p-1} \\
            \deriv{u} &= \frac{p x^{-1}}{q u^{-1}} \\
            \deriv{u} &= n x^{n-1}
\end{align*}
\end{document}
Werner
  • 603,163
14

This is pretty well answered but I'll try and make it simpler:

like others have said, you want to add \usepackage{amsmath} to your preamble, and then put the equations in an align environment.

\documentclass{article}
\usepackage{amsmath}

\begin{document}\noindent Equations with numbers: align \begin{align} 2 + 2 &= 4\ \frac{\sqrt{y}}{x^2} &= a \end{align} Equations without numbers: align* (the * removes the numbers) \begin{align} 2 + 2 &= 4\ \frac{\sqrt{y}}{x^2} &= a \end{align} The & symbol defines alignment points, it can go near any symbol or character and allows different placements: \begin{align} 1 & 2 & 3 & 4 & 5 & 6\ &&& 4 \ &&&&& 6 \end{align} This can be useful if you want \begin{align} \text{Labels over here} && 45 + 10 &= 55\ \text{and equations over there} && foo &= bar\ baz\ \text{while still aligned by the ``='' sign.} \end{align} \end{document}

Not sure if I actually made that easier, but I tried.

If you get the Paragraph ended before \align* was complete. error, it's because you can't have empty lines (which are interpreted as paragraph breaks) inside of an align environment.

Marck
  • 147
  • 7
Ryan
  • 2,914