2

I'm preparing a thesis for publication, and the publisher requires the use of a font with old style numerals in textmode. This results in old style numerals being used when I use the \ce command. No problem, I just redefine \ce so that it's automatically in math mode, like so:

\documentclass{article}

\usepackage{mathspec}
\makeatletter % undo the wrong changes made by mathspec
\let\RequirePackage\original@RequirePackage
\let\usepackage\RequirePackage
\makeatother

\setmainfont{Constantia}
\setmathsfont(Digits){TeX Gyre Termes}
\setmathsfont(Latin){Constantia}
\setmathrm{Constantia}

\usepackage[version=4]{mhchem}
%All uses of \ce are in math mode:
\let\oldce\ce
\renewcommand{\ce}[1]{\ensuremath{\oldce{#1}}}

\begin{document}
\oldce{[Co^{II}(NCS)6]^4-}\ce{[Co^{II}(NCS)6]^4-}
\end{document}

This gets me the proper numerals, and a proper minus sign as a bonus, but now the brackets don't match those in text mode:

Two version of the same chemical formula, each having the desired elements, but each undesirable in their own way.

Is there a way to replace these mathmode brackets with the textmode brackets? Perhaps something based on this answer?

1
  • If you look closely, the parentheses aren't the same either. May 16, 2019 at 15:47

1 Answer 1

4

Why don't you change instead the textfont used by mhchem, e.g.:

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Constantia}
\newfontfamily\cefamily{Constantia}[Numbers=Lining,Ligatures=TeX]
\usepackage[version=4]{mhchem}
\begin{document}

\ce{[Co^{II}(NCS)6]^{123456789}-}

\mhchemoptions{textfontcommand=\cefamily}

\ce{[Co^{II}(NCS)6]^{123456789}-}
\end{document}

enter image description here

You must log in to answer this question.

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