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}
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.