Trying to represent rational numbers using pie charts in a document as this one:
\documentclass{article}
\usepackage{tikz}
\usepackage{pgf-pie}
\begin{document}
\begin{tabular}{|p{4cm}|p{4cm}|p{4cm}|}
$\frac{1}{2}$ & $\frac{2}{2}$ \\
% 1/2
\begin{tikzpicture}
\pie[rotate=90, radius=2, sum=auto, color={white,blue}, /tikz/nodes={opacity=0,overlay}] {1 , 1 }
\end{tikzpicture}
&
% 2/2
\begin{tikzpicture}
\pie[rotate=90, radius=2, sum=auto, color={blue,blue}, /tikz/nodes={opacity=0,overlay}] {1 , 1 }
\end{tikzpicture}
\\
$\frac{1}{3}$ & $\frac{2}{3}$ & $\frac{3}{3}$ \\
% 1/3
\begin{tikzpicture}
\pie[rotate=90, radius=2, sum=auto, color={white,white,blue}, /tikz/nodes={opacity=0,overlay}] {1 , 1, 1 }
\end{tikzpicture}
&
% 2/3
\begin{tikzpicture}
\pie[rotate=90, radius=2, sum=auto, color={white,blue,blue}, /tikz/nodes={opacity=0,overlay}] {1 , 1, 1 }
\end{tikzpicture}
&
% 3/3
\begin{tikzpicture}
\pie[rotate=90, radius=2, sum=auto, color={blue,blue,blue}, /tikz/nodes={opacity=0,overlay}] {1 , 1, 1 }
\end{tikzpicture}
\end{tabular}
\end{document}
the document fulfills more or less what is expected. However, it can be improved with a newcommand that creates each pie chart. The new command should have two arguments, corresponding to the denominator and numerator. Something like:
\newcommand{\rationalpie}[2]{
\begin{tikzpicture}
\pie[rotate=90, radius=2, sum=auto, color={white,blue,blue}, /tikz/nodes={opacity=0,overlay}] {1 , 1, 1 }
\end{tikzpicture}
}
that could be used as:
\rationalpie{2}{3}
The problem is: how to define this newcommand ? The fixed list {1,1,1} must be replaced by so many "1" as the denominator argument and the list {white,blue,blue} must be replaced by some many elements as denominator with "blue" repeated numerator times.