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,
]
\addplot+[mark=none,samples=150] {2*0.7*(1+x)*(1-1/(1+x)^3)};
\addplot[draw=none,
postaction={decorate,decoration={text along path,
text={|\scriptsize| Loading},raise=1ex,
text align={center}
}},
domain=0.5:1.5,] {2*0.7*(1+x)*(1-1/(1+x)^3)+0.5};
\addplot+[mark=none,black,domain=0.5:1.5,->,,samples=150] {2*0.7*(1+x)*(1-1/(1+x)^3)+0.5};
\addplot[draw=none,postaction={decorate,decoration={text along path,
text={|\scriptsize| Unloading},raise=-2ex,
text align={center},
}},
domain=0.5:1.5] {2*0.7*(1+x)*(1-1/(1+x)^3)-0.5};
\addplot+[<-,mark=none, black,domain=0.5:1.5,samples=150] {2*0.7*(1+x)*(1-1/(1+x)^3)-0.5};
\end{axis}
\end{tikzpicture}
\end{document}

\textdegree, but maybe the problem is similar. – jarauh Oct 22 '15 at 12:13