[Tex/LaTex] How to use lining figures in siunitx and fontspec

fontspecoldstylenumssiunitx

I'm using XeTeX and fontspec, and I have selected old-style figures for my body text. Now I use the siunitx package, and have set it up to use text fonts instead of math fonts. For the siunitx values I want to use lining figures instead of old-style figures. How do I do this?

I have tried this, but it does not work:

\setromanfont[Numbers=OldStyle]{Arno Pro}
\usepackage{siunitx}
\sisetup{mode = text}
\sisetup{inter-unit-separator =\cdot}
\sisetup{detect-all}
<snip>
{\fontspec[Numbers={Lining}]{Arno Pro}\SI{10}{\kilo\volt\per\centi\metre}}

Furthermore, siunitx uses the math font comma instead of the text font comma when using

 \sisetup{output-decimal-marker ={,}}

Best Answer

Font detection in siunitx uses the document defaults unless you provide something else. So in your example your getting \rmfamily. The key is to define a font command which will select what you want.

\documentclass{article}
\usepackage{fontspec,siunitx}
\setromanfont[Numbers=OldStyle]{Linux Libertine O}
\newfontfamily\liningroman[Numbers={Lining}]{Linux Libertine O}
\sisetup{mode = text,number-text-rm = \liningroman}
\begin{document}
1234567890
\SI{123456789}{\kilo\volt\per\centi\metre}
\end{document}

I see that there is a second part to the question, asking about the output-decimal-marker option. As detailed in the manual, this is a math mode option. If you want to force this to be in text mode you need to use \text:

\documentclass{article}
\usepackage{fontspec,siunitx}
\setromanfont[Numbers=OldStyle]{Linux Libertine O}
\newfontfamily\liningroman[Numbers={Lining}]{Linux Libertine O}
\sisetup{mode = text,number-text-rm = \liningroman,
  output-decimal-marker=\text{,}}
\begin{document}
1234567890
\SI{123.456789}{\kilo\volt\per\centi\metre}
\end{document}
Related Question