[Tex/LaTex] Using \sffamily for tick labels in pgfplots

fontspgfplots

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
]
\addplot {0.5-abs(x-0.5)};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

which gives

MWE

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?

Best Answer

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
]
\addplot {0.5-abs(x-0.5)};
\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

enter image description here