[Tex/LaTex] File ended while scanning use of \frac

amsmathamssymbequationsfloats

I keep receiving the error message

File ended while scanning use of \frac ."

and have narrowed the error down to this equation, though I can't work out why.

\documentclass [12pt] {report}

\usepackage [doublespacing] {setspace}

\usepackage{times}

\usepackage [top=3cm, bottom=3cm, left=4cm, right=2cm] {geometry}

\usepackage{graphicx}

\usepackage{amsmath,amssymb}

\begin{document}

\begin{equation}

\frac{\partial N}{\partial t}+\frac{\partial}{\partial x}\left(\frac{MN}{D}\right)+\frac{\partial}{\partial y}\left(\frac{N^2}{D}\right)+ gD\frac{\partial z}{\partial y}+\frac{\tau_{y}}{p}=0\\

\label{eq2}

\end{equation}

\end{document}

Best Answer

The main issue is that you mustn't have blank lines in an equation environment -- or any display-math environment, for that matter.

An additional concern: If you use Times Roman as the text font, you should probably also load a Times Roman math font. The mathptmx and newtxtext/newtxmath packages may be suitable.

enter image description here

\documentclass[12pt]{report}
\usepackage[doublespacing,nodisplayskipstretch]{setspace}
\usepackage{newtxtext,newtxmath} % Times Roman text and math fonts
\usepackage[vmargin=3cm, left=4cm, right=2cm]{geometry}
\usepackage{graphicx}
\usepackage{amsmath,amssymb}

% For tighter spacing around \left/\right pairs of parentheses:
\usepackage{mleftright}  \mleftright 

\begin{document}
\begin{equation} \label{eq2}
\frac{\partial N}{\partial t}+\frac{\partial}{\partial x}\left(\frac{MN}{D}\right)
 +\frac{\partial}{\partial y}\left(\frac{N^2}{D}\right)+ gD\frac{\partial z}{\partial y}
 +\frac{\tau_{y}}{p}=0
\end{equation}

\end{document}