Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
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 '12 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*} –  Henri Menke Apr 22 '12 at 18:00
add comment

2 Answers

up vote 4 down vote accepted

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}
share|improve this answer
    
\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. –  Henri Menke Apr 22 '12 at 18:05
    
\mhchemoptions{textfontcommand=\fontfamily{hlh}\selectfont} works good, but only in textmode –  Henri Menke Apr 22 '12 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 '12 at 18:39
    
\mhchemoptions{mathfontcommand=\fontfamily{hlh}\selectfont} makes all letters italic. –  Henri Menke Apr 22 '12 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. –  Henri Menke Apr 22 '12 at 19:04
show 1 more comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.