1

I am trying to use the absolute value symbol in the \ce{} environment provided by the mhchem package, but the value is converted to a horizontal line. Is there a way to escape the symbol so that it will be interpreted literally?

MWE:

\documentclass{article}
\usepackage[version=3]{mhchem}
\begin{document}
\ce{A_{|a|}B_{b} <=>}
\end{document}

MWE output

1
  • 1
    I'd simply use math mode: \ce{A_$|a|$B_$b$ <=>}. Since a, b are variables, they are not supposed to be upright characters anyway.
    – andselisk
    Nov 10, 2018 at 5:03

1 Answer 1

1

Just load the fontenc package with T1 encoding (which is a good thing most of the times when using pdflatex):

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

\begin{document}

\ce{A_{|a|}B_{b} <=>}

\end{document}

enter image description here


I've used version 4 in the example but the answer holds for version 3 as well.


Personally I'd also use math mode for the variables and I'd probably define a command like \abs:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[version=4]{mhchem}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\begin{document}

\ce{A_{$\abs{a}$}B_{$b$} <=>}

\end{document}

You must log in to answer this question.

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