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 Answer 1

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}
5
  • This is true for every input type, by the way :)
    – cgnieder
    Commented Dec 31, 2014 at 12:09
  • Also notice the difference for math output: it is followed by a space (which can be controlled through an option...).
    – cgnieder
    Commented Dec 31, 2014 at 12:10
  • @cgnieder Is the edit OK? Commented Dec 31, 2014 at 12:35
  • Sure :) There is also \setchemformula{math-space=0em} which can be used without chemmacros. Also, the option can be used directly: \ch[math-space=0em]{...}
    – cgnieder
    Commented Dec 31, 2014 at 12:37
  • Thank you very much. The examples from the chemformula documentation worked for me, too. But I couldn't figure out that these spaces are required!
    – Timo Stein
    Commented Dec 31, 2014 at 13:17

You must log in to answer this question.

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