Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

 \pgftext{\selectfont{Hello \boldmath$W \times orld$}}

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

share|improve this question

2 Answers 2

up vote 2 down vote accepted

What about this:


 \pgftext{\selectfont Hello \boldmath$W \times orld$}

Kind of a hack but it does the trick.

share|improve this answer
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.

% picture contents

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

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.