# PGF/TikZ and Sans Serif Fonts

I have a TikZ/PGF file created directly by a graphing package of the form \begin{tikzpicture}{dimensions} ... \end{tikzpicture}. The file uses \pgftext[...]{\selectfont{Some text here or \boldmath$math$}} to render text.

By default, when I include the file in my document, the text is typeset in the default font for my document (Latin Modern Serif). However, I wish for all of my figures/graphs to be typeset in a sans-serif font (Latin Modern Sans). How can I go about this?

Ideally, I would like to accomplish this without having to edit the file directly (so just changing the LaTeX around where I include it).

Update: Minimal Example

\begin{tikzpicture}
\pgftext{\selectfont{Hello \boldmath$W \times orld$}}
\end{tikzpicture}


Anything which can correctly set that piece of text to be sans-serif should do the trick.

-

\documentclass{minimal}
\usepackage{tikz}
\newenvironment{allpgftextsans}{%
\let\oldpgftext=\pgftext
\def\pgftext##1{\oldpgftext{\sffamily##1}}
}{}

\begin{document}
\begin{tikzpicture}
\begin{allpgftextsans}
\pgftext{\selectfont Hello \boldmath$W \times orld$}
\end{allpgftextsans}
\end{tikzpicture}
\end{document}


Kind of a hack but it does the trick.

-
Works a treat for regular text, but does not touch the math. However, I understand that sans-serif math is a problem in general. –  Freddie Witherden Nov 5 '10 at 9:36
Oh, I didn't realize you wanted the math to change font. Different question. But the answer can be adapted...whatever commands you can find to do it once, add them before \sffamily. –  Matthew Leingang Nov 5 '10 at 9:57

Some more details could have been very helpful. To choose a certain font style for your picture you simply have to give appropriate options to the tikzpicture environment.

\begin{tikzpicture}[font=\sffamily]
% picture contents
\end{tikzpicture}


For a global setting you may try \tikzstyle{every picture}+=[font=\sffamily] in the preamble.

-
No luck; I've added a minimal example to my original question so as to be more specific. –  Freddie Witherden Nov 3 '10 at 23:54
@Freddie: It's better if you include a minimal working example, i.e., a document that can be complied as is, and then say what doesn't work out as you want. –  Hendrik Vogt Nov 4 '10 at 15:40