# How to write long equation

I want to write the following equation in such a way that right align is possible. That is all right most elements are in same column. Here left align is done.

\begin{eqnarray*}
y_{0}&= &(r_{73} + 1)r_{9} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{108} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{73} + 1)r_{93} + \\
&  &r_{73} + 1)r_{98} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + r_{73} +1)r_{123} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})\\
&  &r_{115} + r_{73} + 1)r_{85} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} \\
&  & + 1)r_{93} +((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{73} + r_{93})r_{110})r_{115} \\
&  &+ r_{68} + 1)r_{131} +r_{73} + 1)r_{88} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} + 1)r_{93} + ((r_{68}r_{73} + r_{68})\\
&  &r_{93} + r_{68}r_{73} +r_{68})r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{68}r_{73} + r_{68}r_{93})r_{110})r_{115} + \\
&  &r_{68} + 1)r_{131} + (r_{15} + r_{36} +r_{48} + r_{6} + r_{61} + r_{7})r_{73} + ((r_{73} + r_{93})r_{108} + (r_{73} + r_{93})r_{110} \\
&  &+ (r_{73} + r_{93})r_{98} + (r_{15} +r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} \\
&  &+ r_{7} + r_{9})r_{93} + r_{73}r_{9} + 1)r_{115} +((r_{73} + 1)r_{9} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73}  \\
&  &+ r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} + 1)r_{93} +r_{103} + r_{11} + r_{113} + r_{12} + r_{128} + r_{14} + r_{15} \\
&  &+ r_{20} + r_{36} + r_{41} + r_{48} + r_{53} + r_{6} + r_{61} + r_{66}+ r_{7} + r_{90}\\
\end{eqnarray*}

-
–  qubyte Jan 6 '12 at 16:13
possible duplicate of How can I split an equation over two lines –  lockstep Jan 6 '12 at 18:58

I would also recommend that you use the align environment, but would recommend that you:

• not break lines when you are in brackets if possible
• in the cases where it is necessary to break within a brackets to somehow visually indicate that. Here I have used a slightly larger bracket, but perhaps an even larger bracket or a square bracket would be better to allow for easily finding the matching brackets. I have also added extra indentation when this is the case

## Notes:

• You parenthesis are not balanced. I have a comment in the code to indicate where and have left that as is.
• The [showframe] option of the geometry package was used to show where the margins are. So, the code fits within the default width of the article class. This might need to be adjusted based on your text width dimentions.

## Code:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{amsmath}

