# Is it possible to use Linux Libertine as a mathematical font?

I recently heard that there is a package called unicode-math that makes it possible to use an ordinary TTF/OTF font for mathematic typesetting. To what degree is that possible with Linux Libertine? I love this font, only the lack of math-support is a bit annoying, although euler is a good match IMHO.

To provide a more current answer to this, there is now Libertinus, a fork of Linux Libertine with bug fixes and pretty nice math support (check out this example document).

\documentclass[varwidth,border=1mm]{standalone}

\usepackage[
math-style=ISO,
bold-style=ISO,
partial=upright,
nabla=upright
]{unicode-math}

\setmainfont{Libertinus Serif}
\setsansfont{Libertinus Sans}
\setmathfont{Libertinus Math}

\begin{document}
The formula $$E=mc^2$$ is arguably the most famous formula in physics.

In mathematics, it could be $$\mathrm{e}^{\mathrm{i}\uppi}-1=0$$.

$$\displaystyle \sum_{k=0}^\infty \frac{1}{k^2} = \frac{\uppi^2}{6}$$, and
$$\displaystyle \int\displaylimits_{-\infty}^\infty \exp\left(-\frac{x^2}{2}\right) = \sqrt{2\uppi}$$.

$$\alpha\beta\gamma\delta\epsilon\zeta\eta\theta\iota\kappa\lambda\mu\nu\xi\pi\rho\sigma\tau\upupsilon\phi\chi\psi\omega \varepsilon\vartheta\varrho\varsigma\varphi\varkappa$$

$$\upalpha\upbeta\upgamma\updelta\upepsilon\upzeta\upeta\uptheta\upiota\upkappa\uplambda\upmu\upnu\upxi\uppi\uprho\upsigma\uptau\upupsilon\upphi\upchi\uppsi\upomega \upvarepsilon\upvartheta\upvarrho\upvarsigma\upvarphi\upvarkappa$$

$$\Alpha\Beta\Gamma\Delta\Epsilon\Zeta\Eta\Theta\Iota\Kappa\Lambda\Mu\Nu\Xi\Pi\Rho\Sigma\Tau\Upsilon\Phi\Chi\Psi\Omega$$

$$\upAlpha\upBeta\upGamma\upDelta\upEpsilon\upZeta\upEta\upTheta\upIota\upKappa\upLambda\upMu\upNu\upXi\upPi\upRho\upSigma\upTau\upUpsilon\upPhi\upChi\upPsi\upOmega$$
\end{document}


• The link to the example document is dead. – Kubo Sep 11 '18 at 7:30
• @Kubo: I fixed the link. – lblb Sep 15 '18 at 7:48

There is a new LaTeX math package called newtx with a libertine option that matches Libertine text, using Libertine Roman italic and Greek together with symbols from the old txfonts package, remetrized so as not to be as cramped, and with optical versions of math italic and symbols. Versions prior to 0.93 were problematic, but 0.93, which should appear shortly on CTAN, seems to work well.

• Welcome, Michael. Remember to register, as we look forward for your valuable contributions. – egreg May 22 '12 at 22:25
• I would go as far as to say that Linux Libertine is (sadly) more or less useless for setting LaTeX documents that includes any type of math without newtxmath (described in the documentation for newtx) loaded. The vanilla metrics are completely bonkers in math mode if one naively sets Linux Libertine as a math font, and one will have to spend hours on manual kerning to get nice results. Or: just issue \usepackage[libertine]{newtxmath} and get good results immediately. Some situations may still call for manual kerning, but several order of magnitudes fewer than without the package. – Daniel Andersson Aug 30 '14 at 12:53

It's not too hard to use it for the variables and constants (letters). For XeLaTeX, you could use the mathspec package. For regular PDFLaTeX, you could use the mathastext package, e.g.:

\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[italic]{mathastext}


That will give you Computer Modern symbols with Libertine letters and numbers. See the mathastext documentation for options regarding Greek, etc. If you load another symbol font (eulervm, etc.) before loading these you'll get its symbols with libertine letters. Personally I like to load txfonts for symbols, and then load these.

I don't know to make it work if you want the few symbols it contains (which is more than most fonts, but certainly not quite enough either), you could probably use unicode-math, but you'll have to switch back to other fonts for the many symbols it lacks.

• Is it possible to use it for, say, \sum, \int and friends? I think you call them "bigops" – FUZxxl Oct 5 '11 at 15:11
• As far as I know the font does not provide these characters. – Ingo Apr 6 '12 at 16:00

Here is a modified version of Mico answer that does not use mathspec. Neo Euler is set as base math font (can be replaced by any OpenType math font), but math roman and italic are taken from Linux Libertine.

\documentclass{minimal}
\usepackage{unicode-math}
\setmainfont[Ligatures=TeX]{Linux Libertine O}
\setmathfont[Scale=MatchLowercase]{Neo Euler}
\setmathfont[range=\mathup]{Linux Libertine O}
\setmathfont[range=\mathit]{Linux Libertine O Italic}
\setmathfont[range=\mathbfup]{Linux Libertine O Bold}
\setmathfont[range=\mathbfit]{Linux Libertine O Bold Italic}

