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

6
  • 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, 2012 at 0: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, 2012 at 0:33
  • 4
    Left-aligned text "inside" align* is achieved using \intertext. See inserting sentences between subequations.
    – Werner
    Nov 22, 2012 at 0: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, 2012 at 0:42
  • 2
    flalign* really flushes left and right, but it still needs && hacks, as you said.
    – Manuel
    Nov 22, 2012 at 0:50

1 Answer 1

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

2
  • Is the only difference between the * and non-star versions the numbering?
    – soandos
    Oct 3, 2013 at 16:22
  • @soandos: As far as I know: Yes. Oct 3, 2013 at 17:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .