13

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

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

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

| improve this answer | |
  • Is the only difference between the * and non-star versions the numbering? – soandos Oct 3 '13 at 16:22
  • @soandos: As far as I know: Yes. – Dr. Manuel Kuehner Oct 3 '13 at 17:22
  • The correct command is flalign as in the example code. The answer is good otherwise. – Yvon Feb 5 '19 at 1:17

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.