# New to TeX; issue with compiling

I keep getting the compiling error >file ended while scanning use of \frac. I can't see any missing {}, so I'm not sure what to do.

\documentclass[]{scrreprt}
\usepackage{geometry}
\begin{document}

Molar Mass of Nitrogen
\begin{math}
\\ Bulb Volume: 213.7 cm^{3} = .2317 L
\\ Internal bulb pressure: 20 inHg = 508 mmHg = .508 bar
\\ Temperature: 294.2 K
\\ M = \frac{\rho}{P}RT
\\ \rho = \frac{.158 g}{.2137 L} = .739\frac{g}{L}
\\ M = \frac{.739 \frac{g}{L}}{.508 bar} * .083144 \frac{L*bar}{mol*K} * 294.2 K = 35.6 \frac{g}{mol}

\\ Calculation of Volume by van der Waals Equation with Successive Approximations
\\ V = \frac{nRT}{P + \frac{n^{2}a}{V^{2}}} + nb
\\ a = 1.408 \frac{L^{2}*bar}{mol^{2}}
b = .03913 L
\\ V \approx \frac{nRT}{P} + nb \approx \frac{nRT}{P}
\\ n = \frac{m}{M} = \frac{.158 g}{21.35 \frac{g}{mol}} = 7.4*10^{-3} mol
\\ V = \frac{7.4*10^{-3} mol * .083144 \frac{L*bar}{mol*K} * 294.2 K}{.508 bar} = .2138 L
\\ V = \frac{7.4*10^{-3} mol * .083144 \frac{L*bar}{mol*K} * 294.2 K}{.508 bar
+ \frac{(7.4*10^{-3} mol)^{2}*1.408 \frac{L^{2}*bar}{mol^{2}}} {(.2138 L)^{2}}
+ 7.4*10^{-3} mol * .03913 L = .2137 L
\end{math}
\end{document}


This is for a calculations addendum to an undergraduate chemistry lab. I figured it would be worth the time investment to learn laTeX. It's already significantly faster to do calculations in it than word, if only I can get around these compiling errors.

Relevant log text:

Runaway argument? {.508 bar + \frac {(7.4*10^{-3} mol)^{2}*1.408 \frac {L^{2}*bar}{mol^\ETC. ! File ended while scanning use of \frac.

-
Welcome to TeX.SX! The last line of your math environment has an unmatched brace (opens at .508 bar and is never closed). While this (and the empty line before "Calculation of...") are the only explicit errors, you may want to study some mathematics best practices for typesetting these sorts of things. The LaTeX Wikibook has a good start, and you can find many resources on this site as well as the broader web. –  Paul Gessler Feb 23 at 22:33
\frac takes two arguments, like \frac{\pi}{4}. But you'll also find that you won't want a single math mode environment, as @PaulGessler said. As it stands now, all your non-math text in the math environment will be stripped of spaces, italicized, extra spaces added around colons, etc. –  Mike Renfro Feb 23 at 22:39
In addition to Paul and Mike: Open a command line prompt and type there texdoc mathmode. This should open a PDF document with title “Math mode” written by Herbert Voß and included in your TeX distribution. –  Speravir Feb 23 at 22:46

You won't be needing one big math environment for this. Further, it is a good idea to use siunitx package for typesetting your units. Here is a sample:

\documentclass[]{scrreprt}
\usepackage{amsmath}
\usepackage[per-mode=symbol,detect-weight]{siunitx}
\DeclareSIUnit{\inHg}{inHg}
\DeclareSIUnit{\mmHg}{mmHg}
\begin{document}
\noindent
Molar Mass of Nitrogen\\
Bulb Volume: $\SI{13.7}{\centi\meter^{3}} = \SI{0.2317}{\litre}$\\
Internal bulb pressure: $\SI{0}{\inHg} = \SI{508}{\mmHg} = \SI{0.508}{\bar}$\\
Temperature: \SI{294.2}{\kelvin}\\[0.5\baselineskip]
$M = \dfrac{\rho}{P}RT$ \\[0.5\baselineskip]
$\rho = \dfrac{\SI{0.158}{\gram}}{\SI{0.2137}{\litre}} = \SI{0.739}{\gram\per\litre}$ \\[0.5\baselineskip]
$M = \dfrac{\SI{0.739}{\gram\per\litre}}{\SI{0.508}{\bar}} * \SI{0.083144}{\litre\bar\per\mole\per\kelvin} * \SI{294.2}{\kelvin} = \SI{35.6}{\gram\per\mol}$\\[0.5\baselineskip]
Calculation of Volume by van der Waals Equation with Successive Approximations \\[0.5\baselineskip]
$V = \dfrac{nRT}{P + \dfrac{n^{2}a}{V^{2}}} + nb$\\[0.5\baselineskip]
$a = \SI{1.408}{\square\litre\bar\per\mol^{2}}$\\[0.5\baselineskip]
$b = \SI{0.03913}{\litre}$\\[0.5\baselineskip]
$V \approx \dfrac{nRT}{P} + nb \approx \dfrac{nRT}{P}$\\[0.5\baselineskip]
$n = \dfrac{m}{M} = \dfrac{\SI{0.158}{\gram}}{\SI{21.35}{\gram\per\mol}} = 7.4*10^{-3}\si{\mol}$\\[0.5\baselineskip]
$V = \dfrac{7.4*10^{-3}\si{\mol} * \SI{0.083144}{\litre\bar\per\mol\per\kelvin} * \SI{0294.2}{\kelvin}}{\SI{0.508}{\bar}} = \SI{0.2138}{\litre}$\\[0.5\baselineskip]
\begin{flalign*}
V &= \dfrac{7.4*10^{-3}\si{\mol} * \SI{0.083144}{\litre\bar\per\mol\per\kelvin} * \SI{294.2}{\kelvin}}{\SI{0.508}{\bar}}&& \\
& \quad + \dfrac{(7.4*10^{-3}\si{\mol})^{2}* \SI{1.408}{\square\litre\bar\per\square\mol}} {(\SI{0.2138}{\litre})^{2} + 7.4*10^{-3}\si{\mol} * \SI{0.03913}{litre}} &&\\
&= \SI{0.2137}{\litre}
\end{flalign*}
\end{document}


For details you can texdoc mathmode texdoc amsldoc and texdoc siunitx from the terminal.

As a side note, I would also use \cdot or \times to show multiplication, but not *. This, I didn't change in the above example.

-
I never noticed the separate \litre and \liter commands in siunitx until now. Or that SI had three different symbols for it. –  Mike Renfro Feb 24 at 1:05

(As has already been pointed out, the immediate reason for the compilation failure is that you're missing a right curly brace after the first .508 bar in the final calculation of V.)

In addition to using the capabilities of the siunitx package to handle the formatting of units, I'd also use an align* environment to typeset the sequence of calculations. Using such an environment will free you from having to fine-tune the distances between successive lines via instructions such as \\[2ex]. (If you need to allow the insertion of a page break somewhere in the sequence of calculations, insert the instruction \allowdisplaybreaks before \begin{align*}.)

\documentclass[]{scrreprt}
\usepackage{amsmath}
\usepackage[per-mode=symbol,
detect-weight,
group-digits=false]
{siunitx}
\DeclareSIUnit{\inHg}{inHg} % borrowed from Harish's answer...
\DeclareSIUnit{\mmHg}{mmHg}
\begin{document}
\noindent
$\begin{array}{@{}l} \text{Molar Mass of Nitrogen}\\ \text{Bulb Volume: } \SI{13.7}{\centi\meter^{3}} = \SI{0.2317}{\liter}\\ \text{Internal bulb pressure: } \SI{0}{\inHg} = \SI{508}{\mmHg} = \SI{0.508}{\bar}\\ \text{Temperature: } \SI{294.2}{\kelvin} \end{array}$

\begin{align*}
M    &= \frac{\rho}{P}RT \\
\rho &= \frac{\SI{0.158}{\gram}}{\SI{0.2137}{\liter}} = \SI{0.739}{\gram\per\liter} \\
M    &= \frac{\SI{0.739}{\gram\per\liter}}{\SI{0.508}{\bar}} * \SI{0.083144}{\liter\bar\per\mole\per\kelvin} * \SI{294.2}{\kelvin} = \SI{35.6}{\gram\per\mol}\\
\intertext{Calculation of volume by van der Waals equation with successive approximations}
V &= \frac{nRT}{P + \frac{n^{2}a}{V^{2}}} + nb\\
a &= \SI{1.408}{\square\liter\bar\per\mol^{2}}\\
b &= \SI{0.03913}{\liter}\\
V &\approx \frac{nRT}{P} + nb \approx \frac{nRT}{P}\\
n &= \frac{m}{M} = \frac{\SI{0.158}{\gram}}{\SI{21.35}{\gram\per\mol}} = 7.4*10^{-3}\si{\mol}\\
V &= \frac{7.4*10^{-3}\si{\mol} * \SI{0.083144}{\liter\bar\per\mol\per\kelvin} * \SI{0294.2}{\kelvin}}{\SI{0.508}{\bar}} = \SI{0.2138}{\liter}\\
V &= \frac{7.4*10^{-3}\si{\mol} * \SI{0.083144}{\liter\bar\per\mol\per\kelvin} * \SI{294.2}{\kelvin}}{\SI{0.508}{\bar}} \\
&\quad + \frac{(7.4*10^{-3}\si{\mol})^{2}* \SI{1.408}{\square\liter\bar\per\square\mol}} {(\SI{0.2138}{\liter})^{2} + 7.4*10^{-3}\si{\mol} * \SI{0.03913}{\liter}} \\
&= \SI{0.2137}{\liter}
\end{align*}
\end{document}

-