Using XeTeX with fontspec
and unicode-math
, I would like to use the documents main font for for digits (numbers) in mathmode. Also, I would like to make \text{}
in mathmode use Lining numbers while the default for the document are OldStyle numbers. How can I achieve this behavior?
I tried inserting \setmathfont[range=\mathup/{num}]{Linux Libertine O}
but it does not give the desired result.
Here is an MWE, pointing out the problems:
\documentclass{article}
\usepackage{iftex}
\usepackage{libertine}
\usepackage{fontspec}
\setmainfont[Numbers=OldStyle]{Linux Libertine O}
\usepackage{amsmath}
\usepackage{unicode-math}
% Here I try to set up the normal text font for digits in mathmode:
\setmathfont[range=\mathup/{num}]{Linux Libertine O}
\parindent0pt
\begin{document}
This is \ifXeTeX XeTeX\fi\ifLuaTeX LuaTeX\fi
with \fontname\font
\bigskip
Text numbers:
0123456789; italic: \textit{0123456789}; bold: \textbf{0123456789}
Text numbers lining:
\liningnums{0123456789; italic: \textit{0123456789}; bold:
\textbf{0123456789}}
Numbers in mathmode: $0123456789$ (ok)\\
mathit: $\mathit{0123456789}$ (wrong font)\\
mathbf: $\mathbf{0123456789}$ (wrong font)\\
mathrm: $\mathrm{0123456789}$ (wrong font)\\
text (math): $\text{0123456789}$ (should be lining)
In big equation, fonts for big brackets $\big( \Big( \bigg( \Bigg($ are
missing:
\[
\left(\frac{12a}{34b}\right)
\]
\end{document}
Using XeTeX, this results in:
So there are 3 problems:
Linux Libertine O
for digits does not appear in\mathrm
,\mathit
, and\mathbf
etc.- The big brackets are not working. (See more on this below.)
- Is there a way to achieve Lining numbers in mathmode
\text{}
although the document number style is OldStyle?
Concerning problem 1, this is due to range=\mathup/{num}
only applying to updright math text. Does anyone know how to apply this command for all numerals in all ranges? using only range={num}
results in an error.
Concerning problem 2, I have two more pieces of information. A) Using LuaTeX on the same file, the brackets do appear, but without being scaled:
B) If I comment out the line \setmathfont[range=\mathup/{num}]{Linux Libertine O}
, the problem does not occur at all. This suggests that the bracket mechanism is affected by changing the font for numbers, which it shouldn't be, right?
This problem is, by the way, not specific to Linux Libertine O
. It also appeared when I was using SabonNextLTPro
as main document font.
Best Answer
In the meantime until anybody might come up with an idea, I though I'd share a workaround. It's basically reverting to
mathspec
instead ofunicode-math
. Nearly everything works out of the box in only three lines: