Martin Babka
Martin Babka

Reputation: 1

Missing $ inserted error when compiling LaTeX

im a LaTeX beginner and i keep running into this one issue compiling a .tex file.

the error is as following:

*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
! Missing $ inserted.
<inserted text> 
                $
l.31 \quad \rightarrow
                       \quad
? 

the code around line 31 is:

\begin{center}
\chemfig{*6(-F-NO_2-NC)}
\quad +
\quad 3Sn \quad + \quad 6HCl
\quad \rightarrow \quad
\chemfig{*6(-F-NH_2-NC)}
\quad + \quad 3SnCl_2 \quad + \quad 2H_2O
\end{center}

Any help appreciated.

Upvotes: -1

Views: 104

Answers (1)

Macros like _ or \rightarrow are math commands. They need to be used in math mode, e.g. $\rightarrow$.

However you could make your life easier by using one of the packages to typeset chemistry formulas:

\documentclass{article}

\usepackage{chemfig}
\usepackage[version=4]{mhchem}

\begin{document}

\begin{center}
\ce{
  \chemfig{*6(-F-NO_2-NC)}
  +
  3Sn  +  6HCl
  ->
  \chemfig{*6(-F-NH_2-NC)}
  +  3SnCl2  +  2H2O
}
\end{center}


\end{document}

enter image description here

Upvotes: 0

Related Questions