I want to have all tikz graphics in \sffamily font. However, I cannot set a base font for tikz, as it will be overridden, whenever I user, e.g., font=\itshape
, for a node locally.
I tried to set a prefix such as \tikzset{font/.prefix = {\sffamily}}
, as well as to change de default font using \AtBeginEnvironment{tikzpicture}{\renewcommand*{\familydefault}{\sfdefault}}
and \AtEndEnvironment
, respectively.
Also, I tried \tikzset{execute at begin picture={\renewcommand*{\familydefault}{\sfdefault}}}
. However, nothing helped.
I'm simply looking for a proper way to set the base font in all tikz environments to \sfdefault
.
In the following MWE, the first node should be sans, oblique, the other two nodes should be similar:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [font=\sffamily\itshape] {I should be in sans italic};
\node [font=\itshape,below] {I should be in sans italic};
\node [font=\bfseries,above] {I should be in sans oblique};
\end{tikzpicture}
\end{document}
Best Answer
Here is a simple solution (if you don't already use
every picture
style). Add the following line in your preamble:Example: