# How to write a mathematical formula in 2 lines?

I have a mathematical formula with many symbols and Greek characters, but it is too big. So I want to split it in two lines. I use \\ between \$, but it doesn't work. Does anybody know how to fix it?

• Welcome to TeX SX! You have to use one of the ams environments — align, alignat, gather, multline, &c. See the masmath documentation. – Bernard Nov 27 '14 at 19:45

There are a number of ways to achieve this. Here is a list, taken from Herbert's mathmode document: \documentclass{article}

\usepackage[paper=a3paper,margin=1in]{geometry}% Just for this example
\usepackage{amsmath,array}

\newcommand{\BOX}[0.125\columnwidth]{\framebox[#1]}
\begin{document}

$\begin{array}{r@{}>{{}}l@{\qquad}r@{}>{{}}l} \BOX{array} &= \BOX{x} & \BOX{x}&= \BOX{x}\\ \BOX{array}&= \BOX[0.1\columnwidth]{x} & \BOX[0.1\columnwidth]{x} &= \BOX[0.1\columnwidth]{x} \end{array}$

\begin{align*}
\BOX{align} &= \BOX{x} & \BOX{x}&= \BOX{x}\\
\BOX{align}&= \BOX[0.1\columnwidth]{x} & \BOX[0.1\columnwidth]{x} &= \BOX[0.1\columnwidth]{x}
\end{align*}

\begin{alignat*}{2}
\BOX{alignat} &= \BOX{x} & \BOX{x} &= \BOX{x}\\
\BOX{alignat} &= \BOX[0.1\columnwidth]{x} & \BOX[0.1\columnwidth]{x} &= \BOX[0.1\columnwidth]{x}
\end{alignat*}

\begin{flalign*}
\BOX{flalign} &= \BOX{x} & \BOX{x} &= \BOX{x}\\
\BOX{flalign} &= \BOX[0.1\columnwidth]{x} & \BOX[0.1\columnwidth]{x} &= \BOX[0.1\columnwidth]{x}
\end{flalign*}

\begin{xalignat*}{2}
\BOX{xalignat} &= \BOX{x} & \BOX{x} &= \BOX{x}\\
\BOX{xalignat} &= \BOX[0.1\columnwidth]{x} & \BOX[0.1\columnwidth]{x} &= \BOX[0.1\columnwidth]{x}
\end{xalignat*}

\begin{xxalignat}{2}
\BOX{xxalignat} &= \BOX{x} & \BOX{x} &= \BOX{x}\\
\BOX{xxalignat} &= \BOX[0.1\columnwidth]{x} & \BOX[0.1\columnwidth]{x} &= \BOX[0.1\columnwidth]{x}
\end{xxalignat}

\begin{gather*}
\BOX{gather} = \BOX{x}\\
\BOX{gather} = \BOX[0.1\columnwidth]{x}
\end{gather*}

$\begin{gathered}[t] \BOX{gathered[t]} = \BOX{x}\\ \BOX{gathered[t]} = \BOX[0.1\columnwidth]{x} \end{gathered} \quad\rule{1em}{.4pt}\quad \begin{gathered}[c] \BOX{gathered[c]} = \BOX{x}\\ \BOX{gathered[c]} = \BOX[0.1\columnwidth]{x} \end{gathered} \quad\rule{1em}{.4pt}\quad \begin{gathered}[b] \BOX{gathered[b]} = \BOX{x}\\ \BOX{gathered[b]} = \BOX[0.1\columnwidth]{x} \end{gathered}$

\begin{multline*}
\BOX[0.5\columnwidth]{multline start}\\
\BOX[0.5\columnwidth]{x}\\
\BOX[0.5\columnwidth]{x}\\
\shoveright{\BOX[0.5\columnwidth]{multline shoved right}}\\
\BOX[0.5\columnwidth]{x}\\
\BOX[0.5\columnwidth]{end multline}
\end{multline*}

$\begin{split} \BOX[0.35\columnwidth]{split}\\ \BOX[0.75\columnwidth]{x}\\ \BOX[0.65\columnwidth]{x}\\ \BOX[0.95\columnwidth]{x} \end{split}$

$\begin{split} \BOX{split} = {}&\BOX[0.35\columnwidth]{x}\\ &\BOX[0.75\columnwidth]{x}\\ &\BOX[0.65\columnwidth]{x}\\ &\BOX[0.8\columnwidth]{x} \end{split}$

\end{document}


Note that some environments require the user to initiate math mode, while others initiate math mode automatically.

Most of the above environments are listed in their starred form, implying that there will be no numbering of multi-line equations. However, most of them have un-starred alternatives which will number successive equations/components. For more information, review either the amsmath user guide or the mathmode document itself.

array is probably the most well-known math environment for printing content (equations) in a vertical format, using \\ to stack content.

Historically people used eqnarray to stack equations in an array/vertical format. However, nowadays, this is discouraged.

The above discussion is general in nature, and specific use-case solutions may vary. As such, the list is not exhaustive.

You can use the array or eqnarray to split the formula in multiple lines.

• eqnarray is obsolete. – user31729 Nov 27 '14 at 20:33
• – Werner Nov 27 '14 at 20:38
• @Werner Thanks for the pointer. align with need the ams environment. eqnarray is base LaTeX. The OP can make the choice. – unxnut Nov 27 '14 at 21:23
• @unxnut - eqnarray is so vastly inferior to align that the choice between the two environments should be obvious. In fact, why even bother to pretend there's a meaningful choice? – Mico Nov 28 '14 at 0:11