4

When I try to use the \left( and \right) commands in a chemistry equation, using mhchem, I get multiple errors. It is also not possible to use \bigl( or similar.

For example, the following:

\documentclass{article}
\usepackage{mhchem}
\begin{document}
    \[\ce{Zn/Zn^{2+} \left(c = 1\frac{mol}{l}\right) // Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}\]
\end{document}

Gives these errors:

  • line 4: Missing delimiter (. inserted). ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Missing \right. inserted. ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Missing \endgroup inserted. ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Missing \endgroup inserted. ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Missing delimiter (. inserted). ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Extra \right. ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Missing delimiter (. inserted). ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Missing \right. inserted. ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Missing $ inserted. ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Display math should end with $$. ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Missing delimiter (. inserted). ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Extra \right. ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Extra \endgroup. ...Pb^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}
  • line 4: Bad math environment delimiter. ...^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}]
  • line 4: \begin{document} ended by \end{equation*}. ...^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}]
  • line 4: Missing $ inserted. ...^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}]
  • line 4: Display math should end with $$. ...^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}]
  • line 4: Extra \endgroup. ...^{2+} \left(c = 1\frac{mol}{l}\right)/Pb}]

If I were to write the same code without a mhchem equation, I would get no error.

Is there any workaround or another way to use parentheses that automatically scale in mhchem?

7
  • Please, can you add full example?
    – Sebastiano
    Dec 20, 2020 at 11:48
  • 1
    @Sebastiano I added more information
    – jng224
    Dec 20, 2020 at 11:54
  • Don't tell me you really use \left( … \right) for such a content as 1!
    – Bernard
    Dec 20, 2020 at 12:00
  • 2
    The third one is not an error but a warning and is completely unrelated with your question… Can you give a use case where you actually would want scaled delimiters within a chemical formula?
    – cgnieder
    Dec 20, 2020 at 12:00
  • What does "giving the concentration in a fraction" refer to in the context of a reaction equation? Do you refer to stochiometric numbers/factors such as 1/2 O2? Using \ce{1/2 O2} or \ce{(1/2) O2} should be sufficient for that.
    – leandriis
    Dec 20, 2020 at 12:07

2 Answers 2

5

The argument of \ce is processed in a quite complicated fashion and math mode is not in effect. This works, see page 9 of the manual.

\documentclass{article}
\usepackage[version=4]{mhchem}

\begin{document}

\[
\ce{
  Zn/Zn^{2+} $\Big($ c = 1\frac{mol}{l} $\Big)$
  // Pb^{2+} $\Big($ c = 1\frac{mol}{l} $\Big)$/Pb
}
\]

\end{document}

enter image description here

1
  • 3
    The c should be in italic. As most of the equation is math and not chemistry, I would suggest just putting Zn etc. into \ce and leaving the rest outside.
    – mhchem
    Dec 20, 2020 at 21:07
6

I am still not quite sure in which context you want to display the concentration of Pb2+ ions (inside of the text or of a mathematical equation or...). Nevertheless, here are some options :

enter image description here

\documentclass{article}
\usepackage[version=4]{mhchem}

\usepackage{siunitx} % provides the SI command to typeset number and their units
\sisetup{per-mode=fraction}

\usepackage{chemmacros}
\usechemmodule{units} % Provides the \Molar unit
\begin{document}

\ce{Pb^{2+}} \(\left(c = \SI{1}{\mol\per\liter}\right)\)
  
\[ \ce{Pb^{2+}} \left(c = \SI{1}{\mol\per\liter}\right) \]


\sisetup{per-mode=symbol}
\ce{Pb^{2+}} \((c = \SI{1}{\mol\per\liter})\)

\sisetup{per-mode=reciprocal}
\ce{Pb^{2+}} \((c = \SI{1}{\mol\per\liter})\)

\ce{Pb^{2+}} \((c = \SI{1}{\Molar})\)

\end{document}

You must log in to answer this question.

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