# Using \sffamily for tick labels in pgfplots [duplicate]

Possible Duplicate:
How can I change the font family in pgfplots?

I'm trying to use sf font for tick labels in pgfplots. I've already seen many questions like this, but all of them had more complex problems and I couldn't find the appropriate solution myself.

My MWE:

\documentclass[12pt,a4paper]{report}
\usepackage[latin1]{inputenc}
\usepackage{pgfplots}
\usepackage{helvet}
\pgfplotsset{compat=1.3}
\begin{document}
\begin{figure}
\centering

\pgfplotsset{
every axis label/.append style={font=\huge\sffamily},
tick label style={font=\sffamily\huge},
}

\begin{tikzpicture}
\begin{axis}[
height=8cm,
width=15cm,
xlabel = {x3456},
ylabel = {y},
domain = 0:1,
xtick={0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0},
ytick={0.0,0.1,0.2,0.3,0.4,0.5},
grid=major,
no markers,
cycle list name=linestyles
]
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}


which gives

As you can see, \sffamily works for the axis labels, but not for the tick labels. Strangely, the \huge does work for the tick labels.

How do I change tick labels to \sffamily?

## marked as duplicate by Martin Scharrer♦Jan 4 '13 at 23:24

• I think that the question How can I change the font family in pgfplots? applies here. Could you try out that solution? – Jake Jan 4 '13 at 21:52
• That's where I got my mwe from. They use math mode to use sans font. I think now I understand what is happening. Tick labels seem to be considered math expressions, so \sffamily doesn't work with them. So you have to use \sansmath. If someone can confirm this, I appreciate. – perr0 Jan 4 '13 at 22:03
• Yup, that's exactly right. The tick labels are generated using \pgfmathprintnumber{\tick}, which in turn uses math mode. – Jake Jan 4 '13 at 22:26

If my comment regarding tick labels being considered math expressions is correct, you must use math mode sans font to make them sans serif. On the other hand, axis labels are considered normal text, so you have to use \sffamily to make them sans serif.

So, the solution would be:

\documentclass[12pt,a4paper]{report}
\usepackage[latin1]{inputenc}
\usepackage{pgfplots}
\usepackage{helvet}
\usepackage[eulergreek]{sansmath}
\pgfplotsset{
tick label style = {font=\sansmath\sffamily},
every axis label/.append style={font=\sffamily\footnotesize},
}
\pgfplotsset{compat=1.3}
\begin{document}
\begin{figure}
\centering

\begin{tikzpicture}
\begin{axis}[
height=8cm,
width=15cm,
xlabel = {x3456},
ylabel = {y3456},
domain = 0:1,
xtick={0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0},
ytick={0.0,0.1,0.2,0.3,0.4,0.5},
grid=major,
no markers,
cycle list name=linestyles
]
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}


I don't know why, but using only

every axis label = {font=\sffamily\footnotesize}


does not work for me, so I had to use

every axis label/.append style={font=\sffamily\footnotesize}.


With the above code, the output is

• Wouldn't it be more useful to mark your question as duplicate of tex.stackexchange.com/questions/33325/… and maybe edit the answer over there to clarify the things that you didn't get correctly instead of stating a duplicate question an answer here? – Benedikt Bauer Jan 4 '13 at 23:09
• I agree, but I had already posted the question when I figured it out. If there's a way to delete it, I'll do it, but I can't see how. Leaving it unanswered wouldn't help it either. – perr0 Jan 5 '13 at 0:29