4

When using the following code everything works just fine:

\documentclass{article}
\usepackage{siunitx}
\usepackage[modules=all]{chemmacros}

\begin{document}
  \ch{!(colorless)( VO3- ) ->[\SI{-0.255}{V}][ Fe^2+ ] !(blue)( VO^2+ )}
\end{document}

enter image description here

But I need to switch the places between potential and reducing agent:

\documentclass{article}
\usepackage{siunitx}
\usepackage[modules=all]{chemmacros}

\begin{document}
  \ch{!(colorless)( VO3- ) ->[ Fe^2+ ][\SI{-0.255}{V}] !(blue)( VO^2+ )}
\end{document}

Compilation fails with the following error: Extra }, or forgotten \endgroup. ... Fe^2+ ][\SI{-0.255}{V}] !(blue)( VO^2+ )}. What is going on here and how can I use siunitx syntax properly in a label below arrow?

7
  • The problem does not just appear to be using \SI below the line, but (maybe also) in using Fe^2+ above the line. Sep 22, 2017 at 11:52
  • 1
    write ->[ Fe^2+ ][ "\SI{-0.255}{V}" ]
    – cgnieder
    Sep 22, 2017 at 12:01
  • 1
    @clemens maybe I'm out of date on packages, but the above-arrow quantity still blows me up. To get it to work, I have to use ->[$\textrm{Fe}^{2+}$][ "\SI{-0.255}{V}" ] Sep 22, 2017 at 12:03
  • 2
    @StevenB.Segletes did you leave the spaces around Fe^2+? They're important!
    – cgnieder
    Sep 22, 2017 at 12:20
  • 1
    I did, but forgot to leave spaces around the " (didn't realize the importance). Sep 22, 2017 at 12:24

1 Answer 1

6

The reason is quite obvious once you know it. Remember that chemformula splits its input at every space! Let's have a look at the different inputs and what chemformula sees:

In the case ->[\SI{-0.255}{V}][ Fe^2+ ] chemformula parses three parts:

  1. ->[\SI{-0.255}{V}][ – this is detected as an arrow which means that apart from replacing -> with an arrow command everything is left as is
  2. Fe^2+ – this is detected as a chemical formula and treated as such
  3. ] – this is detected as a chemical formula and treated as such

In the case ->[ Fe^2+ ][\SI{-0.255}{V}] chemformula parses three parts:

  1. ->[ – this is detected as an arrow
  2. Fe^2+ – this is detected as a chemical formula
  3. ][\SI{-0.255}{V}] – this is detected as a chemical formula and treated as such; this means for example that numbers get converted to sub- and superscripts according to the rules explained in the manual! As a consequence \SI cannot parse its argument any more!

In the case ->[ Fe^2+ ][ "\SI{-0.255}{V}" ] chemformula parses five parts:

  1. ->[ – this is detected as an arrow
  2. Fe^2+ – this is detected as a chemical formula
  3. ][ – this is detected as a chemical formula
  4. "\SI{-0.255}{V}" – this is detected as escaped text; the " are stripped and the rest is left as is
  5. ] – this is detected as a chemical formula

There is one basic rule: a part that can not cleanly be detected as special input (text, stoichiometric factor, arrow, …) is always treated as a chemical formula.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .