# How to tell pgfplots to use math font for manually selected tick labels [duplicate]

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

Edit: I updated the MWE, removing mtpro2, which actually changes the output, but not the issue.

MWE

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{times}
\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}

Result without mtpro2

Result with mtpro2

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{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}

• they are already in math mode. So if you don't do anything they should pickup the math font. – percusse Apr 17 '18 at 14:52
• If I compile the document, I don't get the same result for xticklabels and yticklabels – BambOo Apr 17 '18 at 14:57
• mtpro is not longer on ctan. The replacement, mtp2lite, isn't either, at least not directly. – John Kormylo Apr 17 '18 at 16:54
• @anderstood, I just edited the post to show the result with mtpro2 – BambOo Apr 18 '18 at 18:56
• This question is similar: tex.stackexchange.com/q/281503/159527 and its accepted answer should do what you want. The third method looks especially suitable. – RobotRaven Nov 13 '18 at 18:14