4

I'm displaying text along an arc in tikz and I want that text to contain the degree symbol (celcius). However, pdflatex seems to hang on my code.

I've reduced my problem to a MWE and it reproduces. I'm working in texstudio w/ texlive on Ubuntu Linux.

\documentclass{standalone}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\begin{document}

\begin{tikzpicture}

\path[  postaction={ decorate },
        decoration={
                    text along path,
                    text={|\small\color{black}|Temperature: 0 to 100 \textdegree C},
                    text align = {center},
                    raise = -8pt
                    }
    ]
    (-0.5 * 0.5in * 3.26, -0.866025404 * 0.5in * 3.26)
    arc(240:-60:0.5in * 3.26);

\end{tikzpicture}

\end{document}

Anybody knows what is wrong? How can I work around this problem?

binarez
  • 165
  • Duplicate: http://tex.stackexchange.com/questions/75256/how-to-insert-math-with-curly-brackets-into-tikz-decoration-text-along-path – erik Mar 11 '16 at 20:20

2 Answers2

5

From tikz manual for decorations.text library:

Each character in the text is typeset in a separate\hbox. This means that if you want fancy things like kerning or ligatures you will have to manually annotate the characters in the decoration text within a group.

You need to put your command within a group

\documentclass{standalone}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\usepackage{gensymb}

\begin{document}

\begin{tikzpicture}

\path[postaction={decorate},
        decoration={
                    text along path,
                    text={|\small\color{black}|Temperature: 0 to 100 {\textdegree}  C},
                    text align = {center},
                    raise = -8pt
                    }
    ]
    (-0.5 * 0.5in * 3.26, -0.866025404 * 0.5in * 3.26)
    arc(240:-60:0.5in * 3.26);

\end{tikzpicture}

\end{document} 

enter image description here

Salim Bou
  • 17,021
  • 2
  • 31
  • 76
3

Special content like \textdegree should be placed in a {...} pair. I rather suggest to use \SI{0}{\degree} etc. instead of \textdegree C, however.

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\begin{document}
\begin{tikzpicture}

\path[  postaction={ decorate },
        decoration={
                    text along path,
                    text={|\small\color{black}|Temperature:  {\SI{0}{\degree}} to {\SI{100}{\degree}}},
                    text align = {center},
                    raise = -8pt
                    }
    ]
    (-0.5 * 0.5in * 3.26, -0.866025404 * 0.5in * 3.26)
    arc(240:-60:0.5in * 3.26);

\end{tikzpicture}

\end{document}

enter image description here