Fractions in equation mode

equationsmath-mode

I don't want to double up other questions and this is probably a quick one for somebody that uses math mode more often than me (I pretty much started today)

Can someone help me understand what is wrong with the syntax here?

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation} \label{eqn:x}
$\Delta$C$_{i}$ = $(\frac{m^{a}/m^{o}}{C_{i}^{a}/C_{i}^{o}}-1) C_{i}^{o}$   
\end{equation}

\end{document}

The above produces this preview in Sublime Text 3, which is fine and just how I need the equation to look.

xx

But with it came a series of errors, which I assume is because I'm mixing \frac with the equation environment in a bad way somehow or being uneconomic with my notation.

"Display math should end with $$. [ $\Delta]"
"Missing $ inserted. [  $\Delta]"
"LaTeX Error: Bad math environment delimiter. [ \end{equation}]"
"You can't use `\eqno' in horizontal mode. [    \end{equation}]"
"Missing $ inserted. [  \end{equation}]"
"Display math should end with $$. [ \end{equation}]"

I tried for some time to understand where delimiters should go to no avail

Could someone please spare a second to help me learn to do this more sensibly?

Best Answer

TeX has two fundamental ways of processing material. The material can be processed either in text mode or in math mode. TeX's math mode has two main subcategories: inline math mode and display math mode.

One can use $ tokens to initiate and terminate inline math mode while in text mode. However, after \begin{equation}, TeX is in display math mode automatically; while in display math mode, it's an error to try to initiate (or terminate) inline text mode.

What to do? Easy! Just get rid of all six instances of $ in the equation. In addition, I would also tell TeX to enlarge the parentheses, by prefixing \Bigl to ( and \Bigr to ).

Moral of the story? Don't ever ignore TeX's error messages. Just because the program somehow manages to struggle through to the end without crashing completely doesn't mean that it's ok to ignore the error messages.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation} \label{eqn:x}
\Delta C_{i} = \Bigl(\frac{m^{a}/m^{o}}{C_{i}^{a}/C_{i}^{o}}-1\Bigr) C_{i}^{o}   
\end{equation}

\end{document}
Related Question