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}
Best Answer
In normal text,
phi
is only one glyph, and the font makes it upright, bold, italic, bold-italic. In math text, there are a dozenphi
glyphs, and the boldness, italic is part of the glyph itself:To have upright lower case Greek, use
\setmathfont{Asana Math}[math-style=french]
, for example, and use\mitphi
for italic phi.Use
\AtBeginDocument{\renewcommand\mupphi{\mitphi}}
to redefine upright phi as italic phi.To do the converse, italic lower case Greek with italic phi redefined as upright phi:
Or maybe even just use
\mupphi
wherever needed.