# Vertical bars in chemical equation

I'm trying to write chemical equations with mhchem, but I can't compile the code when I insert vertical bars (||) in the formula.

\usepackage[version=4]{mhchem}
.
.
\begin{center}
\ce{|M_{x}(H2O)_{\gamma}|[Al_{x}Si_{t-x}O_{2t}]-IZA}
\end{center}


When I write ||, the code don't compile, but if I replace it by [] it works fine.

Any suggestions?

• Could you provide a minimal working example? – Rico Jan 2 '16 at 21:22
• I would like write something like this: \begin{center} \ce{|M_{x}(H2O)_{\gamma}|[Al_{x}Si_{t-x}O_{2t}]-IZA} \end{center} I need write || in the formula. I wouldn't like replace it by [ ] because IUPAC rules don't allow. – Valeria García Melgarejo Jan 2 '16 at 21:24
• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – user36296 Jan 2 '16 at 21:30
• You could split up the \ce like so: |\ce{M_{x}(H2O)_{\gamma}}| \ce{[Al_{x}Si_{t-x}O_{2t}]-IZA} – Rico Jan 2 '16 at 21:52
• Have a look at tex.stackexchange.com/questions/46519/…. – biozic Jan 2 '16 at 21:53

I don't know if the bars in my example are in proper places, but the idea is simple: putting them in math mode:

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

\begin{document}
\begin{center}
\ce{$|$M_{x}(H2O)_{\gamma}$|$ $|$Al_{x}Si_{t-x}O_{2t}$|$-IZA}
\end{center}

\end{document}


You could simply split up you formula.

\documentclass{article}

\usepackage[version=4]{mhchem}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}
\begin{center}
|\ce{M_{x}(H2O)_{\gamma}}| \ce{[Al_{x}Si_{t-x}O_{2t}]-IZA}
\end{center}

\end{document}


The other answers offered workarounds. As for the question, why this is not supported by the \ce macro, well, the author never considered this particular notation. If you can provide an argument that this is a standard chemical notation (preferably by a IUPAC colored book), he will be happy to include this into one of the next mhchem releases.

• It seems that here is bug. For example \ce{M_{x}(H2O)_{\gamma}|} works, but \ce{|M_{x}(H2O)_{\gamma}} not and \ce{$|$M_{x}(H2O)_{\gamma}|} works again. Also works \ce{O2|M_{x}(H2O)_{\gamma}|}. Error is only if vertical bar is in beginning of chem formula. – Zarko Jan 3 '16 at 18:34