6

How do i use math mode in chemformula? The first example works, including the sub- and superscript. In the second example the subscripts don't work.

\documentclass[12pt,a4paper]{scrartcl}
\usepackage{chemmacros}
\chemsetup{modules={reactions}}
\begin{document}
\begin{reactions}
X -> Y  &\hfill &   \text{because\ $E=m_{x}c^2$}
\end{reactions}
\begin{reactions}
A + B &->[$E_{a,1}$] AB \\
A + K + B &->[$E_{a,2}$] AK ->[$E_{a,3}$] AB + P
\end{reactions}
\end{document}

enter image description here

7

Inside a reactions environment, _ changes its meaning; you can use \sb in its place. For ^ there is \sp.

\documentclass[12pt,a4paper]{scrartcl}
\usepackage{chemmacros}
\chemsetup{modules={reactions}}
\begin{document}
\begin{reactions}
X -> Y  &\hfill &   \text{because\ $E=m\sb{x}c^2$}
\end{reactions}
\begin{reactions}
A + B &->[$E\sb{a,1}$] AB \\
A + K + B &->[$E\sb{a,2}$] AK ->[$E\sb{a,3}$] AB + P
\end{reactions}
\end{document}

enter image description here

2
  • Thanks, I didn't know about that command \sb. Is it always an identical backup to _?
    – Wulfram
    Jun 10 '17 at 16:17
  • @Wulfram Yes, unless some devious package changes it.
    – egreg
    Jun 10 '17 at 16:25
3

When using chemformula it is important to know that spaces separate different parts inside \ch{..} and – as a consequence – inside a reaction environment. This means ->[ $E_{a,1}$ ] will work. There is only one thing else to keep in mind: chemformula per default inserts some space before a math part. (I am not convinced any more this is the best default behaviour, but…)

BTW: it also doesn't make much sense (IMHO it's actually wrong) to write a text part within \ch{...} with \text. The recommended way in chemformula is escaping text with "...": "because\ $E=m_{x}c^2$".

\documentclass[12pt,a4paper]{scrartcl}
\usepackage{chemmacros}
\chemsetup{
  modules={reactions} ,
  formula = chemformula ,
  chemformula/math-space = 0pt
}
\begin{document}

\begin{reactions}
  X -> Y  & & "because\ $E=m_{x}c^2$"
\end{reactions}

\begin{reactions}
  A + B &->[ $E_{a,1}$ ] AB \\
  A + K + B &->[ $E_{a,2}$ ] AK ->[ $E_{a,3}$ ] AB + P
\end{reactions}

\end{document}

enter image description here

4
  • Thanks. Well, I used \text{} because i am used to do so in equations resp. i the \begin{align}environment (is that wrong?). It's just a made up example here, I don't usually put text in reactions...
    – Wulfram
    Jun 11 '17 at 18:12
  • If I am already here - how can i make labels over arrows that are more than one line? Didn't find an example in the documentation. \\ , \newlineand \linebreak don't work.
    – Wulfram
    Jun 11 '17 at 18:16
  • @Wulfram \text is a command by amsmath for placing text in math mode which matches the surrounding text. chemformula OTOH explicitly mentions its “escaping” mechanism with "..." in its manual.
    – cgnieder
    Jun 12 '17 at 5:55
  • @Wulfram maybe \newcommand*\stack[2][c]{\begin{tabular}{#1}#2\end{tabular}} and \ch{A ->[\stack{x\\y}] B}
    – cgnieder
    Jun 12 '17 at 5:55

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.