\begin{document}
The formula $E=mc^2$ is arguably the most famous formula in physics.

In mathematics, it could be $\mathrm{e}^{\mathrm{i}\pi}-1=0$.

$\displaystyle \sum_{k=0}^\infty \frac{1}{k^2} = \frac{\pi^2}{6}$, and
$\displaystyle \int_{-\infty}^\infty \exp\left(-\frac{x^2}{2}\right) = \sqrt{2\pi}$.
\end{document}


Notice the bad placing of some superscripts since Libertine is not a proper math font.

The package unicode-math requires XeLaTeX or LuaLaTeX and a font that has special mathematical tables and, currently, there's no such font in the Linux Libertine family.

With XeLaTeX you can try

\usepackage{mathspec}
\setmathsfont(Digits,Latin,Greek)
[Numbers={Lining,Proportional}]{Linux Libertine O}


but as Linux Libertine O Italic has not the right parameters for letters as math symbols, some adjustments are needed in certain situations, see the manual of mathspec.

Note: I changed the answer below after learning that the OP prefers "Neo Euler" to "XITS Math".

As others have noted, there is as of now no OpenType math version of the Linux Libertine fonts. You've indicated that you'd might want to use the Neo Euler fonts. Font purists will no doubt be able to point out any numbers of differences between the two fonts; let me just say up front that I will fully agree with all of their points, but we're consciously making a compromise here.

A consideration is how to scale the math font; usually, a good starting point is to set "Scale=MatchLowercase". Second, Neo Euler only has "upright" rather than slanted font shapes for letters and numerals; in consequence, it's probably a good idea to use Libertine's italics (text) font for upper- and lowercase letters as well as for numerals, even though the glyphs' sidebearings won't be correct in many cases. The code below, which uses the mathspec package, illustrates the results of scaling Neo Euler to have the same x-height as Linux Libertine.

% !TeX program = xelatex
\documentclass{article}
\usepackage{mathspec}
\setmainfont[Ligatures=TeX]{Linux Libertine O}
\setmathfont[Scale=MatchLowercase]{Neo Euler}
\setmathfont(Digits,Latin,Greek){Linux Libertine O} % override

\begin{document}
The formula $E=mc^2$ is arguably the most famous formula in physics.

In mathematics, it could be $\mathrm{e}^{\mathrm{i}\pi}-1=0$.

$\displaystyle \sum_{k=0}^\infty \frac{1}{k^2} = \frac{\pi^2}{6}$, and
$\displaystyle \int_{-\infty}^\infty \exp\left(-\frac{x^2}{2}\right) = \sqrt{2\pi}$.
\end{document}


Observe the near-collisions between letters and superscript numerals, which are a consequence of the fact that the letters and digits come from a text rather than from a math font.

Personally, I think it's preferable to use a dedicated math font such as XITS Math together with Linux Libertine. Obviously, this will also entail making some compromises, but at least the spacing around math glyphs won't be an issue. One would load the XITS Math package as follows (note the use of the fontspec and \unicode-math packages instead of the mathspec package):

\usepackage{fontspec,unicode-math}
\setmainfont[Ligatures=TeX]{Linux Libertine O}
\setmathfont[Scale=MatchLowercase]{XITS Math}


The resulting output from the preceding MWE would then look like this:

Happy TeXing!

• Thank you for the help, but it's just - well - I hate this font. It looks too sharp and is no match for the rather round and organic libertine... btw, is there also a way to rescale euler to match libertine in height? – FUZxxl Oct 5 '11 at 16:10
• Yeah, Times New Roman (the model for XITS) is not to everyone's taste! I've revised my answer to play off Libertine Text and Neo Euler math. As you'll see, you still need to make a decision regarding scaling of the math font. – Mico Oct 5 '11 at 16:49
• You need math-style=upright with Neo Euler (since it has no math italics), else you will get LM Math italic (as in the sample you posted above). But since Euler alphabet is so much different from Libertine (XITS is much more closer), you better use Libertine text italic in math as well (though it has side effects) and keep Euler for math symbols. – Khaled Hosny Oct 5 '11 at 17:08
• @KhaledHosny -- thanks! I've made the change in the code and the displayed image. I fully agree with you, incidentally, that XITS Math is a much better match for Linux Libertine than Neo Euler is. – Mico Oct 5 '11 at 17:31
• @Mico hm... The image is still not quite correct... – FUZxxl Oct 5 '11 at 17:57

If you also thought that MnSymbol fits best to Libertine here is a (quite well) working hack:

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
%\usepackage[lf]{MinionPro}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{MnSymbol}
\protected\def\mathbb#1{\text{\usefont{U}{msb}{m}{n}#1}} %gives us blackboard back -> http://tex.stackexchange.com/questions/214570/try-to-use-ams-blackboard-bold-font-together-with-texgyrepagella
\begin{document}
0123456789 äüöÄÜÖß Office The $\sum_{i=1}^\infty\alpha\xi\geq\oplus\alpha\sqrt[n]{n}$
$$\left(\int_{i=0}^\infty\times \sum_{i=0}^\infty\right)\idotsint$$
\end{document}


The output is:

Now compared to MinionPro: