[Tex/LaTex] Using old style numerals in XeLaTeX in math mode

libertinemath-modeoldstylenums

I am using XeLaTeX and the Linux Libertine font to typeset my thesis. I set it up to use old style numerals in the text by:

\setromanfont[Ligatures={Common}, Numbers={OldStyle}]{Linux Libertine O}

Sometimes I use inline math, and these numbers are in Lining format, which looks strange with other numbers in the text (e.g. referring to a figure). I didn't specify a specific math font, if I do so (e.g. \usepackage[oldstylenums]{kpfonts} ), I do get the old style numerals in math mode but the font is not balanced with the text, so I'd like to stick with the default math font, or something that goes well with Linux Libertine. Of course, I can put all numbers outside the $ $, but that just seems like a hack, not something that you're supposed to do.

Am I trying to do something that is typographically incorrect? How do I use old style numerals for math mode?

Best Answer

\documentclass{article}
\usepackage{mathspec}
\setmainfont[Mapping=tex-text]{Linux Libertine O}
\setmathfont(Digits,Greek,Latin)[Numbers=OldStyle]{Linux Libertine O}
\begin{document}

$0123456789$

\end{document}

enter image description here