how to split equation on two lines

user2121 picture user2121 · Mar 14, 2016 · Viewed 17.9k times · Source

I wrote the following two equations in latex, but the problem is when I run the code, both equation are written on the same line

how can I split them on two lines

\begin{equation}
N = R * cos(lat) * sin(lon) \\
E = R * cos(lat) * cos(lon)
\label{eq:gps_to_cartesian}
\end{equation}

Answer

zdim picture zdim · Mar 14, 2016

There is the amsmath package for such needs. It provides tools to work with multi-line equations, bundled in its equation-like environments. It is a standard package which is in most installations.

For two independent equations, listed below each other and aligned on = sign

\usepackage{amsmath}

\begin{align} \label{eq:gps_to_cartesian}
N = &  R * cos(lat) * sin(lon) \\
E = &  R * cos(lat) * cos(lon).
\end{align}

Additional alignment points can be set up with additional &. Equation numbering can be suppressed on individual lines by adding \notag. More tweaking can be done.

Note that there are other environments for multi-line equations, to suit different uses.

Here is a clear page on Aligning Equations and here is the official User's Guide (pdf).


The original way was to use eqnarray for this, replaced long ago by amsmath, but it can still step in if for some reason the package cannot be used.