How to write mathematical equations above and below double harpoons in chemical equations?

The processing of the arrow arguments somehow interferes with math mode. A workaround is to define two small macros that hide the content long enough to be processed normally:

\documentclass{article}
\usepackage{chemmacros}
\def\kf{k_f}
\def\kb{k_b}
\begin{document}
\begin{equation}
\sum_{s=1}^{N_s}\nu'_s \ch{X}_s  \ch{<=>[$\kf$][$\kb$]}   \sum_{s=1}^{N_s}\nu''_s \ch{X}_s 
\end{equation}
\end{document}

enter image description here

It's of course not ideal but if you don't need a lot of different variable-subscript combinations then it may be an acceptable solution.


Strictly speaking, this expression isn't an equation; rather, it's a reaction (a definition of a generic elementary reaction in chemical kinetics, to be precise). I think using labeled reaction environment from chemmacros's reactions module suits this case much better: this way one can also address it later both in text and in the list of reactions.

As for the troubles with math inside the chemical environment, chemformula's manual covers this case well (this has also been mentioned by polyn in the comments):

8.2. Math

If you especially want to input math you just enclose it with $ $. This output is different from the escaped text as it is followed by a space. The reasoning behind this is that I assume math will mostly be used to replace stoichiometric factors.

\ch{ $⟨escaped math⟩$ }
One of two possibilities to escape chemformula’s parsing into math mode.

\ch{ \(⟨escaped math⟩\) }
The second of two possibilities to escape chemformula’s parsing into math mode.

Additionally, I would use roman typeface for the textual subscripts instead of italics, and also denote forward and reverse rates with more common notations used in kinetics: k_fwd and k_rev instead of k_f and k_b, correspondingly. The subscript "f", for instance, is ambiguous and denotes "formation" or "fusion" in physical chemistry.

enter image description here

\documentclass[12pt]{article}
\usepackage{chemmacros}
    \chemsetup{modules=all}

\begin{document}

\begin{reaction}
    $\sum_{s=1}^{N\sb{s}}\nu'_s$ X_{$s$} 
    <=>[ $k_\mathrm{fwd}$ ][ $k_\mathrm{rev}$ ]
    $\sum_{s=1}^{N\sb{s}}\nu''_s$ X_{$s$}
    "\label{rxn:generic-kinetic-model}"
\end{reaction}

Reaction \ref{rxn:generic-kinetic-model} is elementary.

\listofreactions

\end{document}