14

I want to simultaneously have text left and right justified around an align environment. I'm able to do this, but my solution seems like a dreadful hack. I really don't want to prepend every line with &&. But && doesn't really get the text to be flush with the left. Does anyone have a better solution?

Here's my code:

\documentclass{article}
\usepackage{amsmath,amssymb,amsthm,mathtools}
\usepackage[margin=1in]{geometry}
\setlength{\parindent}{0pt}
\begin{document}
Establish the following identity:
    \[\cos^4\theta-\sin^4\theta=\cos(2\theta)\]
\begin{align*}%'
    \tag*{\makebox[0pt][l]{\hspace*{-\textwidth}\textbf{Proof:}}}
    \cos^4\theta-\sin^4\theta 
    &=     (1-\sin^2\theta)^2 - \sin^4\theta
    && \text{Use $\cos^2\theta=1-\sin^2\theta$}
    \\
    &    =    1 - 2\sin^2\theta + \sin^4\theta - \sin^4\theta
    \\
    &    =    1 - 2\sin^2\theta = \cos(2\theta) && \text{Double angle formula.}
\end{align*}
\end{document}

Result: enter image description here

David Carlisle
  • 757,742
A.Ellett
  • 50,533
  • Welcome to tex.sx! Note that if you indent your code by 4 spaces, it will be displayed as a code block. Alternatively, you can select the code and click the "code" ({}) button. – T. Verron Nov 22 '12 at 00:30
  • 1
    Welcome to TeX.SX! What is preventing you from writing "Proof" outside the align* environment? Having it on the same height as the first formula is not at all needed or desirable, in my opinion. – egreg Nov 22 '12 at 00:33
  • It's just an example. It's not the best example. I agree with your comment about "proof". The point is that this example achieves the effect I desire. I'm interested in a better way of achieving the effect. – A.Ellett Nov 22 '12 at 00:35
  • 4
    Left-aligned text "inside" align* is achieved using \intertext. See inserting sentences between subequations. – Werner Nov 22 '12 at 00:41
  • 1
    The problem with intertext is that it places the text between the lines. I want the text on the same line. – A.Ellett Nov 22 '12 at 00:42
  • 2
    flalign* really flushes left and right, but it still needs && hacks, as you said. – Manuel Nov 22 '12 at 00:50

1 Answers1

18

As one of the comments mentioned, I would use the not well-known flalign or flalign* environment, like in this example:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{flalign}
\text{Proof}    && a &= b &&\\
    && a &= b &&\\
    && a &= b && \text{some comment}\\
    && a &= b &&
\end{flalign}

\begin{flalign*}
\text{Proof}    && a &= b &&\\
    && a &= b &&\\
    && a &= b && \text{some comment}\\
    && a &= b &&
\end{flalign*}

\end{document}

This will result in:

enter image description here