I'm trying to define a document template, in which I have a serif-font for the main text and math, but just for my plots (tikz/pgfplots) I'd like to have a sans font, Fira Sans namely.
I can load the Fira Sans package in the preamble, and successfully switch between serif and sans serif fonts. If I enable \usepackage(sfmath}
, the plot looks good, while the equation in the main text is also set using the sans-font. On the other hand, if I disable % \usebackage{sfmath}
, the math in the plot is set in serif-font.
Here a small example...
\documentclass{article}
\usepackage{Fira Sans}
% \usepackage{sfmath} <-- enable/disable here!
\usepackage{units}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\lipsum[2]
\begin{equation}
\Gamma(\phi) = \oint \alpha(\phi)\,\textrm{d}\phi
\end{equation}
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\sffamily
\def\curvea{287*100/x/1000}
\def\curveb{287*300/x/1000}
\def\curvec{287*500/x/1000}
\begin{axis}[
minor x tick num=3, minor y tick num=3,
xlabel={spec. Volume $v$ in $\unitfrac{m^3}{kg}$},
ylabel={Pressure $p$ in $\unit{kPa}$},
domain=0:3, y domain=0:300,
xmin=0, xmax=3, ymin=0, ymax=300,
samples=100,
]
\addplot[thick, solid]{\curvea} node[inner sep=2, fill=white, rotate=-10, pos=0.982] {\tiny $T=\Ta~\unit{K}$};
\addplot[thick, solid]{\curveb} node[inner sep=2, fill=white, rotate=-10, pos=0.993] {\tiny $T=\Tb~\unit{K}$};
\addplot[thick, solid]{\curvec} node[inner sep=2, fill=white, rotate=-10, pos=0.998] {\tiny $T=\Tc~\unit{K}$};
\end{axis}
\end{tikzpicture}
\caption{Caption}
\label{fig:my_label}
\end{figure}
\lipsum[4]
\end{document}
Please, could anyone point me into the right direction on how to use Fira Sans for the math inside the plot also, by keeping the serif-fonts for the main text?