7

This is the formula I want to be made in LaTeX.

This is my old big formula

The problem is to make this formula aligned. I've made something like this

\begin{gather}
1 = \cos \, (\bar x, \bar x) = \cos^2 \, (\bar x, x) + \cos^2 \, (\bar x, y) + \cos^2 \, (\bar x, z) = \notag \\
\begin{array}{rl}
= & \alpha_1^2 + \beta_1^2 + \gamma_1^2 = 1, \\
& \alpha_2^2 + \beta_2^2 + \gamma_2^2 = 1, \\
& \alpha_3^2 + \beta_3^2 + \gamma_3^2 = 1, \\
\end{array}
\tag{5} \\
0 = \cos \, (\bar y, \bar z) = \cos \, (\bar y, x) \cos \, (\bar z, x) + \cos \, (\bar y, y) \cos \, (\bar z, y) + \cos \, (\bar y, z) \cos \, (\bar z, z) = \notag \\
\begin{array}{rl}
= & \alpha_2 \alpha_3 + \beta_2 \beta_3 + \gamma_2 \gamma_3 = 0, \\
& \alpha_3 \alpha_1 + \beta_3 \beta_1 + \gamma_3 \gamma_1 = 0, \\
& \alpha_1 \alpha_2 + \beta_1 \beta_2 + \gamma_1 \gamma_2 = 0. \\
\end{array}
\notag
\end{gather}

And I've got this New one

Do you have any ideas how to make it look more pretty?

P. S. I use MikTeX on Windows.

7

Your friend is the aligned environment that takes a vertical placement argument t or b:

Sample output

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{gather}
  \begin{aligned}[b]
    1 = \cos (\bar x, \bar x)
    &= \cos^2 (\bar x, x) + \cos^2 (\bar x, y) + \cos^2 (\bar x, z)
    = 
    \\
    &\!\begin{aligned}[b]
      {}={}
      \alpha_1^2 + \beta_1^2 + \gamma_1^2 &= 1, \\
      \alpha_2^2 + \beta_2^2 + \gamma_2^2 &= 1, \\
      \alpha_3^2 + \beta_3^2 + \gamma_3^2 &= 1, \\
    \end{aligned}
  \end{aligned}
  \tag{5} \\
  \begin{gathered}
    0 = \cos (\bar y, \bar z)
    = \cos (\bar y, x) \cos (\bar z, x) + \cos (\bar y, y) \cos
    (\bar z, y) + \cos (\bar y, z) \cos (\bar z, z) =\\ 
    = \begin{aligned}[t]
      \alpha_2 \alpha_3 + \beta_2 \beta_3 + \gamma_2 \gamma_3 &= 0, \\
      \alpha_3 \alpha_1 + \beta_3 \beta_1 + \gamma_3 \gamma_1 &= 0, \\
      \alpha_1 \alpha_2 + \beta_1 \beta_2 + \gamma_1 \gamma_2 &= 0. \\
    \end{aligned}
  \end{gathered}
  \notag
\end{gather}

\end{document}

Note that it appears to me that the final collections of equations are aligned on their equals signs rather than their first character.

In the first equation the (old fashioned) equals before these equations was included in the aligned block to get correct placement of the equation number. A quirk of aligned is that it adds a thin space \, at its start, so this has to be cancelled with a \!. Spacing around = depends on the surrounding characters, hence the {}={} combination in the first aligned block.

I have collected the second equation in to one gathered block, so that one only needs one \notag.

1

or just use align and put & on proper place:

\documentclass[prewiev]{article}
    \usepackage{empheq}
\begin{document}
        \begin{align}
1 = \cos(\bar{x},\bar{x})
    =   & \cos^2(\bar{x},x) + \cos^2(\bar{x},y) + \cos^2(\bar{x},z) =   \notag \\ 
    =   & \alpha_1^2 + \beta_1^2 + \gamma_1^2 = 1,                      \notag  \\
        & \alpha_2^2 + \beta_2^2 + \gamma_2^2 = 1,                      \notag  \\
        & \alpha_3^2 + \beta_3^2 + \gamma_3^2 = 1,                      \tag{5} \\
0 = \cos (\bar{y},\bar{z}) = \cos(\bar{y},x)
        &   \cos(\bar{z},x) + \cos(\bar{y},y)\cos(\bar{z},y)
                            + \cos(\bar{y},z)\cos(\bar{z},z) =          \notag  \\
    =   & \alpha_2 \alpha_3 + \beta_2 \beta_3 + \gamma_2 \gamma_3 = 0,  \notag  \\
        & \alpha_3 \alpha_1 + \beta_3 \beta_1 + \gamma_3 \gamma_1 = 0,  \notag  \\
        & \alpha_1 \alpha_2 + \beta_1 \beta_2 + \gamma_1 \gamma_2 = 0.  \notag
        \end{align}
\end{document}

enter image description here

2
  • Isn't that just pure luck then that the three last = align? – daleif Jan 3 '14 at 11:41
  • Now the spacing infront of \alpha_1^2 and \alpha_2\alpha_3 is wrong. Remember, if you align to the right of a relation then use ` {} & ` of the space after the relation comes out wrong. – daleif Jan 3 '14 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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