\begin{document}
\begin{align*}
y_{0}
&= (r_{73} + 1)r_{9}
+ ((r_{73} + 1)r_{93} + r_{73} + 1)r_{108}
+ ((r_{73} + 1)r_{93} + r_{73} + 1)r_{110}\\
&\quad+ ((r_{73} + 1)r_{93} + r_{73} + 1)r_{98}
+ ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + r_{73} +1)r_{123}\\
&\quad+ ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + r_{73} + 1)r_{85}\\
% This is a long expression
&\quad+ \big((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + ((r_{68} + 1)r_{73}
+ ((r_{68} + 1)r_{73} + r_{68}+ 1)r_{93} \\
&\quad\qquad+((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{73} + r_{93})r_{110})r_{115}\\
+r_{73} + 1\big)r_{88} \\
% -------------------------------------
&\quad+ ((r_{68} + 1)r_{73} % Not sure where this opening ( is supposed to close
+ ((r_{68} + 1)r_{73} + r_{68} + 1)r_{93} \\
% Another long expression:
&\quad+ \big((r_{68}r_{73} + r_{68}
r_{93} + r_{68}r_{73} +r_{68})r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} \\
&\quad\qquad+ (r_{68}r_{73} + r_{68}r_{93})r_{110})r_{115} + r_{68} + 1 \big)r_{131}\\
% ----------------------
&\quad+ (r_{15} + r_{36} +r_{48} + r_{6} + r_{61} + r_{7})r_{73} \\
%
% Another long expression:
&\quad+ \big((r_{73} + r_{93})r_{108} + (r_{73} + r_{93})r_{110}
+ (r_{73} + r_{93})r_{98} + (r_{15} +r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73} \\
&\quad\qquad+ (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} + r_{9})r_{93} \\
% -----------------------------------------------
% Another long expression:
&\quad+ \big((r_{73} + 1)r_{9}
+ (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73}
+ r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} + 1\big)r_{93}\\
% -----------------------------------------------
% Rest are single terms so we can break them anywhere
&\quad+r_{103} + r_{11} + r_{113} + r_{12} + r_{128} + r_{14} + r_{15}
+ r_{20} + r_{36} + r_{41} + r_{48} + r_{53} + r_{6} + r_{61} + r_{66}\\
&\quad+ r_{7} + r_{90}
\end{align*}
\end{document}

-
Thank you very much. –  user12290 Jan 8 '12 at 15:59

Use align from the amsmath package:

\documentclass{minimal}
\usepackage{amsmath}

\begin{document}
\begin{align*}
y_{0}=(r_{73} + 1)r_{9} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{108} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{73} + 1)r_{93}& + \\
r_{73} + 1)r_{98} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + r_{73} +1)r_{123} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})&\\
r_{115} + r_{73} + 1)r_{85} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} &\\
+ 1)r_{93} +((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{73} + r_{93})r_{110})r_{115} &\\
+ r_{68} + 1)r_{131} +r_{73} + 1)r_{88} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} + 1)r_{93} + ((r_{68}r_{73} + r_{68})&\\
r_{93} + r_{68}r_{73} +r_{68})r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{68}r_{73} + r_{68}r_{93})r_{110})r_{115}& + \\
r_{68} + 1)r_{131} + (r_{15} + r_{36} +r_{48} + r_{6} + r_{61} + r_{7})r_{73} + ((r_{73} + r_{93})r_{108} + (r_{73} + r_{93})r_{110} &\\
+ (r_{73} + r_{93})r_{98} + (r_{15} +r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} &\\
+ r_{7} + r_{9})r_{93} + r_{73}r_{9} + 1)r_{115} +((r_{73} + 1)r_{9} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73}  &\\
+ r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} + 1)r_{93} +r_{103} + r_{11} + r_{113} + r_{12} + r_{128} + r_{14} + r_{15} &\\
+ r_{20} + r_{36} + r_{41} + r_{48} + r_{53} + r_{6} + r_{61} + r_{66}+ r_{7} + r_{90}&
\end{align*}
\end{document}


If you want everything to be right up against the margins, just replace eqnarray with flalign, also from amsmath:

\documentclass{minimal}
\usepackage{amsmath}

\begin{document}
\begin{flalign*}
y_{0}=&& (r_{73} + 1)r_{9} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{108} + ((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{73} + 1)r_{93} &+ \\
&  &r_{73} + 1)r_{98} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + r_{73} +1)r_{123} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})\\
&  &r_{115} + r_{73} + 1)r_{85} + ((r_{73} + 1)r_{93} + (r_{73} + r_{93})r_{115} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} \\
&  & + 1)r_{93} +((r_{73} + 1)r_{93} + r_{73} + 1)r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{73} + r_{93})r_{110})r_{115} \\
&  &+ r_{68} + 1)r_{131} +r_{73} + 1)r_{88} + ((r_{68} + 1)r_{73} + ((r_{68} + 1)r_{73} + r_{68} + 1)r_{93} + ((r_{68}r_{73} + r_{68})\\
&  &r_{93} + r_{68}r_{73} +r_{68})r_{110} + ((r_{68} + 1)r_{73} + (r_{68} + 1)r_{93} + (r_{68}r_{73} + r_{68}r_{93})r_{110})r_{115} &+ \\
&  &r_{68} + 1)r_{131} + (r_{15} + r_{36} +r_{48} + r_{6} + r_{61} + r_{7})r_{73} + ((r_{73} + r_{93})r_{108} + (r_{73} + r_{93})r_{110} \\
&  &+ (r_{73} + r_{93})r_{98} + (r_{15} +r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} \\
&  &+ r_{7} + r_{9})r_{93} + r_{73}r_{9} + 1)r_{115} +((r_{73} + 1)r_{9} + (r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7})r_{73}  \\
&  &+ r_{15} + r_{36} + r_{48} + r_{6} + r_{61} + r_{7} + 1)r_{93} +r_{103} + r_{11} + r_{113} + r_{12} + r_{128} + r_{14} + r_{15} \\
&  &+ r_{20} + r_{36} + r_{41} + r_{48} + r_{53} + r_{6} + r_{61} + r_{66}+ r_{7} + r_{90}\\
\end{flalign*}
\end{document}

-
Thanks for the help. –  user12290 Jan 8 '12 at 15:59