# PGFPlots: Math, commands and braces in text along path

Following my question here about how to plot a text along a path another question came up. How can I add math or commands with \command to the text along the path?

This here works:

postaction={decorate,decoration={text along path,text={|\scriptsize| Loading}}}

These do not:

postaction={decorate,decoration={text along path,text={|\scriptsize| 0\textdegree Loading}}}

postaction={decorate,decoration={text along path,text={|\scriptsize| 0$^{\circ}$ Loading}}}

I tried capsulating the commands and math with braces but this doesn't work either. No error is produced, just the compilation with pdflatex takes forever and doesn't end.

Can someone tell me why this does not work and how to fix that?

\documentclass[a4paper,10pt]{scrreprt}
\usepackage[T1]{fontenc}
% \usepackage[utf8]{inputenc}
\usepackage[latin1]{inputenc}
\usepackage{pgfplots}
\usetikzlibrary{decorations.text}
\usepackage{textcomp}

\pgfplotsset{compat=1.12}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
domain=0:2,
xmin=0, xmax=2.25,
ymin=0, ymax=4.5,
samples=100,
axis y line=center,
axis x line=middle,
]
postaction={decorate,decoration={text along path,
text align={center}
}},
domain=0.5:1.5,] {2*0.7*(1+x)*(1-1/(1+x)^3)+0.5};
text align={center},
}},
domain=0.5:1.5] {2*0.7*(1+x)*(1-1/(1+x)^3)-0.5};
\end{axis}
\end{tikzpicture}
\end{document}


Since it is a unit, I would use siunitx :

\addplot[draw=none,
postaction={decorate,decoration={text along path,
text align={center}
}},
domain=0.5:1.5,] {2*0.7*(1+x)*(1-1/(1+x)^3)+0.5};


Full code will be:

\documentclass[a4paper,10pt]{scrreprt}
\usepackage[T1]{fontenc}
% \usepackage[utf8]{inputenc}
\usepackage[latin1]{inputenc}
\usepackage{siunitx}
\usepackage{pgfplots}
\usetikzlibrary{decorations.text}
\usepackage{textcomp}

\pgfplotsset{compat=1.12}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
domain=0:2,
xmin=0, xmax=2.25,
ymin=0, ymax=4.5,
samples=100,
axis y line=center,
axis x line=middle,
]
postaction={decorate,decoration={text along path,
text align={center}
}},
domain=0.5:1.5,] {2*0.7*(1+x)*(1-1/(1+x)^3)+0.5};
text align={center},
}},
domain=0.5:1.5] {2*0.7*(1+x)*(1-1/(1+x)^3)-0.5};
\end{axis}
\end{tikzpicture}
\end{document}


Note that we have to hide the \SI{0}{\degree} from tikz parser by using braces.

• Thx once again @Harish Kumar – raedma Oct 23 '15 at 8:33

Thanks a lot @jarauth the link helped me to find the trick. I must have somehow missed that during my tests with brackets.

This here works like a charm:

postaction={decorate,decoration={text along path,text={|\scriptsize| 0{\textdegree} Loading}}}