### Who is online

In total there are 7 users online :: 0 registered, 0 hidden and 7 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 7 guests

## Too long equation

Add tags Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).

### Too long equation

Hello everybody,

I have a very long equation and this causes me some problems. I want it to look the following way:

left side = right side\\
+continuation of right side\\
=right side again modified\\
+continuation of the modified right side\\
=result

I first used the align environment:

Code: Select all  •  Open in writeLaTeX
\begin{align*}\pi^{M}(s^{M},f^{M},x^{M}) :&= 12s^{M}+14f^{M}-(s^{M})^2-(x^{M}-4)^2-(f^{M})^2-x^{M}f^{M}-(x^{M})^2                          &=12\times6+14\times\dfrac{48}{7}-6^2-\left(\dfrac{2}{7}-4\right)^2-\left(\dfrac{48}{7}\right)^2                             -\dfrac{2}{7}\times\dfrac{48}{7}-\left(\dfrac{2}{7}\right)^2\\                            &=69,14\end{align*}

However, the problem is, that I'm doing this in a presentation and the column width is limited. Despite of that {align} doesn't adjust the expression to the margins of the slide (by braking the expression before a + or a - sign and continuing it on the next line), but makes it go out of the whole page area.

I thought of multline, however, the problem is, that multline aligns the first row left the second to last but one rows centered and last row right. This works well, if one has an expression of the type a+b=c+d+e+f+g+h=j, where there's only one row between initial row and result. However, in my case, I have some mathematical transformation (meaning an additional row) and so I need the equal sign of the row: "12\times6+14\times\dfrac{48}{7}-6^2-\left(\dfrac{2}{7}-4\right)^2-\left(\dfrac{48}{7}\right)^2
-\dfrac{2}{7}\times\dfrac{48}{7}-\left(\dfrac{2}{7}\right)^2" to be aligned under the first equal sign. So now I use this version:

Code: Select all  •  Open in writeLaTeX
\begin{align*}\pi^{M}(s^{M},f^{M},x^{M}) :=& 12s^{M}+14f^{M}-(s^{M})^2-(x^{M}-4)^2-(f^{M})^2\\                             &-x^{M}f^{M}-(x^{M})^2\pause\\                            =&12\times6+14\times\dfrac{48}{7}-6^2-\left(\dfrac{2}{7}-4\right)^2-\left(\dfrac{48}{7}\right)^2\\                             &-\dfrac{2}{7}\times\dfrac{48}{7}-\left(\dfrac{2}{7}\right)^2\pause\\                            =&69,14\pause\end{align*}

Does anybody have better ideas? Thank you
avp3000

Posts: 49
Joined: Thu Nov 15th, 2007

### Re: Too long equation

You can try the split environment, which is also provided by the amsmath package. To get a proper alignment, there are some tricky things to do.
Code: Select all  •  Open in writeLaTeX
\begin{align*}  \pi^{M}(s^{M},f^{M},x^{M}):   \begin{split}    &= 12s^{M}+14f^{M}-(s^{M})^2-(x^{M}-4)^2 \\    &\quad -(f^{M})^2-x^{M}f^{M}-(x^{M})^2  \end{split}\\  \begin{split}    &= 12\times 6+14\times\frac{48}{7}-6^2-\left(\frac{2}{7}-4\right)^2 \\    &\quad -\left(\frac{48}{7}\right)^2-\frac{2}{7}\times\frac{48}{7}-\left(\frac{2}{7}\right)^2  \end{split}\\  &=69,14\end{align*}

Note that the alignment as known from the align environment has to be put into the split environment. More hints about typesetting mathematical expressions are given in "Math mode".

Best regards
Thorsten
LaTeX Community Moderator

¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

localghost
Site Moderator

Posts: 9219
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

### Re: Too long equation

Here you have a different approach through the aligned environment:
Code: Select all  •  Open in writeLaTeX
\newcommand{\coloneqq}{\mathrel{\mathop:}=} \begin{align*}  \pi^{M}(s^{M},f^{M},x^{M})\coloneqq{}&  \!\begin{aligned}[t]     &12s^{M}+14f^{M}-(s^{M})^2-(x^{M}-4)^2 \\    &-(f^{M})^2-x^{M}f^{M}-(x^{M})^2  \end{aligned}\\  ={}&  \!\begin{aligned}[t]    &12\times 6+14\times\frac{48}{7}-6^2-\left(\frac{2}{7}-4\right)^2 \\    &-\left(\frac{48}{7}\right)^2-\frac{2}{7}\times\frac{48}{7}    -\left(\frac{2}{7}\right)^2  \end{aligned}\\  ={}&69,14\end{align*}

The \! command removes a small space before the contents of the aligned environment. Note, in addition, the use of \coloneqq instead of :=. You can also get this character from txfonts. Finally, comparing with your second code, remark the braces after =, needed to get a proper spacing.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.

Juanjo

Posts: 656
Joined: Sat Jan 27th, 2007

### Re: Too long equation

Hi,

we discussed a very similar issue today on Matheplanet.

Btw. I would try to use & at the equal sign. If you consider the mathematical style of multiline equations, perhaps have a look at for instance IEEE Computer Society Style Guide - Mathematical Expressions: If line breaks are needed in equations that appear in a paragraph, they should come after a plus sign, equals sign, or similar character. But of course there may be different styles.

Stefan

Stefan_K

Posts: 6937
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

### Re: Too long equation

Stefan_K wrote:Hi,

we discussed a very similar issue today on Matheplanet.

Btw. I would try to use & at the equal sign. If you consider the mathematical style of multiline equations, perhaps have a look at for instance IEEE Computer Society Style Guide - Mathematical Expressions: If line breaks are needed in equations that appear in a paragraph, they should come after a plus sign, equals sign, or similar character. But of course there may be different styles.

Stefan

Concerning the discussion in MathPlanet, I can't follow it, since I don't understand German. Anyway, please note that the quoted advice given in the IEEE guide applies to inline formulas (i.e. formulas inside paragraphs). However, in displayed formulas, the line break comes before binary relations or operators. So, in the code you posted in MathPlanet, I would suggest to move the + signs to the beginning of the next line (they are not properly spaced indeed).
I apologize if I shouldn't refer here to topics in a different forum.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.

Juanjo

Posts: 656
Joined: Sat Jan 27th, 2007

### Re: Too long equation

Hi Juanjo,

I just mentioned the topic of the other forum because of the coincidence of similar code, aligned inside align. Just wanted to point at the code, not at the discussion in german.
I remembered the line break after plus/minus etc. and just gave the link to that style guide quickly, I did not reed further. Now I read the part on displayed equations too. If you know more ressources concerning mathematical style I would be glad to know.

Stefan

Stefan_K

Posts: 6937
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

### Re: Too long equation

Hi Stefan,

Stefan_K wrote: If you know more ressources concerning mathematical style I would be glad to know.

The primary resource I know is the following book:

Ellen Swanson: Mathematics into Type. Updated by Arlene O'Sean and Antoinette Schleyer. American Mathematical Society, 1999.

It is cited in every author's guide for the publications of the AMS. There are similar books, like that of N. J. Higham cited in the IEEE page you linked, or Handbook of Typography for the Mathematical Sciences, by Steven G. Krantz, published by Chapman& Hall. Since I have access to these books, I have not needed to search for online resources. I've found anyway an interesting page here. Surely, a careful search would yield more suitable links.

By the way, congratulations for your TeXblog, that up to today I hadn't had got time to visit in detail.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.

Juanjo

Posts: 656
Joined: Sat Jan 27th, 2007