[Tex/LaTex] Using Linux Libertine in math mode with unicode-math (XeLaTeX)

libertineunicode-mathxetex

I'm trying to use the Linux Libertine font for my thesis. Libertine in fact does have mathematical symbols, but I didn't manage to use them properly in unicode-math. The following example sums up my attempts to progressively add symbols from the font, and highlights the failures. I'm aware that some of the issues could not be solved because the OTF font does not fully support math, but maybe some of the issues could be solved using advanced TeX trickery. The two main problems are the accents and brackets; I can tolerate other symbols being taken from another font.

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\setlength{\parindent}{0pt}
\usepackage{fontspec}
\usepackage[partial=upright,nabla=upright]{unicode-math}

\newcommand{\sample}{\[ \underbrace{\frac{\partial y}{\partial x}R(x)^2}_{\text{Foo}} = \left[ \sum_{i=0}^\infty \tilde{f}_i \arcsin\left( \alpha_i^3 x \right) \right]^{-1} \sqrt[6]{\int \nabla y\times\mathbf{\theta}(y) \mathrm{d}\phi} \geq \mathring{\Omega}_\ell [d]\]}

\begin{document}
\sample
This is a correct rendering using Latin Modern. Let's try to add some Libertine\ldots

\setmainfont[Mapping=tex-text]{Linux Libertine O}
\setmathfont[range=\mathit/{latin,Latin,num,Greek,greek}]{Linux Libertine O Italic}
\setmathfont[range=\mathup/{latin,Latin,num,Greek,greek}]{Linux Libertine O}
\setmathfont[range=\mathbfup/{latin,Latin,num,Greek,greek}]{Linux Libertine O Bold}
\setmathfont[range=\mathbfit/{latin,Latin,num,Greek,greek}]{Linux Libertine O Bold Italic}
\setmathfont[range={"0300-"036F}]{Linux Libertine O}% Accents - won't compile correctly without this line
\setmathfont[range={"003D,"00D7,"2202,"2207,"2212,"221E,"2265}]{Linux Libertine O} % some more symbols, they work properly
% U+003D    Equal sign
% U+00D7    Cross
% U+2202    Partial
% U+2207    Nabla
% U+2212    Minus
% U+221E    Infinity
% U+2265    Greater or equal

\sample

\textcolor{red}{Problem 1:} accents are off (ugly hack: use \texttt{\backslash skew})\\
\textcolor{red}{Problem 2:} brackets are still in LM; at least the normal sized brackets must match the text, so let's add parentheses \& square brackets:

\setmathfont[range={"0028,"0029,"005B,"005D}]{Linux Libertine O}

\sample

\textcolor{red}{Problem 3:} only the right parenthesis extends\\
\textcolor{red}{Problem 4:} the underbrace became gibberish\\
Possible fix to 3 \& 4: include the extending brackets from  `Miscellaneous Technical' unicode block (\texttt{U+239B}--\texttt{U+23AA}); unfortunately it doesn't change anything.
\medskip

Libertine has a summation and integral symbol, let's try to use them:

\setmathfont[range={"2211,"222B}]{Linux Libertine O}

\sample

\textcolor{red}{Problem 5:} the summation symbol is too small; Note that the integral symbol was broken to an top and bottom parts (both exist in the font), but there are no top and bottom parts of the summation symbol in this font.
\end{document}

Trying to render a complex mathematical formula using Linux Libertine

Best Answer

Don't use anything but alphanumeric symbols from non-OpenType math fonts like Linux Libertine. Parenthesis, big operators (summation, integrals, etc.), wide accents, roots and so on, all need special considerations only enviable in full OpenType math fonts.

In general, if you want the highest quality of math typesetting, use only full math fonts, as you can see even in the first Libertine example the accents and the root degree are off.

XITS Math might be a better match than the lighter Latin Modern font.

Related Question