19

When I use {align*}, it shifts the expressions on the right of the = to the far right of the equation. But when I use {aligned}[t] it works normally. The following is the code:

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{align*}
  x + 3y + 4z &=& 2\\
  3y - 4z &=& 5\\
  3 &=& 4
\end{align*}\\
$ \! \begin{aligned}[t]
        x + 3y + 4z &=& 2\\
        3y - 4z &=& 5\\
        3 &=& 4
     \end{aligned}$
\end{document}

enter image description here

I've searched this question but the answers are usually about other ways of writing it without explanation. So what is the purpose of \!, [t] and how is aligned different from align?

3
  • Single & is marking the alignment, not two around =, remove the latter one on each line
    – daleif
    Commented Nov 14, 2017 at 6:58
  • 1
    align is a full math display, aligned is just an alignment building block. Commented Nov 14, 2017 at 7:19
  • your aligned version doesn't work normally as you show in the image it is also setting the = with incorrect spacing and the right hand side is also flush right (but hard to see as you just have single digits) Commented Nov 14, 2017 at 8:54

1 Answer 1

36

You're using the environments incorrectly. Here's how you could (should...) use them:

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
  x + 3y + 4z &= 2 \\
      3y - 4z &= 5 \\
            z &= 4
\end{align*}

\[
  \begin{aligned}[t]
    x + 3y + 4z &= 2 \\
        3y - 4z &= 5
              x &= 4
  \end{aligned}
\]

\end{document}

Some things to note:

  • The alignment around the relation = is made using a single & on the left. This differs from the eqnarray usage of & other both sides of the relation.

  • align* sets an unnumbered alignment that is always centred with respect to the text block.

  • aligned sets a block with a similar interface to align* that can be used as inline math or within a display setting. The optional parameter allows you to specify a vertical alignment parameter with respect to the surrounding content. As an example, see

    enter image description here

    Before
    $\begin{aligned}[t]
      a &= b \\
      c &= d
    \end{aligned}$
    between
    $\begin{aligned}
      a &= b \\
      c &= d
    \end{aligned}$
    after
    $\begin{aligned}[b]
      a &= b \\
      c &= d
    \end{aligned}$
    end.
    
3
  • Is there a document mentioning the parameter of aligned?
    – IvanaGyro
    Commented Oct 2, 2022 at 16:10
  • 2
    @IvanaGyro: See p 9 of the amsmath User Guide: "Like the array environment, these -ed variants also take an optional [t], [b] or the default [c] argument to specify vertical positioning."
    – Werner
    Commented Oct 3, 2022 at 19:28
  • Thank you for providing this information.
    – IvanaGyro
    Commented Oct 4, 2022 at 17:45

You must log in to answer this question.

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