6

When using 'foo' or "foo" in order to provide chemformula with input which shouldn't be treated as part of a chemical formula within \ch{}, numbers are still being typeset subscript. The code

\documentclass[fontsize=12pt,paper=a4]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{chemformula}
\begin{document}
\ch{Pd(0)L4} \ch{Pd'(0)'L4} \ch{Pd"(0)"L4} \ch{Pd$(0)$L4} \ch{Pd\textrm{(0)}L4} \ch{Pd(}0\ch{)L4} 
\end{document}

gives the following when compiling with the latest MiKTeX distribution (pdflatex):

enter image description here

As you can see, only the last dirty workaround invoking \ch{Pd(}0\ch{)L4} gives the desired output. I also tried to fool chemformula by entering 0 in math mode which didn't work either.

1 Answers1

8

You have to put a space before and after the escaping sequence, both in text and in math mode. That is, for example

\ch{Pd '(0)' L4}

instead of

\ch{Pd'(0)'L4}

MWE:

\documentclass[fontsize=12pt,paper=a4]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{chemformula}
\begin{document}
\ch{Pd(0)L4} \ch{Pd '(0)' L4} \ch{Pd "(0)" L4} \ch{Pd $(0)$ L4} \ch{Pd\textrm{(0)}L4} \ch{Pd(}0\ch{)L4}
\end{document} 

Output

enter image description here

As cgnieder has noticed, in math mode some spacing is inserted. To remove this, set

\setchemformula{math-space=0em}

globally, or, to have it locally

\ch[math-space=0em]{Pd $(0)$ L4}
karlkoeller
  • 124,410