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?

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

2

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

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.