You can search "texgyrehero" in your computer and you can get a font texgyreheros-italic.otf
, set mathsf
to it like
\documentclass{article}
\usepackage{fontspec}
\setmathsf{texgyreheros-italic.otf}
\newcommand{\sfmu}{\mathsf{μ}}
\begin{document}
\[
\sfmu : X \to Y
\]
\end{document}

Another solution: Use unicode-math
package
First you can refer to Greek sans serif math .
And you can try another opentype font which support "Math" script, like "Fira Math". Here are two examples:
- If you want to use sans serif
\mu
in total paper, you can use
\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{latinmodern-math.otf}
\setmathfont[range=\mitmu]{FiraMath-Regular.otf}
\begin{document}
\[
\mitmu : X \to Y,
\]
\end{document}

- As you said, you can declare a
sfit
family, here I call it fira
, you can use
\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{latinmodern-math.otf}
\setmathfontface\fira{FiraMath-Regular.otf}
\begin{document}
\[
\fira{\mupmu, \mitmu} : X \to Y,
\]
\end{document}

- If you insist on using
TeX Gyre Heros
, you can use
\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{latinmodern-math.otf}
\setmathfontface\sfit{texgyreheros-italic.otf}
\setmathfontface\sfup{texgyreheros-regular.otf}
\begin{document}
\[
\sfit{\mupmu}, \sfup{\mupmu} : X \to Y,
\]
\end{document}

Because TeX Gyre Heros doesn't contain "Math" script, so we can't use \sfit{\mitmu}
to get a italic \mu
.
In those examples, \mupmu
is a command declared by unicode-math
, which means m(math)up(upright)mu(μ)
, so you can easily guess what \mitmu
means.