I have a pgfplots axis, displaying some data. The ticklabels are defined manually, so the standard font used is the base text font.
What I would like to do is to obtain tick labels using the math font of my document without putting all of my ticklabels in math mode using $ ... $.
Basically, I think I just need to add some ticklabel style={font=\mathseries} but I don't know what command to use instead of \mathseries.
I apologize in advance for this somewhat dummy question.
CLOSE EDIT
I used egreg's answer in the duplicate link, not the accepted answer.
Edit: I updated the MWE, removing mtpro2, which actually changes the output, but not the issue.
MWE
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{times}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=5cm,
height=5cm,
at={(0cm,0cm)},
scale only axis,
plot box ratio=1 1 1,
xmin=0,
xmax=10,
xtick={0,2,4,6},
% HERE THE LABELS DEPEND ON THE MATH MODE
xticklabels={$0.12$,0.12,$0.345$,0.345},
ymin=-0.5,ymax=9.5,
ytick=\empty,
zmin=0.0000e+00,
zmax=10,
view={-4.4000e+01}{5.9600e+01},
axis x line*=bottom,
axis y line*=left,
axis z line*=left,
ticklabel style={font={\footnotesize}},
]
\end{axis}
\end{tikzpicture}%
\end{document}
As you can see, the labels within $ ... $ and the other labels have different fonts.
Edit 2 Comment regarding the use of assume math mode from pgfmanual v3.0.1a p954
/pgf/number format/assume math mode={hbooleani} (default true) Set this to true if you don’t want any checks for math mode. The initial setting checks whether math mode is active using \pgfutilensuremath for each final number. Use assume math mode=true if you know that math mode is active. In that case, the final number is typeset as-is, no further checking is performed.
Edit 3 I added a xticklabel={$\pgfmathprintnumber{\tick}$} after the xticklabels={...} call. I actually overwrites the manually defined xticklabels and uses the values in xtick but gives the desired math output...
Updated MWE
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{times}
\pgfplotsset{compat=newest}
\pgfplotsset{xticklabel={\pgfmathprintnumber[assume math mode=true]{\tick}}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
width=5cm,
height=5cm,
at={(0cm,0cm)},
scale only axis,
plot box ratio=1 1 1,
xmin=0,
xmax=10,
xtick={0,2,4,6},
% HERE THE LABELS DEPEND ON THE MATH MODE
xticklabels={$0.12$,0.12,$0.345$,0.345},
%PRINTS THE TICKS IN MATH MODE BUT NOT THE MANUALLY SET TICKLABELS
xticklabel={$\pgfmathprintnumber{\tick}$},
ymin=-0.5,ymax=9.5,
ytick=\empty,
zmin=0.0000e+00,
zmax=10,
view={-4.4000e+01}{5.9600e+01},
axis x line*=bottom,
axis y line*=left,
axis z line*=left,
ticklabel style={font={\footnotesize}},
]
\end{axis}
\end{tikzpicture}%
\end{document}



mtpro2, but the problem remains. – BambOo Apr 17 '18 at 19:29times? – anderstood Apr 17 '18 at 21:23{0.12, 3.45, ...}so that they are rendered as they had typed{$0.12$, $3.45$, ...}. – anderstood Apr 17 '18 at 23:00\pgfplotsset{xticklabel={\pgfmathprintnumber[assume math mode=false]{\tick}}}does not work (see 373722). – anderstood Apr 18 '18 at 13:01assume math mode=trueonly seems to leave the result as it is no matter what the value contains. See the edit in the question. However, there is no explanation on whatassume math mode=falseshould do. Only check for math environment ? enforce math environment ? – BambOo Apr 18 '18 at 14:02\usepackage{mathptmx}. See also this answer. If you're usingmtpro2I don't know what the problem is, but the difference might be unnoticeable... – anderstood Apr 18 '18 at 18:27mtpro2– BambOo Apr 18 '18 at 18:56