How can I split up a long and complicated equation in LaTeX?

  • Context: LaTeX 
  • Thread starter Thread starter SeM
  • Start date Start date
  • Tags Tags
    Latex Lines Split
Click For Summary

Discussion Overview

The discussion revolves around how to split a long and complicated equation in LaTeX into multiple lines for better readability and formatting. Participants explore various LaTeX environments and techniques suitable for achieving this, including align, split, and IEEEeqnarray.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant seeks assistance on splitting a lengthy equation in LaTeX that exceeds the right margin.
  • Another participant asks for clarification on what methods have been attempted to resolve the issue.
  • A participant suggests using the split environment for single equations that are too long, emphasizing that it should be used within another displayed equation structure.
  • Some participants provide examples of how to format the equation using the align environment, suggesting that it allows for clearer presentation.
  • Another participant proposes using variables to simplify the equation's structure, which could enhance clarity and readability.
  • One participant mentions the IEEEeqnarray environment as an alternative for formatting equations, along with installation instructions for the necessary package.
  • A later reply indicates that the original poster opted for a different tool, texlabel, to manage long expressions more effectively.

Areas of Agreement / Disagreement

Participants express various methods for formatting equations, but there is no consensus on a single best approach. Multiple competing views on the use of different environments and techniques remain present.

Contextual Notes

Some participants reference specific LaTeX environments and their intended use, but there are unresolved questions regarding the best practices for splitting equations effectively. Limitations in the original equation's formatting and the impact of different environments on readability are noted but not fully resolved.

SeM
Hi, how do I split up this horrible equation into several lines?

given in latex code:

\Psi_2= -2.018\,{10}^{-122}\,C_{2}\,{\mathrm{e}}^{-x\,1.014{}{10}^7{}\mathrm{i}}\,\left(1.398\,{10}^{121}\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}-1.398\,{10}^{121}\,x^2\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}+1.398\,{10}^{121}\,x^2-1.436\,{10}^{135}+x^3\,1.396{}{10}^{60}{}\mathrm{i}+x\,2.833{}{10}^{128}{}\mathrm{i}\right)

and shown in latex form:

\begin{equation}
\Psi_2= -2.018\,{10}^{-122}\,C_{2}\,{\mathrm{e}}^{-x\,1.014{}{10}^7{}\mathrm{i}}\,\left(1.398\,{10}^{121}\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}-1.398\,{10}^{121}\,x^2\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}+1.398\,{10}^{121}\,x^2-1.436\,{10}^{135}+x^3\,1.396{}{10}^{60}{}\mathrm{i}+x\,2.833{}{10}^{128}{}\mathrm{i}\right)
\end{equation}

it shows beautifully here, but in my latex document it stretches beyond the right margin of the page, and does not split up no matter what I have tried.
 
Physics news on Phys.org
SeM said:
no matter what I have tried.
What have you tried?
 
DrClaude said:
What have you tried?

I managed, I used

\begin{equation*}
\begin{split*}
\begin{align*}
& Text to split //
& second part to split //
& and so on //

\end{equation*}
\end{split*}
\end{align*}
 
It is strange to see an align within a split. Normally, it should be inside the align. From the AMS math documentation:
Like multiline, the split environment is for single equations that are too long to fit on one line and hence must be split into multiple lines. Unlike multline, however, the split environment provides for alignment among the split lines, using & to mark alignment points. Unlike the other amsmath equation structures, the split environment provides no numbering, because it is intended to be used only inside some other displayed equation structure, usually an equation, align, or gather environment, which provides the numbering.
 
DrClaude said:
It is strange to see an align within a split. Normally, it should be inside the align. From the AMS math documentation:
It worked well as given.

Thanks!
 
SeM said:
Hi, how do I split up this horrible equation into several lines?

given in latex code:

\Psi_2= -2.018\,{10}^{-122}\,C_{2}\,{\mathrm{e}}^{-x\,1.014{}{10}^7{}\mathrm{i}}\,\left(1.398\,{10}^{121}\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}-1.398\,{10}^{121}\,x^2\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}+1.398\,{10}^{121}\,x^2-1.436\,{10}^{135}+x^3\,1.396{}{10}^{60}{}\mathrm{i}+x\,2.833{}{10}^{128}{}\mathrm{i}\right)

