2

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.

  • 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
  • 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
13

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

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 is defines alignmnet points, it can go near any 
    symbols or characters 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 alligned 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.

  • An instructive answer – Sveinung Nov 11 '14 at 9:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.