# interaction between mhchem \ce command and square brackets

So I have a number of equations with concentrations in them... and using mhchem I find an anomaly (probably in my understanding!) when I use \ce with []

\ce{[OH-]} does not give me [OH^{-}], but gives me [OH-], but \ce{[H+]} does give me [H^{+}]. [\ce{OH-}] does give [OH^{-}].

I am not sure what I don't understand here...

with thanks for the help

Chris

Here is my guess: [ and ] are part of the compound as far as mhchem is concerned and in the middle of a compound a - is interpreted as a single bond which is what you're seeing in \ce{[OH-]}. At the end of a compound a - is interpreted as a negative charge which is what you're seeing in \ce{OH-}. Since + does not have a different meaning in the middle of a compound it doesn't behave differently but is interpreted as a positive charge both times.

\documentclass{article}
\usepackage[version=3]{mhchem}
\begin{document}
\ce{[OH-]} vs \ce{OH-}

\ce{[OH\bond{-}]}

\ce{[H+]} vs \ce{H+}
\end{document}


The way out is clear: \ce{[OH^-]}