I am using \mathtoolsset{centercolon} in a document, together with PGFPlots. I noticed that if I insert a colon in the \addlegendentry command, the document keeps compiling forever and never produces any output.
This also occurs when using the code from this answer, so, taking inspiration from that, I could fix it up using \ordinarycolon. However, it's not clear to me why this is happening within \addlegendsentry, and especially I was wondering if it's possible to fix it in a way that I do not need special treatment for legends in order to compile.
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{mathtools}
% Does not compile when this is on:
\mathtoolsset{centercolon}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot {-5*x^3 - x^2};
% Needs extra braces somehow, but does not compile
\addlegendentry{{$f(x) : A\to B$}}
% Took inspiration from https://tex.stackexchange.com/a/4218/26355,
% using \ordinarycolon this compiles:
% \addlegendentry{{$f(x) \ordinarycolon A\to B$}}
\end{axis}
\end{tikzpicture}
\end{document}
centercolonto get nicely aligned:=in the document where I took the MVE from. – Pietro Saccardi Sep 30 '21 at 15:51\coloneq, then there's no active colons – daleif Sep 30 '21 at 15:52