1

Running the following example

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\hrule
\begin{gather}
    \sin{2x}=2\sin{x}\cos{x}\\
    \begin{align}
        \cos{2x}&=\cos^2{x}-\sin^2{x}\\ 
                &=1-2\sin^2{x}\\
                &=2\cos^2{x}-1
    \end{align}
\end{gather}
\hrule
\end{document}

generates this:

enter image description here

I would like to create the text as above but without equation numbers.

Using gather* and align* in the following code

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\hrule
\begin{gather*}
    \sin{2x}=2\sin{x}\cos{x}\\
    \begin{align*}
    \cos{2x}&=\cos^2{x}-\sin^2{x}\\ 
                &=1-2\sin^2{x}\\
                &=2\cos^2{x}-1
    \end{align*}
\end{gather*}
\hrule
\end{document}

generates this:

enter image description here

Why does the lack of equation numbers cause the aligned portion of the text to no longer be centered, and how can it be centered?

Thanks for your time.

2
  • Maybe \documentclass{article} \usepackage{amsmath} \begin{document} \hrule \begin{align} \sin{2x}&=2\sin{x}\cos{x}\\ \cos{2x}&=\cos^2{x}-\sin^2{x}\notag\\ &=1-2\sin^2{x}\notag\\ &=2\cos^2{x}-1 \end{align} \hrule \end{document}?
    – user194703
    Sep 16, 2019 at 3:13
  • That's close to what I was trying to do, except for the equation numbers on the first and fourth line. In addition to the other two lines, adding \notag to the second and third removes the equation numbers. However, the equal sign of the first line is aligned with the other three, and I wanted to see if there was a way to center the first line instead.
    – user197543
    Sep 16, 2019 at 11:08

1 Answer 1

3

You had not nested align* inside any math environment. For such cases is defined in the amsmath package aligned:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\hrule
\begin{gather*}
    \sin{2x}=2\sin{x}\cos{x}\\
    \begin{aligned} % <------------
    \cos{2x}&=\cos^2{x}-\sin^2{x}\\
                &=1-2\sin^2{x}\\
                &=2\cos^2{x}-1
    \end{aligned}
\end{gather*}
\hrule

\medskip
but, what you not use simple the following :

\medskip
\hrule
\begin{align*}
    \sin{2x} & = 2\sin{x}\cos{x}\\
    \cos{2x} & =  \cos^2{x}-\sin^2{x}\\
             & = 1-2\sin^2{x}\\
             & = 2\cos^2{x}-1
    \end{align*}
\hrule

\end{document}

enter image description here

2
  • Thanks for your answer. I chose not to align the equal signs of the first and second identities because the two are not equal, and I thought that aligning the equal signs implies that they are.
    – user197543
    Sep 16, 2019 at 2:14
  • 2
    @AndrewFK, how you like to write your equation, is up to you. However, the first example solves your problem, doesn't it?
    – Zarko
    Sep 16, 2019 at 2:23

You must log in to answer this question.