Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

try the new TeX Gyre Pagella Math which is part of TL 2012:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\setlength{\parindent}{0pt}
\usepackage[partial=upright,nabla=upright]{unicode-math}
\setmainfont{Linux Libertine O}
\setmonofont{LinMonoO} 
\setmathfont{TG Pagella Math}
\setmathfont[range={\mathcal,\mathbfcal},StylisticSet=1]{XITS Math}

\def\Macro#1{\texttt{\textbackslash#1}}
\begin{document}

\[ \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]
\]

\Macro{mathscr}: $\mathscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
\Macro{mathscr}: $\mathscr{abcdefghijklmnopqrstuvwxyz}$\\
\Macro{mathbfscr}: $\mathbfscr{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
\Macro{mathbfscr}: $\mathbfscr{abcdefghijklmnopqrstuvwxyz}$

\bigskip
\Macro{mathcal} and \Macro{mathbfcal}

\texttt{StylisticSet=1}: $\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
\texttt{StylisticSet=1}: $\mathbfcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$

\setmathfont[range={\mathcal,\mathbfcal},StylisticSet=2]{XITS Math}
\texttt{StylisticSet=2}: $\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$\\
\texttt{StylisticSet=2}: $\mathbfcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$

\end{document}

enter image description here

share|improve this answer
    
Thanks again for all the font suggestions, however I did not ask for an alternative math font. My thesis and the figures in it are in Libertine, and I want the equations to look as close as possible. I understand that not all features will are available in Libertine, but it does have glyphs like accents and parenthesis which work in text mode but not so well in math mode. –  fheshwfq Aug 24 '12 at 15:04
add comment

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.

share|improve this answer
    
Hi Kaled, XITS is indeed a better match but using it (with Libertine for the alphanumeric only), the accents are still misplaced. And as I said having the parentheses in the same font as the alphanumerics is really important for me. –  fheshwfq Aug 24 '12 at 14:27
    
Sorry, but nothing can be done about this (to my knowledge at least), math typesetting is hard and many things need to be done on the font side, so any solution short of a complete OpenType math support in Libertine is a limited hack. –  Khaled Hosny Aug 24 '12 at 14:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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