8

I use the Lucida font for my documents with its old style numerals in text and its lining figures in mathmode.

But how can I get lining figures inside chemical eqautions with mhchem?

Here is some sample code (I compile with either latex or pdflatex)

\documentclass{article}

\usepackage[paperwidth=90mm, paperheight=20mm, left=10pt, top=20pt]{geometry}%

\usepackage[romanfamily=bright-osf,stdmathdigits=true,scale=.9]{lucimatx}

\usepackage{mhchem}

\begin{document}
Chemical formula: \ce{2 H2O -> 2H2 + O2}
\end{document}

This is what I get Old style numerals This is what I want No old style numerals

I already tried

{\fontfamily{hlh}\selectfont \ce{2 H2O -> 2H2 + O2}}

But that will mess up the format if the equations get more complicated

I found a related entry with the same problem but this guy uses luatex: text figures (old style numbers) and mhchem

2
  • Sorry, can you explain why that will mess up the formula once it gets more complicated? By first instinct is to rename \ce to add the fontfamily commands to it, but I'm opening the mhchem manual now.
    – Canageek
    Apr 22, 2012 at 17:49
  • This one compiles but ignores the font command: \begin{align*} \fontfamily{hlh}\selectfont \cee{2H + O2 &->[\Delta E] 4H+ + 4e- + O2} \end{align*} Apr 22, 2012 at 18:00

2 Answers 2

4

I can't test this, as I've not purchased the Lucidia fonts, but using the mhchem manual I've created:

\documentclass{minimal}
\usepackage[paperwidth=90mm, paperheight=20mm, left=10pt, top=20pt]{geometry}
\usepackage[romanfamily=bright-osf,stdmathdigits=true,scale=.9]{lucimatx}
\usepackage{mhchem}

\mhchemoptions{textfontcommand=\fontfamily{hlh}\selectfont}
\mhchemoptions{mathfontcommand=\fontfamily{hlh}\selectfont\text}

\begin{document}
Chemical formula: \ce{2 H2O -> 2H2 + O2}
\end{document}
6
  • \mathsf works but it makes Sans-Serif (of course). If I switch to \mathrm the old style numerals also come back. \mhchemoptions{mathfontcommand=\fontfamily{hlh}\selectfont\mathrm} is being ignored. Apr 22, 2012 at 18:05
  • \mhchemoptions{textfontcommand=\fontfamily{hlh}\selectfont} works good, but only in textmode Apr 22, 2012 at 18:07
  • Right, you'd have to change \mhchemoptions{mathfontcommand=foo} to change what it does in mathmode. Try what I have above.
    – Canageek
    Apr 22, 2012 at 18:39
  • \mhchemoptions{mathfontcommand=\fontfamily{hlh}\selectfont} makes all letters italic. Apr 22, 2012 at 18:59
  • I found a solution \mhchemoptions{textfontcommand=\fontfamily{hlh}\selectfont} and \mhchemoptions{mathfontcommand=\fontfamily{hlh}\selectfont\text}. Maybe there are pitfalls, but for now this seems to behave correct. Apr 22, 2012 at 19:04
3

mhchem uses the active font. So if you write in text-mode, you'll get oldstyle numerals, whereas in math-mode you'll get lining figures:

\documentclass{article}
\usepackage[osf]{mathpazo}
\usepackage{mhchem}

\begin{document}

\ce{2H2O -> 2H2 + O2} \qquad $\ce{2H2O -> 2H2 + O2}$

\end{document}

Output will be:

enter image description here

You must log in to answer this question.

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