为什么 pgf-pie 会产生那么多“缺少字符:字体 nullfont 中没有 b!”错误?

为什么 pgf-pie 会产生那么多“缺少字符:字体 nullfont 中没有 b!”错误?

我正在尝试pgf-pie,甚至简单的例子似乎也有一些错误,因为我收到很多Missing character: There is no b in font nullfont!错误,如果我将所有错误一个接一个地放置,它们就会读取blue!60blue!60,cyan!60,yellow!60...,所以它一定是 pgf-pie 中的标准颜色定义的问题。

我正在使用Package: pgf-pie 2011/10/02 v0.2,这个问题在以后的版本中是否已经修复?

这是导致给定问题的 MWE:

\documentclass{standalone}
\usepackage{pgf-pie}

\begin{document}

\begin{tikzpicture}[every label/.style={black}, nodes={white}]
  \pie {10/A, 20/B, 30/C, 10/D, 10/E, 10/F, 10/G}
  \pie[pos={8,0}, square] {23/A, 27/B, 17/C, 13/D, 20/E}
  \pie[pos={2,-8}, cloud] {10/A, 20/B, 30/C, 20/D, 20/E}
\end{tikzpicture}
\end{document}

答案1

您可以尝试以下方法。但我没有仔细检查代码,所以也许 \thecolor 有我错过的功能

\documentclass{standalone}
\usepackage{pgf-pie}
\makeatletter
\renewcommand{\pgfpie@findColor}[1]
{
  \pgfmathparse{int(mod(#1,\value{pgfpie@colorLength}))}
  \let\ci\pgfmathresult
  \foreach \c [count=\j from 0] in \pgfpie@color {
    \ifnum \j=\ci
    \xdef\thecolor{\c}
    %\thecolor %removed 
    \breakforeach
    \fi
  }
}
\makeatother

\begin{document}

\begin{tikzpicture}[every label/.style={black}, nodes={white}]
  \pie {10/A, 20/B, 30/C, 10/D, 10/E, 10/F, 10/G}
  \pie[pos={8,0}, square] {23/A, 27/B, 17/C, 13/D, 20/E}
  \pie[pos={2,-8}, cloud] {10/A, 20/B, 30/C, 20/D, 20/E}
\end{tikzpicture}
\end{document}

答案2

etoolbox -https://tex.stackexchange.com/a/130985/197451

在此处输入图片描述

\documentclass{standalone}
\usepackage{pgf-pie,etoolbox}

\begin{document}

\begin{tikzpicture}[scale=0.9]
\pie[pos={0,0},
    /tikz/every pin/.style={align=center},
    every only number node/.style={text=white},
    text=pin,
    rotate=240,
    explode=0.2,
    color={blue!70,cyan!70,red!70,orange!50}
    ]{10/A, 20/B, 30/C, 10/D, 10/E, 10/F, 10/G}

\pie[pos={0,-9cm},square,
     /tikz/every pin/.style={align=center},
     every only number node/.style={text=white},
     text=pin,
     rotate=240,
     explode=0.2,
     color={blue!70,cyan!70,red!70,orange!50}
     ]{23/A, 27/B, 17/C, 13/D, 20/E}

\pie[pos={0,-15cm},cloud,
     /tikz/every pin/.style={align=center},
     every only number node/.style={text=white},
     text=pin,
     rotate=240,
     explode=0.2,
     color={blue!70,cyan!70,red!70,orange!50}
     ]{10/A, 20/B, 30/C, 20/D, 20/E}

\end{tikzpicture}
\end{document}

相关内容