2

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

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}
\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 =\mu_{\text{B}},
            unit marking pre={\text{in }},
            unit marking post={},
            ylabel = Yupp
        ]
        \end{axis}
    \end{tikzpicture}
    \end{figure}

\end{document}

enter image description here

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

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.