4

Preface

I'm using XeLaTeX and typeset a document using the TeX Gyre Pagella Math font in conjunction with the unicode-math package. This is some sample code

\documentclass{standalone}
\usepackage{unicode-math}
\setmathfont{TeX Gyre Pagella Math}
\begin{document}
$a^2 + b^2 = c^2$
\end{document}

I use Debian GNU/Linux on my machine with a "vanilla" TeXLive. For me the above example compiles all fine, but when a friend of mine, who is using Ubuntu GNU/Linux with texlive-full from the official repositories tried to compile it, he encountered font-not-found errors.

It turned out, that the font is installed on his system, but is named TG Pagella Math instead of TeX Gyre Pagella Math.

Question

How do I implement a switch between two fontnames in XeLaTeX using unicode-math? See my pseudo-code for better visualisation

...
\usepackage{unicode-math}
\IFDEF UBUNTU
  \setmathfont{TG Pagella Math}
\ELSE
  \setmathfont{TeX Gyre Pagella Math}
\ENDIF
...
6
  • The font was misnamed at its first release. Up-to-date distributions should carry the font with the longer name.
    – egreg
    Jun 11, 2013 at 20:46
  • @egreg Is there a way, that I can rename the font? Jun 11, 2013 at 20:59
  • You can load them by their "file name". Look in the documentation of fontspec
    – egreg
    Jun 11, 2013 at 21:04
  • @egreg Is there an official announcement anywhere for the renaming of the font? I'd like to file a bug report to the maintainer. Jun 11, 2013 at 21:15
  • The change happened between versions 1.543 and 1.605 of the fonts, see the diff in TeX Live: tug.org/svn/texlive/trunk/Master/texmf-dist/doc/fonts/…
    – egreg
    Jun 11, 2013 at 21:45

2 Answers 2

3

This should work

\ifx\UBUNTU\undefined
  \setmathfont{TG Pagella Math}
\else
  \setmathfont{TeX Gyre Pagella Math}
\fi

(assuming you define \UBUNTU earlier in your friends' version of the code and comment it in yours, or to avoid that hassle and be able to sync effortlessly, both include a settings file with the same name but with \UBUNTU defined or not).

For more details about the mechanism (and alternatives), check this answer:
What is the difference between \ifx\somecommand\undefined and \ifdefined\somecommand\else?

1
  • 1
    only if you arrange for \UBUNTU to be defined in one case? Jun 11, 2013 at 20:31
5

Note that if the fonts have different names they are presumably a different release so (may?) have different metrics which will lead to different line and page breaks. So an alternative might be just to locally install the latest version of the fonts on both machines and load them.

However perhaps the simplest way to have that kind of local customisation is to put

\InputIfFileExists{\jobname.cfg}{}

Then you can share the document but have non-shared .cfg file one of which say

 \setmathfont{TG Pagella Math}

and the other says

 \setmathfont{TeX Gyre Pagella Math}

You can of course include any other customisation in the same file.

You must log in to answer this question.

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