I learned from this answer that the package sansmath can be used to change the font of tick label by setting option tick label style
. Now I want to set the tick label font to be sans serif font while other fonts such as legend font and label font are still serif fonts. I use xelatex and unicode-math. How can I achieve this?
\documentclass{article}
\usepackage{sansmath}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.16,
tick label style={font=\sansmath\sffamily},
}
\usepackage{unicode-math}
\setmathfont{TeX Gyre Termes Math}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates {(1,2) (2,3)};
\addlegendentry{$n=1$};
\end{axis}
\end{tikzpicture}
\end{document}
In the above example, the tick label font is in the italic form. I want to make only the tick label font is sans serif and all other positions are still serif fonts.