# PGF Plots Ternary Diagram - Undefined control sequence

I am going through the PGFPLOTS manual and copied the first code example from Section 5.13 Ternary Diagrams which I have placed into a document on overleaf.com. The code is as follows:

\documentclass{article}
\usepackage[utf8]{inputenc}

% PGF Plots
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usepgfplotslibrary{ternary}

\begin{document}

\centering
\begin{tikzpicture}
\begin{ternaryaxis}
(0.81, 0.19, 0.00)
(0.76, 0.17, 0.07)
(0.66, 0.16, 0.16)
(0.76, 0.07, 0.17)
(0.81, 0.00, 0.19)
};
(0.85, 0.15, 0.00)
(0.82, 0.13, 0.05)
(0.73, 0.14, 0.13)
(0.82, 0.06, 0.13)
(0.84, 0.00, 0.16)
};
\legend{$10$\textdegree, $20$\textdegree}
\end{ternaryaxis}
\end{tikzpicture}
\end{document}


I get two errors, which do not stop compilation of the document but are flagged up as Undefined control sequence at \end{ternaryaxis}. The logs output is as follows for each error:

\pgfplots@already@computed@legend@node ...tdegree
};\\\pgfplots@show@small@l...
l.29 \end{ternaryaxis}


It is a manageable issue at this point but I'd like to know a solution if possible before I get too far into my dissertation and it potentially becomes a problem.

Thanks

• Welcome to TeX.SE! Adding \usepackage{textcomp} to the preamble solves your issue.
– user121799
Feb 12, 2019 at 16:00
• Thank you that has worked perfectly. Why is \usepackage{textcomp} required? Feb 12, 2019 at 16:06
• Because it defines \textdegree. (Yes, it might be better if the manual mentioned that.)
– user121799
Feb 12, 2019 at 16:08
• Thank you marmot, I'd like to accept your answer but can't see how to do so. Feb 12, 2019 at 16:11
• Because it is a comment. ;-) You could try to persuade Sebastiano to rewrite his answer and then accept his.
– user121799
Feb 12, 2019 at 16:12

Your code with the replace ^{\circ} instead of \textdegree which required a further package as mentioned, correctly, in the @marmot's comments. This is another option adding \usepackage{amsmath,amssymb} to define \circ symbol of degree.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}

% PGF Plots
\usepackage{pgfplots}
\usepgfplotslibrary{ternary}

\begin{document}

\centering
\begin{tikzpicture}
\begin{ternaryaxis}
(0.81, 0.19, 0.00)
(0.76, 0.17, 0.07)
(0.66, 0.16, 0.16)
(0.76, 0.07, 0.17)
(0.81, 0.00, 0.19)
};
\legend{$10^{\circ}$, $20^{\circ}$}