0

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}

  • If I'm not mistaken, centercolon make the : active which tikz/pgf properly doesn't like as : is used as a part of the tikz/pgf syntax. Not sure if loading the babel tikz library might help. Why do you use centercolon in the first place? – daleif Sep 30 '21 at 15:42
  • I noticed it had problem parsing the legend as well if I didn't add braces around it, but I am surprised it expands into the formula instead of transferring it to the legend node? I use centercolon to get nicely aligned := in the document where I took the MVE from. – Pietro Saccardi Sep 30 '21 at 15:51
  • 2
    You should be using \coloneq, then there's no active colons – daleif Sep 30 '21 at 15:52

0 Answers0