I'm trying to use Linux Libertine as the math (and main) font, and I used this answer to set the math fonts. However, the math output is still CM.

\usepackage{amsmath, mathspec, libertine, lipsum}


    \hat{Q}_i=\int_0^\infty \mathcal{G}^2(x) \Sigma^{-1}(x^2) f_i(x)dx


enter image description here

If I try to uncomment the newtxmath line, I get an error

Package mathspec Error: amsmath' must be loaded earlier thanmathspec'

But I have loaded amsmath before mathspec!

How do I fix these issues (fixing either is fine, since the goal is to use LL fonts for math).

As pointed out, moving newtxmath before amsmath solves the problem in the above MWE. Now let me change it a bit and include amsthm as well, which now leads to a host of other errors such as:

! LaTeX Error: Command \openbox already defined. Or name \end... illegal, see p.192 of the manual.

  • @karlkoeller Strange, that seems to work for this example. However, if I add amsthm as well, it gives lots of errors... Sep 12, 2013 at 19:58
  • The right order is amsthm, newtxmath, mathspec. Don't load amsmath since it is loaded by newtxmath. Sep 12, 2013 at 20:14
  • @karlkoeller Oh dear... never would've though that. If you'd like to answer, I'll accept it. Sep 12, 2013 at 20:57

2 Answers 2


The right order to load those packages is amsthm, newtxmath, mathspec


You don't need to load amsmath since it is already loaded by newtxmath. That's also the reason why mathspec complains when you load newtxmath after it.

Moreover, note that both amsthm and newtxmath define the \openbox command. But, while the former defines it through a \newcommand, the latter does it through a \DeclareRobustCommand, so it does not complain...


Libertinus is a fork of Linux Libertine with bug fixes and very good math support (check out this example document). It would enable you to use Linux Libertine for math without using newtxmath. This is the question title ... (see XY problem).

To be compiled with xelatex and Libertinus fonts installed.



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

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\)




Be aware though: xe(la)tex currently (TeX Live 2016) has a bug, which is visible in my screenshot: Why is the fraction off the math axis in XeTeX? . lualatex of TeX Live 2016 has a bug as well: spacing in LuaLaTeX with unicode-math


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .