# How can I typeset LaTeX math proofs with long lines?

I usually typeset math proofs in LaTeX by using the align environment. For instance,

\documentclass{article}
\usepackage{amsmath,mathtools}
\begin{document}
\begin{align}
& x^2 \\
&= x*x \\
&= x+x
\end{align}
\end{document}


This works great, until the lines become too long to fit on the page. Ideally, I'd like to use something like the multline environment on one line to accomplish this. For instance, I'd like overly long lines to wrap, while still aligning, like this:

= x+x+x+x+x+x+x+x+x+x+x+x+x+
x+x+x+x+x+x+x+x
= y+y+y+y+y+y+y+y+y+y+y+y+y+y+y


Using multlined from the mathtools package inside of align results almost works:

\begin{align}
& \begin{multlined}x+x+x+x+x+x+x+x+x+x+x+x\\x+x+x+x+x+x+x+x\end{multlined}\\
&= y+y+y+y+y+y+y+y+y+y+y+y+y+y+y
\end{align}


Unfortunately, the second multiline equation aligns to the rightmost part of the first multiline equation, rather than aligning to the right of the align block, which looks very awkward:

Manually specifying a width to multlined so that it fills the align block results in something that looks half-decent, but feels hacky:

\begin{align}
& \begin{multlined}[c][3.63in]x+x+x+x+x+x+x+x+x+x+x+x\\x+x+x+x+x+x+x+x\end{multlined}\\
&= y+y+y+y+y+y+y+y+y+y+y+y+y+y+y
\end{align}


Is there a better way of handling long lines in proofs?

-
this is a good questionm and i'd like to add a request for a good answer to the amsmath request list. please send an actual workable example or two to tech-support@ams.org and i will put it on our list, to be considered for the next upgrade. –  barbara beeton May 4 '11 at 20:24
This seems to be a bug that I can not reproduce anymore with mathtools package 1.12. –  mafp Dec 5 '12 at 21:46
@mafp I just tried with mathtools 1.12 and got the same behavior. In particular, the lines of the equations are flushed left. This looks ugly in a larger proof that uses the full width of the text area. –  Ed McMan Dec 6 '12 at 18:17
@EdMcMan That is odd. Then maybe it is a regression in amsmath? My package is old: version 2.13. As I said, it works for me, the multilined block starts on the same horizontal position as the equal sign of the equation below. Did you do as Barbara asked, and contacted ams.org? –  mafp Dec 6 '12 at 20:45
@mafp I was mistaken. The second multiline is not left aligned, but is right aligned to the first multiline. I edited the example in my question to make this apparent. It should now be possible to see the real problem, which was not clear before the edits: the second multiline should be right aligned to the align environment, not the multiline environment. I hope the question is more clear now! –  Ed McMan Dec 7 '12 at 16:35
show 1 more comment

## migrated from stackoverflow.comMay 3 '11 at 20:15

This question came from our site for professional and enthusiast programmers.

You have known Morten Høgholm's mathtools, then you can try his breqn package:

\documentclass{article}
\usepackage{breqn}

\begin{document}
\hsize=12cm
\begin{dmath}
f(x) = x+x+x+x+x+x+x+x+x+x+x+x+x+x+x+x+x = x*c
\end{dmath}

\hsize=6cm
\begin{dmath}
f(x) = x+x+x+x+x+x+x+x+x+x+x+x+x+x+x+x+x = x*c
\end{dmath}

\hsize=3cm
\begin{dmath}
f(x) = x+x+x+x+x+x+x+x+x+x+x+x+x+x+x+x+x = x*c
\end{dmath}
\end{document}


-