4

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.

Mensch
  • 65,388
  • Just to add: I have already updated all MiKTeX packages, and reinstalled TeXstudio 2.12.14. I also try to compile the example in another computer, and It worked, but in mine, it does not. I also tried this https://tex.stackexchange.com/questions/378649/how-to-make-disappear-some-weird-numbers-in-a-pie-chart-with-pgf-pie, but the weird text is still there. – David Cano Jan 10 '19 at 02:32
  • 1
    it seems that pgf-pie is broken or not compatible anymore with recent tikz. – Zarko Jan 10 '19 at 03:10
  • (not only reinstalled TeXstudio but also MiKTeX, gsview and ghostscript). – David Cano Jan 10 '19 at 03:42
  • Zarko, the think is that the other computer where I tried the code, has the very same version of all (MiKTeK, GSview, Ghostscript and TeXStudio -including its profile-) and it gives still the same pdf file with the weird text. – David Cano Jan 10 '19 at 04:04
  • I get the same, wrong output on my updated TeXLive 2018 distribution on MacOS with the last version of TikZ installed. (AFAIK pgf-pie is not an official package, but I might be wrong.) –  Jan 10 '19 at 04:15
  • i get the same result, however in December (before tikz 3.1) it works normally (this is easy to check here on site), so i guess that the pgf-pie not work well with recent tikz. someone should write to package author. – Zarko Jan 10 '19 at 04:24
  • Agreed, I too have issues after just updating everything. Most likely, Overleaf will encounter similar issues whenever they update tikz. Things are actually being drawn, but the labels are messed up (and push the draws off the page). For some reason, the list of colors is supposed to be looped and identify the fill color for each wedge. If you replace color={...} with color={} within \pgfkeys (in the package file), you will see everything drawn with labels, minus the correct fill color. I'm not immediately sure how difficult a fix is, however. – whatisit Jan 10 '19 at 04:32
  • Just one more piece of information; your chart gets drawn. It just gets moved so far to the right that it is beyond the boundaries of the page. If you use the standalone class, you can see the chart. However, you see also the extra text, parts of which you see here. (I have tried to answer a few questions where this style was used. Personally I'd like to recommend to switch to other ways. You can find so many nice examples of pie charts on this site, most of which have much cleaner coding.) –  Jan 10 '19 at 05:15
  • A general comment: A key power of La(Tex) is the philosophy of longstanding always-backwards compatibility except under exceptional circumstances, Indeed code is written to avoid compatibility problems in bug correction. The same should apply to packages. It matters not that pgf-pie is not an "official" package. Why is it a good idea that we simply accept (in 2018) that changes to packages breaks code that previously compiled, unless the reasons are compelling. The principle excludes defective code (not just badly written) that happened to compile, but I don't think that applies here. – Aubrey Blumsohn Jan 10 '19 at 09:51
  • Hey guys, thank you for your help. You were right about the compatibility problem. I have found a solution that might not work for everyone. As I told you, I run that code in another computer and it worked there. What I did is to copy all the MiKTeK folders located in C:\ProgramData, %user%\AppData\Roaming, %user%\AppData\Local to my computer. Everything is fine now. It might not be the best solution because that would mean that some packages are not going to be updated... but still. While this problem is not solved, I guess that it is better to find another way to make those charts. Regards! – David Cano Jan 10 '19 at 13:10
  • I add a bug report: https://github.com/xuyuan/pgf-pie/issues/13 – quark67 Jan 10 '19 at 13:56
  • 1
    @AubreyBlumsohn Well, I'm not sure redefining \color, locally or not, is good practice ... Do a find&replace in pgf-pie.sty, replacing \color with e.g. \pie@color, and it works fine. I'll add a comment on the GitHub issue as well. – Torbjørn T. Jan 10 '19 at 17:22

2 Answers2

3

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}
Torbjørn T.
  • 206,688
2

I am using TexStudio and had the exact same problem, too. It didn't find the package pgf-pie. My idea, after finding your post, was to install the package manually. It worked for me and now I can use the package!

On the website below there is a description how to do it. I followed the exact steps (I have Linux) and it worked like a charm!

Manual installation of the package pgf-pie