# Using math-mode in pgfplots axis unit

I want to apply a unit to my axis. Usually I use the siunitx package for that. However, this time I would like to use a Greek letter with a subscript \mu_\text{B} but my document won't compile.

Here is a MWE which compiles if you remove the $s. \documentclass[]{scrartcl} \usepackage[utf8]{inputenc} \usepackage{mathtools} \usepackage{pgfplots,tikz} \pgfplotsset{compat=newest} \usepgfplotslibrary{units} \begin{document} \begin{figure}[tbch] \centering \begin{tikzpicture} \begin{axis}[ axis line style={very thick}, axis lines = left, y unit ={$A$}, unit marking pre={\text{in }}, unit marking post={}, ylabel = Yupp ] \end{axis} \end{tikzpicture} \end{figure} \end{document}  ## 1 Answer Since all typesetting of labels occur within math mode, you don't need $ there. Just use

y unit =\mu_{\text{B}},


Here is the MWE

\documentclass[]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage{mathtools}

\usepackage{pgfplots}
\usepgfplotslibrary{units}

\begin{document}

\begin{figure}[tbch]
\centering
\begin{tikzpicture}
\begin{axis}[
axis line style={very thick},
axis lines = left,
y unit =\mu_{\text{B}},
unit marking pre={\text{in }},
unit marking post={},
ylabel = Yupp
]
\end{axis}
\end{tikzpicture}
\end{figure}

\end{document}


• You can use y unit =\si{\micro}_{\text{B}}, too if you need. – user11232 May 11 '15 at 13:16