I am using the classicthesis package in LyX to typeset my thesis. I have a plot produced with pgfplots. It uses math fonts same as elsewhere in the text, which is inconsistent with other plots of mine (imported from Matlab), where Arial is used for tick and axes labels. So my question is, how can I change the font family for the text used in my pgfplots plot (i.e. the caption font should NOT change)? The minimal TeX code would be:

\pgfplotsset{every axis/.append style={
tick style={semithick}}}
xlabel = {$x$},
ylabel = {$\phi(x)$},
domain = 0:1,
no markers,
cycle list name=linestyles
\addplot {0.5-abs(x-0.5)};
\caption{Solution of Eikonal equation on a 1D domain $\Omega=[0;1]$}

So I would like all the tick numbers, and x and \phi(x) labels to be in Arial, while the bottom caption to remain in Palatino.


Simply using \pgfplotsset and \sffamily is probably not sufficient for you, since your numbers and labels are in math mode. It can be achieved with the sansmath package, such as

  tick label style = {font=\sansmath\sffamily},
  every axis label = {font=\sansmath\sffamily},
  legend style = {font=\sansmath\sffamily},
  label style = {font=\sansmath\sffamily}

You probably have still to take care of Greek letters though, if you use eulervm. Without that package, \sansmath works well. Or, omit sans serif style for the label, and do it manually at this specific place, such as

xlabel = {$\mathsf{x}$},
ylabel = {$\phi\mathsf{(x)}$},

All together I got with your code all labels in sans serif, while the caption remains in serif font:


  • This is almost brilliant! But you are right, phi(x) looks very ugly. But how would I take care of it? And is there a way to make the labels non-italic? – MindV0rtex Nov 1 '11 at 16:38
  • @MindV0rtex Consider changing the Matlab plots to match your LaTeX style for keeping all consistent. Or keep at least labels such as \phi(x) similar to your expressions in code instead of trying sans serif Greek, at least the numbers and tick labels would match your Matlab style. – Stefan Kottwitz Nov 1 '11 at 16:53
  • Mine is the same except for the \phi(x) part, which instead looks something like OEx without any parentheses (I don't know how to add pictures to comments and I don't want to add another answer). Does it mean that I lack some font files? – MindV0rtex Nov 1 '11 at 17:24
  • @MindV0rtex If you don't load eulervm, \phi works with \sansmath. – Stefan Kottwitz Nov 2 '11 at 11:38
  • @stefan-kottwitz How can I use my font's sffamily? I have set it up like this: \renewcommand{\sfdefault}{mysf-font} and when I use font=\sffamily it doesn't change accordingly. – jonen Jun 8 '14 at 13:46

This is more of an extended comment than an answer, but I think it might be useful for others.

Following page 75 of the pgfplots manual (Revision 1.17 (2020/02/29))


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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