3
\begin{align*}
    2\sin2\theta+1=0\\
    \sin2\theta=-\dfrac{1}{2}\\
    \alpha&=\sin^{-1}\left(\dfrac{1}{2}\right)\\
    &=\dfrac{\pi}{6}\\
    2\theta=\pi+\alpha,2\pi-\alpha,3\pi+\alpha,4\pi-\alpha
\end{align*}

produces

enter image description here

However, I would like all equations to be flushed right, except the line = π/6 that should be aligned with previous equal sign.

ebosi
  • 11,692
Eugene
  • 928

1 Answers1

4

Answer: The trick is to nest an aligned environment within the align* one.


Background

Indeed, you want a local alignment (the two-line equality), within a global alignment (flushed right). The aligned environment created a fixed block, that is itself positioned relatively to the other lines.
(As explained here align* environment creates a math-mode. So when you already are in a math-mode, you should then use an aligned-environment.)

In both align* and aligned environments, you must write your equations on separated line. You indicate that a new line starts with \\. Then, to know how/where to align these lines, these environments use the 'key' &. They flush-right or flush-left the as following:

                         right flushed text & left flushed text                           &             right flushed text & left flushed text      \\
loooooooong text that defines the alignment & some text                                   &                      some text & lorem ipsum            \\
                                      lorem & some other text                             & always the same story about lengths & lorem ipsum       \\
                                  some text & loooooooong text that defines the alignment &                          lorem & some other text        \\

MWE

enter image description here

\documentclass{scrartcl}
    \usepackage{amsmath}
\begin{document}
    \begin{align*}
        2\sin2\theta+1=0                                        &\\
        \sin2\theta=-\dfrac{1}{2}                               &\\
        \begin{aligned}
            \alpha  &=\sin^{-1}\left(\dfrac{1}{2}\right)\\
                    &=\dfrac{\pi}{6}
        \end{aligned}                                           &\\
        2\theta=\pi+\alpha,2\pi-\alpha,3\pi+\alpha,4\pi-\alpha  &\\
    \end{align*}
\end{document}
ebosi
  • 11,692
  • What is the & before the \ for? – Eugene Jun 14 '16 at 10:07
  • 1
    & defines where equations should align, so if you put them at the end of the line, you artificially ask for flushed right (i.e. aligned at the end of the line) equations – ebosi Jun 14 '16 at 10:10