[Tex/LaTex] Problem generating pie chart with pgf-pie package

pgf-pietikz-pgf

I am having troubles with TexStudio making pie charts with the pgf-pie package. I literally copied a fragment of this template: https://es.overleaf.com/latex/examples/drawing-pie-charts-with-pgf-pie/bjghbcfkrdvn

\documentclass{article}
\usepackage{pgf-pie}
\begin{document}
\begin{tikzpicture}
\pie{10/A, 20/B, 30/C, 40/D}
\end{tikzpicture}
\end{document}

enter image description here

The log only shows the following message:
Overfull \hbox (1033.10823pt too wide) in paragraph

As you can see the result is not the expected one, first because it does not show any pie chard, and secondo of all it should be something like this (done through Overleaf):
**enter image description here**

Does anybody knows how to fix this error?

Thank you for reading and for your Help.

David.

Best Answer

The problem seems to come from the \def\color inside the definition of \setcolor, though I can't give any details of what happens.

Anyways, replacing \color with something else, like \pgfpie@color in pgf-pie.sty appears to fix the problem. There are three occurrences, on lines 68, 133, and 235.

I made a pull request on GitHub implementing that, but I don't know if the author is still active, so cannot say whether a fix will make its way to CTAN.

If you don't want to edit the package file, you can do this:

\documentclass{article}
\usepackage{pgf-pie}
\usepackage{xpatch}
\makeatletter
\def\setcolor#1\pgfeov{\def\pgfpie@color{#1}}
\pgfkeyslet{/color/.@cmd}{\setcolor}
\xpatchcmd{\pgfpie@findColor}{\color}{\pgfpie@color}{}{}
\xpatchcmd{\pie}{\color}{\pgfpie@color}{}{}
\makeatother
\begin{document}
\begin{tikzpicture}
\pie{10/A, 20/B, 30/C, 40/D}
\end{tikzpicture}
\end{document}
Related Question