A good guide on what factors to consider when mixing fonts is Thierry Bouche's Diversity in math fonts article in TUGboat, Volume 19 (1998), No. 2.
The most important aspect is to use the same font for text and math letters (as well as letter-like symbols as \partial
or \infty
). This has drawbacks as some letters will suffer from spacing problems, but compared to the other option (using totally different math letters), it's really a lesser evil. Of course, if this is not acceptable to you, then you should first choose the math font and then use the same font for text, but that limits your font choices dramatically.
Once you've assigned the text font to the math letters, the remaining choices you face is for the geometric symbols, the delimiters and the big operators (\sum
, \int
, \bigcup
etc.). The main consideration is color (how bold the symbols are) and the shape of the symbols (mainly the shape of sum or integral symbols, especially if you use them often). Compared to Libertine, XITS and Asana are a bit too bold (especially true for the sum symbol), Latin Modern is a bit too light (especially +
, \otimes
, etc.), and Cambria has a very huge \sum
symbol, huge \otimes
and \oplus
as well as very bold \bigcup
. Thus, which font will look better will depend on what type of math you're typing, and none will be perfect.
Here's a sample to show the results of this font mixing with Libertine. Notice the spacing problems around the f in f(r_k)
and \Sigma_c f(r)
due to the fact that's it's a text font we're using for math. I've not set all letter-like symbols to come from Libertine (only \infty
), so there's still room for improvement. (Note also the missing parenthesis in one of the formulas with Latin Modern Math.)
\documentclass{article}
\usepackage{amsmath}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{Linux Libertine O}
\newcommand{\setlibertinemath}{%
% use Libertine for the letters
\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={"2202}]{Linux Libertine O}% "02202 = \partial % doesn't work
\setmathfont[range={"221E}]{Linux Libertine O}% "0221E = \infty
% etc. (list should be completed depending on needs)
}
\newcommand{\sample}{%
When computing the sums $\sum_{k=0}^{+\infty}{f(r_k)}$ of $f$ the integral representation of $K_0(x)$ may be used.
\[
\eta(r)\frac{\partial f}{\partial r} + 2\Sigma_cf(r)
= \sum_{k=0}^{+\infty}{K_0\mathopen{}\left(\frac{\lvert r - r_k \rvert}{L}\right)}
= \int_{0}^{\infty}{e^{-\left(z+\frac{r^2}{4L^2\pi}\right)} \frac{dz}{2z}}.
\]
We then use
\[
\bigcup_{\lambda \in \Lambda}{U_\lambda} \cap \bigsqcup_{\delta > 0}{G_\delta} = \bigcap_{i \in I}{\mathbf{A}_i}
\quad \text{so that} \quad
u \otimes w \oplus v = 0.
\]
}
\pagestyle{empty}
\begin{document}
\section{Libertine + Latin Modern}
\setmathfont{Latin Modern Math}\setlibertinemath
\sample
\section{Libertine + Cambria}
\setmathfont{Cambria Math}\setlibertinemath
\sample
\section{Libertine + XITS}
\setmathfont{XITS Math}\setlibertinemath
\sample
\section{Libertine + Asana}
\setmathfont{Asana Math}\setlibertinemath
\sample
\end{document}
Your document doesn't compile with XeLaTeX on my system, so I can't compare LuaLaTeX and XeLaTeX.
There is a tiny problem in the code, but I am not the expert here:
\setmainfont[SmallCapsFont={Linux Libertine Capitals O}]{Linux Libertine O}
With OpenType fonts the small caps are included in the main font. So there is no reason to explicitly mention a different one. Linux Libertine at least has them built in. Then there is no font Linux Libertine Capitals O
on my system and I don't think that I have removed them explicitly.
Linux Libertine does not have a small caps ā in the font as far as I can see. And thus there is no way to display it. (You could fake it though.)
The problem with the small tt does not exist here, so I can't comment on that either. But I guess the correct answer is what Herbert commented:
Why didn't you simply use \usepackage{libertineotf}
? It does all the font setting.
\documentclass[a4paper]{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX,Numbers=OldStyle}% ,Scale=MatchLowercase} bug in current Biolinum
\setmainfont{Linux Libertine O}
\setsansfont{Linux Biolinum O}
\begin{document}
\noindent Linux Libertine serif text followed by {\scshape Sans serif Small Caps text.} {\scshape Small Caps disappear when diacritics are used like a macron above a in anāchron: note the small letter for the ā instead of a Small Caps version.}
\medskip
\sffamily
\noindent Linux Biolinum sans serif text followed by {\scshape Sans serif Small Caps text.} {\scshape Small Caps disappear when diacritics are used like a macron above a in anāchron: note the small letter for the ā instead of a Small Caps version.}
\end{document}
gives:
Best Answer
Actually, it is not that difficult; the problems arise more from the many options the
biolinum
family offers, which means there is no\biolinum
command per se.The following should allow you access to both types of sans serif: