2

I'm using XeTeX and the fontspec and unicode-math packages. In order to use a different math font for Greek letters, I do something like this, using the range option of \setmathfont:

\setmathfont[Path=/usr/share/texmf/fonts/opentype/public/tex-gyre-math/]{texgyretermes-math.otf} 
\setmathfont[range=\mathit/{greek,Greek},Path=/usr/share/texmf/fonts/opentype/public/tex-gyre/]{texgyretermes-regular.otf} 

Now, how could I change the font for only one Greek letter (say \phi) ?

Update

Based on @egreg's answer (which is deleted now), I tried the following code. The $\phi$ does not appear in the output. If I replace this line by the commented line, then $\phi$ appears in the output but it is not in regular font.

% !TeX program = XeLaTeX
% !Mode:: "TeX:UTF-8"
\documentclass[fontsize=12pt]{scrartcl}
\usepackage{amsmath,amssymb,amsfonts,amsthm}
\usepackage{unicode-math}
\usepackage{fontspec}
\setmonofont[Path=/usr/share/fonts/truetype/freefont/,Scale = 1.05]{FreeMonoBold.ttf} 
\setmainfont
[        Scale = 1.1,
     Extension = .otf,
   UprightFont = *-regular,
      BoldFont = *-bold,
    ItalicFont = *-italic,
BoldItalicFont = *-bolditalic,
]{xits}

\setmathfont[Path=/usr/share/texmf/fonts/opentype/public/tex-gyre-math/]{texgyretermes-math.otf} 
\setmathfont[range={\mitvarphi,\mitphi},Path=/usr/share/texmf/fonts/opentype/public/tex-gyre/]{texgyretermes-regular.otf}
% \setmathfont[range=\mathit/{varphi,phi},Path=/usr/share/texmf/fonts/opentype/public/tex-gyre/]{texgyretermes-regular.otf}
\setmathfont[range=\int,Path=/usr/share/texmf/fonts/opentype/public/tex-gyre-math/]{texgyretermes-math.otf}

\begin{document}

$\phi = \psi+1$. 

\end{document}

Second update

Since I use only three greek letters in my document, phi, mu and lambda, the following code works :

\setmathfont[Path=/usr/share/texmf/fonts/opentype/public/tex-gyre-math/]{texgyretermes-math.otf} 
\setmathfont[range=\mathit/{greek,Greek},Path=/usr/share/texmf/fonts/opentype/public/tex-gyre/]{texgyretermes-regular.otf} 
\setmathfont[range={\mitmu,\mitlambda},Path=/usr/share/texmf/fonts/opentype/public/tex-gyre-math/]{texgyretermes-math.otf} 
  • TeX Gyre Termes is not a math font, so it has no \mitphi and \mitvarphi. – egreg Jul 7 '15 at 9:53
  • @egreg And why that does not work with the commented line instead ? – Stéphane Laurent Jul 7 '15 at 9:58
  • @egreg I also tried range=\mathit/{"03D5} – Stéphane Laurent Jul 7 '15 at 10:11
  • It's not at all clear what your aim is. – egreg Jul 7 '15 at 10:27
  • @egreg : I want the converse of your output : only $\phi$ in regular font, not the other Greek letters. I have just posted a working solution, but it requires to list all the other Greek letters. – Stéphane Laurent Jul 7 '15 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.