我正在尝试使用以下图表绘制图表:
\documentclass[aspectratio=169,10pt]{beamer}
\usepackage{tikz}
\usepackage{pgf-pie} % Pie chart library
\begin{frame}{Work}
\begin{figure}[H]
\centering
\scalebox{0.8}{
\begin{tikzpicture}
\pie[
color = {
yellow!90!black,
green!60!black,
blue!60,
red!70,
gray!70,
teal!20},
text = legend % Add a legend
] % Values:
{
20/Report Writing + Documentation,
10/Reaction Wheel design,
30/Components testing,
40/HiL control algorithm testing and optimization
}
\end{tikzpicture}
}
\captionsetup{justification=centering}
\caption{Work organisation. Source: Own.}
\label{fig:work_pie_chart}
\end{figure}
\end{frame}
\end{document}
但是我无法渲染 pdf,它说
Package pgfkeys: I do not know the key '/pgf/ color', to which you passed 'yellow!90!black, green!60!black, blue!60, red!70, gray!70, teal!20', and I am going to ignore it. Perhaps you misspelled it.
答案1
这个例子有效
\documentclass[aspectratio=169,10pt]{beamer}
\usepackage{tikz}
\usepackage{pgf-pie} % Pie chart library
\begin{document}
\begin{frame}
\frametitle{Work}
\begin{tikzpicture}
\pie[color={yellow!90!black,
green!60!black,
blue!60,
red!70,
gray!70,
teal!20},
text = legend % Add a legend
] % Values:
{
20/Report Writing + Documentation,
10/Reaction Wheel design,
30/Components testing,
40/HiL control algorithm testing and optimization
}
\end{tikzpicture}
\end{frame}
\end{document}
而这失败了:
\documentclass[aspectratio=169,10pt]{beamer}
\usepackage{tikz}
\usepackage{pgf-pie} % Pie chart library
\begin{document}
\begin{frame}
\frametitle{Work}
\begin{tikzpicture}
\pie[
color={yellow!90!black,
...
注意后面的换行符\pie[
仅仅删除换行符是不够的,还需要\pie[color...
对于那些尝试调试此问题的人来说,错误中有一个提示:
! Package pgfkeys Error: I do not know the key '/pgf/ color', to which you pass
ed 'yellow!90!black, green!60!black, blue!60, red!70, gray!70, teal!20', and I
am going to ignore it. Perhaps you misspelled it.
请注意,'/pgf/ color'
键通常不以空格开头或结尾。
我不知道为什么它没有被自动删除,也许其他人可以回答这个问题。
答案2
一般来说,输入类似以下内容是安全的
\begin{tikzpicture}[
option1 = a,
option2 = b,
]
<code>
\end{tikzpicture}
但显然这是不允许的,\pie
因为它不会占用结束行生成的空间,事实上,错误消息是关于键的
pgf/ color
未被定义。
你可以通过记住输入来解决这个问题
\pie[%
color={...},
text={...}
]
或者你可以向前迈一步:通知 Ti 的开发人员钾Z/PGF 关于不一致性,并暂时修复定义,以便它消耗可能的空间。
\documentclass[aspectratio=169,10pt]{beamer}
\usepackage{tikz}
\usepackage{pgf-pie} % Pie chart library
\usepackage{caption}
\makeatletter
\let\orig@pgfpie@@pie\pgfpie@@pie
\def\pgfpie@@pie[#1]#2{%
\if\relax\detokenize{#1}\relax
\orig@pgfpie@@pie[]{#2}%
\else
\expandafter\orig@pgfpie@@pie\expandafter[\@firstofone #1]{#2}%
\fi
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{Work}
\begin{figure}
\centering
\scalebox{0.8}{% <--- don't forget
\begin{tikzpicture}
\pie[
color = {
yellow!90!black,
green!60!black,
blue!60,
red!70,
gray!70,
teal!20
},
text = legend % Add a legend
] % Values:
{
20/Report Writing + Documentation,
10/Reaction Wheel design,
30/Components testing,
40/HiL control algorithm testing and optimization
}
\end{tikzpicture}% <--- don't forget
}
\captionsetup{justification=centering}
\caption{Work organisation. Source: Own.}
\label{fig:work_pie_chart}
\end{figure}
\end{frame}
\end{document}
在我看来,最好只缩放饼图而不缩放文本。
\documentclass[aspectratio=169,10pt]{beamer}
\usepackage{tikz}
\usepackage{pgf-pie} % Pie chart library
\usepackage{caption}
\makeatletter
\let\orig@pgfpie@@pie\pgfpie@@pie
\def\pgfpie@@pie[#1]#2{%
\if\relax\detokenize{#1}\relax
\orig@pgfpie@@pie[]{#2}%
\else
\expandafter\orig@pgfpie@@pie\expandafter[\@firstofone #1]{#2}%
\fi
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{Work}
\begin{figure}
\centering
\begin{tikzpicture}[scale=0.8]
\pie[
color = {
yellow!90!black,
green!60!black,
blue!60,
red!70,
gray!70,
teal!20
},
text = legend % Add a legend
] % Values:
{
20/Report Writing + Documentation,
10/Reaction Wheel design,
30/Components testing,
40/HiL control algorithm testing and optimization
}
\end{tikzpicture}
\captionsetup{justification=centering}
\caption{Work organisation. Source: Own.}
\label{fig:work_pie_chart}
\end{figure}
\end{frame}
\end{document}
请注意,说明[H]
符不执行任何操作(而且无论如何也几乎不应该使用)。并且拥有一个图形环境实际上没有什么用处:请注意未限定的“Figure:”部分,它对观众来说毫无用处。并且不会\label
引用任何合理的值。
\documentclass[aspectratio=169,10pt]{beamer}
\usepackage{tikz}
\usepackage{pgf-pie} % Pie chart library
\usepackage{caption}
\makeatletter
\let\orig@pgfpie@@pie\pgfpie@@pie
\def\pgfpie@@pie[#1]#2{%
\if\relax\detokenize{#1}\relax
\orig@pgfpie@@pie[]{#2}%
\else
\expandafter\orig@pgfpie@@pie\expandafter[\@firstofone #1]{#2}%
\fi
}
\makeatother
\begin{document}
\begin{frame}
\frametitle{Work}
\centering
\begin{tikzpicture}[scale=0.8]
\pie[
color = {
yellow!90!black,
green!60!black,
blue!60,
red!70,
gray!70,
teal!20
},
text = legend % Add a legend
] % Values:
{
20/Report Writing + Documentation,
10/Reaction Wheel design,
30/Components testing,
40/HiL control algorithm testing and optimization
}
\end{tikzpicture}
\bigskip
Work organisation. Source: Own.
\end{frame}
\end{document}