[Tex/LaTex] Difference between {align} and {aligned}[t]

alignequations

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?

Best Answer

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.