# How to use siunitx with mathdesign and Adobe Garamond fonts?

I have seen this question, but in making an MWE I discovered that this happens without fontspec loaded at all. I would expect that siunitx's mode detection would cause output to match the numerals in either text or math mode in the rest of the document.

This works as I'd expect with two fonts including oldstyle numerals (cfr-lm and mathpazo): the numerals used in \num{560} correspond to those used in 560, and the same for $$\num{560}$$ and $$560$$.

But using adobe-garamond with mathdesign, I get oldstyle numerals with $$\num{560}$$ while getting uppercase numerals with $$560$$. The behavior is the same if I use  or  to delimit math mode. I tried to find a free font that also has this issue, but was unsuccessful; so I apologize in advance for that inconvenience.

How can I use siunitx with \usepackage[adobe-garamond]{mathdesign} and have siunitx's mode detection function properly?

MWE

\documentclass{article}
%\usepackage{cfr-lm} % this works as expected
%\usepackage[osf]{mathpazo} % this works as expected
%\usepackage{mathpazo} % this also works as expected
\usepackage[adobe-garamond]{mathdesign} % this doesn't work as expected (siunitx typesets oldstyle figures)
\usepackage{siunitx}
%\sisetup{detect-all} % tried this; it has no effect

\begin{document}
Here, a test of numerals in text mode: 560

And numerals in mathematics mode: $$560$$

And numerals in \textsf{siunitx} macros (text): \num{560}

And numerals in \textsf{siunitx} macros (math): $$\num{560}$$

% for Joseph's comment:
With mathnormal: $\mathnormal{560}$

With mathrm: $\mathrm{560}$
\end{document}


Output

*I realize that the sans serif fonts are bitmapped in my MWE; I just didn't load anything else for the purpose of keeping the MWE minimal.

• I don' have the font here, but my suspicion is \mathrm versus \mathnormal. Could you try a 'reference rendering' using them? – Joseph Wright Mar 12 '14 at 20:13
• @JosephWright you mean something like comparing $\mathrm{560}$ to $\mathnormal{560}$, correct? – Paul Gessler Mar 12 '14 at 20:19
• Yes, exactly: the standard settings in siunitx use \mathrm, but that may not always be the best choice. – Joseph Wright Mar 12 '14 at 20:20
• @JosephWright I edited this in... now I'm even more confused... why would math mode digits be slanted/italicized? – Paul Gessler Mar 12 '14 at 20:26
• @JosephWright I just found that mdpgd.sty doesn't set \mathnormal, so a default or fall-back is likely to be used. I don't know much of the TeXnical details behind math alphabets, but it seems to me that this might be relevant? – Paul Gessler Mar 13 '14 at 17:26

The mechanisms used by siunitx assume more-or-less 'well-behaved' setting of LaTeX font commands. In particular, in math mode the package uses \mathrm to typeset output as standard. If that fails, using \mathnormal is the usual fall back but here that does not appear to apply. I would therefore go to the second fall back of using \ensuremath:
\sisetup{number-math-rm = \ensuremath}