15

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:

First attempt

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}

Good alignment

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

6
  • 2
    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 [email protected] and i will put it on our list, to be considered for the next upgrade. May 4, 2011 at 20:24
  • This seems to be a bug that I can not reproduce anymore with mathtools package 1.12.
    – mafp
    Dec 5, 2012 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, 2012 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, 2012 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, 2012 at 16:35

1 Answer 1

8

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}

enter image description here

1
  • Thank you for sharing this! The dmath environment is exactly what I've been looking for.
    – KeithWM
    Jul 15, 2016 at 11:49

You must log in to answer this question.

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