1

I am writing a report that requires chemical reactions to be numbered and have used the following code to do so:

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{chemformula}

\begin{document}

\begin{subequations}
\begin{eqnarray}
\label{eq:formloss1}
\ch{HCHO + ^.OH -> CHO^. + H2O} \\
\ch{HCHO + \textit{hv_{uv}} ->[O2] CHO^. + HO2} \\
\label{eq:formloss2}
\ch{HCHO + \textit{hv_{uv}} -> CO + H2}
\end{eqnarray}
\end{subequations}
\end{document}

But in the second equation the O2 (which is above the reaction arrow) doesn't subscript the 2, which I need it to do. How can I force it to subscript this? And if it requires changing the packages I'm using, how to I keep the equations numbered?

  • 1
    According to the manual you should use ->[ O2 ] (note the extra spaces) if you want the 2 subscripted. – John Kormylo Oct 2 '15 at 4:31
3

From chemformula's manual:

chemformula distinguishes between different types of input. These different parts have to be separated with blanks:

\ch{part1 part2 part3 part4}

The same holds for formulas above or below arrows. This means you have to write

->[ O2 ]

chemformula needs formulas enclosed with spaces to correctly detect wether an input is a formula/a stoichiometric factor/an arrow…

Secondly I'd write $h\nu_{\textup{uv}}$ instead of \textit{hv_{uv}}. By using math mode you'll get the right spacing between the Planck constant and the frequency. Also I'm quite sure you want the frequency \nu and not v (velocity?). The subscript seems to be a label, so it should be upright again.

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{chemformula}

\begin{document}

\begin{subequations}
  \begin{gather}
    \ch{HCHO + ^.OH -> CHO^. + H2O} \label{eq:formloss1} \\
    \ch{HCHO + $h\nu_{\textup{uv}}$ ->[ O2 ] CHO^. + HO2} \\
    \ch{HCHO + $h\nu_{\textup{uv}}$ -> CO + H2} \label{eq:formloss2}
  \end{gather}
\end{subequations}

\end{document}

enter image description here

By the way: do you really need eqnarray? I suggest you read Avoid eqnarray by Lars Madsen and decide for yourself.

2

I used mhchem package, which solves your problem. Here is the code. You should also install chemgreek as mhchem uses it. (Note that the command for chemical equation is \ce.)

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage[version=4]{mhchem}

\begin{document}

\begin{subequations}
\begin{eqnarray}
\label{eq:formloss1}
\ce{HCHO + ^.OH -> CHO^. + H2O} \\
\ce{HCHO + $hv_{uv}$ ->[O2] CHO^. + HO2} \\
\label{eq:formloss2}
\ce{HCHO + $hv_{uv}$ -> CO + H2}
\end{eqnarray}
\end{subequations}

\end{document}
  • Please don't suggest people to install chemgreek manually! I've had quite a few “bug reports” because people did that instead of updating their distribution and having chemgreek installed and ready to use… – cgnieder Oct 2 '15 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.