13

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 ={,}}
  • Is there a convenient free font offering old style numbers? I don't have Arno Pro to test this. – Joseph Wright Jan 14 '11 at 21:19
  • Calibri offers them, Cambria too. – Ruud Jan 14 '11 at 21:22
  • The libertine font – user2478 Jan 14 '11 at 21:25
  • @Ruud: Calibri and Cambria aren't free. – Philipp Jan 14 '11 at 21:48
  • 3
    @Joseph: Herbert has already mentioned Linux Libertine, others are Antykwa Poltawskiego, Antykwa Torunska, Asana Math, Computer Modern, Cyklop, GFS Artemisia, GFS Baskerville, GFS Bodoni, GFS Didot, GFS Neohellenic, Iwona, Kurier, Latin Modern, Linux Biolinum, Neo Euler, TeX Gyre Adventor, TeX Gyre Bonum, TeX Gyre Chorus, TeX Gyre Cursor, TeX Gyre Heros, TeX Gyre Pagella, TeX Gyre Schola, TeX Gyre Termes, Vollkorn, XITS. TeX Live alone contains dozens of those. – Philipp Jan 14 '11 at 21:49
13

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}
  • 2
    You shouldn't use \newcommand and \fontspec to do this. You should use fontspec's \newfontfamily command: \newfontfamily\liningroman[Numbers={Lining}]{Linux Libertine O} – Alan Munn Jan 15 '11 at 0:53
  • @Alan. Altered - I can't say I use the fontspec beyond loading it, so I've never had occasion to set up a new font family before. – Joseph Wright Jan 15 '11 at 6:20
  • 3
    The reason is that when you put \fontspec to select a font into a command like that, every time you use the command, it has to parse the font features over again; the \newfontfamily kind of encapsulates the features and is therefore much more efficient. – Alan Munn Jan 15 '11 at 13:30
  • This solution works perfectly, thank you very much! – Ruud Jan 15 '11 at 15:33
  • 1
    @lblb 'Every one of the font options can be given independently for units and number, with the prefixes unit- and number-, respectively.': there are a lot of options this applies to, and listing them all in the docs seems like overkill. – Joseph Wright Oct 3 '17 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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