1

I would like to use the Tex Gyre Pagella font in my document but only outside the math environment. I have tried setting the math font as in the following code:

% !TeX program = xelatex
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}

\usepackage[math-style=ISO]{unicode-math}
\setmainfont[
    Extension=.otf,
  UprightFont=*-regular,
  ItalicFont=*-italic,
  BoldFont=*-bold,
  BoldItalicFont=*-bolditalic,
  Numbers=OldStyle,
  Scale=MatchLowercase
  ]{texgyrepagella}
\setmathfont{NewCMMath-Book.otf} 

\begin{document}
This is some text that contains some \emph{italic text} and some \textbf{bold text} and some math: $x + y = z, \mathbf{x} + \mathbf{y} = \mathbf{z}$.
\end{document}

However, the bold version of the math still uses Tex Gyre Pagella instead of computer modern.

enter image description here

For reference, this is how the math should be displayed in computer modern:

enter image description here

How can tell \setmainfont to completely ignore everything inside the math environment?

In addition, the italic version of Tex Gyre Pagella seems to have a lower height compared to the regular version (see the above screenshot). Is it possible to scale the italic version to match the height of regular?

Thank you very much in advance for your help!

2 Answers 2

2

I'm not sure why you'd want to mix Computer Modern math with Palatino. The problem with italics is the Scale=MatchLowercase instruction that should never be given for the main font.

Anyway, the solution is not to load mathspec that is incompatible with LuaLaTeX and also has problem with the more recent versions of fontspec.

\documentclass{article}
\usepackage{amsmath}
%\usepackage{amsfonts}% not with unicode-math

\usepackage[math-style=ISO]{unicode-math}

\setmainfont[
  Extension=.otf,
  UprightFont=*-regular,
  ItalicFont=*-italic,
  BoldFont=*-bold,
  BoldItalicFont=*-bolditalic,
  Numbers=OldStyle,
  ]{texgyrepagella}
\setmathfont{NewCMMath-Book.otf}

\setmathrm{NewCM10-Regular.otf}[
  BoldFont=NewCM10-Bold.otf,
]
\begin{document}

This is some text that contains some \emph{italic text} and some \textbf{bold text}
and some math: $x + y = z, \mathbf{x} + \mathbf{y} = \mathrm{z}$.

\end{document}

enter image description here

I find the output rather ugly, to be honest.

3
  • Thank you so much!! Great answer as always! What would be your recommendation for a math font to be used with Pagella please?
    – f10w
    Commented Mar 18 at 21:32
  • @f10w TeX Gyre Pagella Math, of course.
    – egreg
    Commented Mar 18 at 22:04
  • Haha, of course! Though my eyes still prefer CM...
    – f10w
    Commented Mar 18 at 22:37
0

Using mathspec instead of unicode-math makes it work:

% \usepackage[math-style=ISO]{unicode-math}
\usepackage{mathspec} %loads fontspec as well

\setmainfont[
    Extension=.otf,
  UprightFont=*-regular,
  ItalicFont=*-italic,
  BoldFont=*-bold,
  BoldItalicFont=*-bolditalic,
  Numbers=OldStyle,
  Scale=MatchLowercase
  ]{texgyrepagella}
% \setmathfont{NewCMMath-Book.otf}

You must log in to answer this question.

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