and shown in latex form:

\begin{equation}
\Psi_2= -2.018\,{10}^{-122}\,C_{2}\,{\mathrm{e}}^{-x\,1.014{}{10}^7{}\mathrm{i}}\,\left(1.398\,{10}^{121}\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}-1.398\,{10}^{121}\,x^2\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}+1.398\,{10}^{121}\,x^2-1.436\,{10}^{135}+x^3\,1.396{}{10}^{60}{}\mathrm{i}+x\,2.833{}{10}^{128}{}\mathrm{i}\right)
\end{equation}

it shows beautifully here, but in my latex document it stretches beyond the right margin of the page, and does not split up no matter what I have tried.

Well there are various environments like align and IEEEeqnarray that you could use to produce output like this: $$\begin{align}
\Psi_2 = -2.018 \, {10}^{-122} \, C_{2} \,
{\mathrm{e}}^{-x\,1.014 \cdot {10}^7{}\mathrm{i}}\, \Bigl(
& 1.398 \, {10}^{121} \,
{\mathrm{e}}^{x\,1.014 \cdot {10}^7{}\mathrm{i}} \nonumber \\
&-\> 1.398 \, {10}^{121} \, x^2 \,
{\mathrm{e}}^{x \, 1.014 \cdot {10}^7{}\mathrm{i}} \nonumber \\
&+\> 1.398\,{10}^{121}\,x^2 - 1.436\,{10}^{135} \nonumber \\
&+\> x^3\,1.396{}{10}^{60}{}\mathrm{i}
+ x\,2.833{}{10}^{128}{}\mathrm{i} \Bigr) \,.
\end{align}$$

But why not just use a few variables: $$\Psi_{2} = - \lambda \, C_{2} \,
\mathrm{e}^{-\mathrm{i} \phi x} \, \Bigl(
\alpha \mathrm{e}^{\mathrm{i} \phi x}
- \alpha x^{2} \mathrm{e}^{\mathrm{i} \phi x}
+ \alpha x^{2} - \beta
+ \mathrm{i} \gamma x^{3}
+ \mathrm{i} \delta x \Bigr) \,,$$ where $$\begin{eqnarray}
\lambda &=& 2.018 \cdot 10^{-122} \,, &\qquad&
\phi &=& 1.014 \cdot 10^{7} \,, \\
\alpha &=& 1.398 \cdot 10^{121} \,, &&
\beta &=& 1.436 \cdot 10^{135} \,, \\
\gamma &=& 1.396 \cdot 10^{60} \,, &&
\delta &=& 2.833 \cdot 10^{128} \,.
\end{eqnarray}$$ This makes the structure of the equation so much clearer.

You can produce the second set of equations in a paper with, e.g.,
Code:
\begin{IEEEeqnarray}{rCl+rCl}
  \lambda &=& 2.018 \cdot 10^{-122} \,, &
  \phi &=& 1.014 \cdot 10^{7} \,, \\
  \alpha &=& 1.398 \cdot 10^{121} \,, &
  \beta &=& 1.436 \cdot 10^{135} \,, \\
  \gamma &=& 1.396 \cdot 10^{60} \,, &
  \delta &=& 2.833 \cdot 10^{128} \,.
\end{IEEEeqnarray}
(If you want to use the IEEEeqnarray environment like here then install IEEEtrantools and put \usepackage[retainorgcmds]{IEEEtrantools} in the document preamble.)
 
  • Like
Likes   Reactions: FactChecker
wle said:
(If you want to use the IEEEeqnarray environment like here then install IEEEtrantools and put \usepackage[retainorgcmds]{IEEEtrantools} in the document preamble.)
Thanks WLE! I ended up using texlabel because these expressions become too long.
 
Last edited by a moderator:

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 11 ·
Replies
11
Views
9K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 15 ·
Replies
15
Views
25K