Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have 21 pie charts (generated using pgf-pie) that I wanted to display in rows of 3. The "table" spans multiple pages (which has made it difficult to use the figure or tabular environments).

I have been able to achieve a similar result to that which I desire, with the following problems:

  • The pie charts do not line up across rows
  • I do not wish for each row to have its own caption (and when I remove the \caption command, I get this error: Package caption Error: Continuedfigure' after ??'.
  • I do not wish for the vertical spacing to vary across pages.

Current formatting

Here is a minimum working example demonstrating the code that I have used to produce the above result. I apologise for the length of the example... it was necessary to include the pgf-pie style file, as well as some plots to be placed in the document.

\documentclass[a4paper]{report}

\usepackage{filecontents}
\usepackage{tikz}
\usepackage{xparse}

\begin{filecontents}{pgf-pie.sty}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Some LaTeX macros for pie chart by using PGF/Tikz package.
% Home page of project: http://pgf-pie.googlecode.com/
% Author: Xu Yuan <xuyuan.cn@gmail.com>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{pgf-pie}[2011/10/02 v0.2 Some LaTeX macros for pie
chart by using PGF/Tikz package.]

\RequirePackage{tikz}
\RequirePackage{ifthen}
\RequirePackage{scalefnt}

% args:
% #1: begin angle
% #2: end angle
% #3: number
% #4: label
% #5: explode
% #6: fill color
% #7: radius
% #8: center
\newcommand{\pgfpie@slice}[8]{%
    \pgfmathparse{0.5*(#1)+0.5*(#2)}%
    \let\midangle\pgfmathresult
    %
    \path (#8) -- ++(\midangle:#5) coordinate(O);%
    %
    \pgfmathparse{#7+#5}%
    \let\radius\pgfmathresult
    %
    % slice
    \draw[line join=round, fill=#6, \style] (O) -- ++(#1:#7) arc (#1:#2:#7) -- cycle;%
    %
    \pgfmathparse{min(((#2)-(#1)-10)/110*(-0.3),0)}%
    \let\temp\pgfmathresult%
    \pgfmathparse{(max(\temp,-0.5) + 0.8)*#7}%
    \let\innerpos\pgfmathresult
    %
    \ifthenelse{\equal{\pgfpie@text}{inside}}{%
        % label and number together
        \path (O) -- ++(\midangle:\innerpos) node%
        {\scalefont{#3}\shortstack{#4\\\beforenumber#3\afternumber}};%
    }{%
        % label
        \iflegend
        \else
            \path (O) -- ++ (\midangle:\radius)%
            node[inner sep=0, \pgfpie@text=\midangle:#4]{};%
        \fi
        %
        % number
        \path (O) -- ++(\midangle:\innerpos) node%
        {\scalefont{#3}\beforenumber#3\afternumber};%
    }%
}

\newcommand{\pgfpie@findColor}[1]{%
    \pgfmathparse{int(mod(#1,\value{pgfpie@colorLength}))}%
    \let\ci\pgfmathresult
    \foreach \c [count=\j from 0] in \color {%
        \ifnum \j=\ci
            \xdef\thecolor{\c}%
            \thecolor
            \breakforeach
        \fi
    }%
}

\newcommand{\pgfpie@findExplode}[1]{%
    \pgfmathparse{int(mod(#1,\value{pgfpie@explodeLength}))}%
    \let\ei\pgfmathresult
    \foreach \e [count=\j from 0] in \explode {%
        \ifnum \j=\ei
            \xdef\theexplode{\e}%
            \breakforeach
        \fi
    }%
}

% #1: bottom left point
% #2: size
% #3: number
% #4: color
% #5: text
\newcommand{\pgfpie@square}[5]{%
    \ifthenelse{\equal{\pgfpie@text}{inside}}{%
        \draw[fill=#4, \style] (#1) rectangle node%
        {\scalefont{#3}\shortstack{#5\\\beforenumber#3\afternumber}} ++(#2);%
    }{%
        \draw[fill=#4, \style] (#1) rectangle node%
        {\scalefont{#3}\beforenumber#3\afternumber} ++(#2);%
    }%
}

% #1: pos
% #2: radius
% #3: number
% #4: color
% $5: style
% $6: label
\newcommand{\pgfpie@cloud}[6]{%
    \draw[fill=#4, #5] (#1) circle[radius=#2];%
    \ifthenelse{\equal{\pgfpie@text}{inside}}{%
        \node at (#1) {\scalefont{#3}\shortstack{#6\\\beforenumber#3\afternumber}};%
    }{%
        \node at (#1) {\scalefont{#3}\beforenumber#3\afternumber};%
    }%
}

\newlength{\pgfpie@angleEnd}
\newcounter{pgfpie@explodeLength}
\newcounter{pgfpie@colorLength}
\newcounter{pgfpie@sliceLength}

\def\setexplode#1\pgfeov{\def\explode{#1}}
\pgfkeyslet{/explode/.@cmd}{\setexplode}

\def\setcolor#1\pgfeov{\def\color{#1}}
\pgfkeyslet{/color/.@cmd}{\setcolor}

\def\setradius#1\pgfeov{\def\radius{#1}}
\pgfkeyslet{/radius/.@cmd}{\setradius}

\def\setpos#1\pgfeov{\def\pos{#1}}
\pgfkeyslet{/pos/.@cmd}{\setpos}

\def\setstyle#1\pgfeov{\def\style{#1}}
\pgfkeyslet{/style/.@cmd}{\setstyle}

\def\setbeforenumber#1\pgfeov{\def\beforenumber{#1}}
\pgfkeyslet{/before number/.@cmd}{\setbeforenumber}

\def\setafternumber#1\pgfeov{\def\afternumber{#1}}
\pgfkeyslet{/after number/.@cmd}{\setafternumber}

\def\settext#1\pgfeov{\xdef\pgfpie@text{#1}}
\pgfkeyslet{/text/.@cmd}{\settext}

\def\setsum#1\pgfeov{\xdef\pgfpie@sum{#1}}
\pgfkeyslet{/sum/.@cmd}{\setsum}

\def\setrotate#1\pgfeov{\xdef\rotate{#1}}
\pgfkeyslet{/rotate/.@cmd}{\setrotate}

\newif\ifpolar
\pgfkeys{/polar/.is if=polar}

\newif\iflegend
\newif\ifnolegend
\newif\iflegendonly

\newif\ifsquare
\pgfkeys{/square/.is if=square}

\newif\ifcloud
\pgfkeys{/cloud/.is if=cloud}

\newif\ifscalefont
\pgfkeys{/scale font/.is if=scalefont}
\let\scalefontorg\scalefont
\renewcommand{\scalefont}[1]{%
    \ifscalefont
        \pgfmathparse{#1 / \pgfpie@sum * 3 + 0.9}%
        \scalefontorg{\pgfmathresult}%
    \fi
}

\newcommand{\pie}[2][]{%
    % load default parameters
    \pgfkeys{%
        explode=0,%
        color={blue!60, cyan!60, yellow!60, orange!60, red!60,%
               blue!60!cyan!60, cyan!60!yellow!60, red!60!cyan!60,%
               red!60!blue!60, orange!60!cyan!60},%
        radius=3,%
        pos={0,0},%
        style={thick},%
        before number=,%
        after number=,%
        text=label,%
        sum=100,%
        rotate=0,%
        polar=false,%
        square=false,%
        cloud=false,%
        scale font=false,%
    }%
    %
    % load user's parameters
    \pgfkeys{#1}%
    % add percentage automatically
    \ifthenelse{\equal{\pgfpie@sum}{100}}{%
        \pgfkeys{after number=\%}%
        \pgfkeys{#1}%
    }{}%
    %
    % legend or not
    \ifthenelse{\equal{\pgfpie@text}{legend}}%
    {\legendtrue}%
    {\legendfalse}%
    %
    % nolegend or not
    \ifthenelse{\equal{\pgfpie@text}{nolegend}}%
    {\nolegendtrue \legendtrue}%
    {\nolegendfalse}%
    %
    % legendonly or not
    \ifthenelse{\equal{\pgfpie@text}{legendonly}}%
    {\legendonlytrue \legendtrue}%
    {\legendonlyfalse}%
    %
    % handle sum
    \ifthenelse{\equal{\pgfpie@sum}{auto}}{%
        % sum all input
        \xdef\pgfpie@sum{0}%
        \foreach \p/\t in {#2}{%
            \pgfmathparse{\pgfpie@sum + \p}%
            \xdef\pgfpie@sum{\pgfmathresult}%
        }%
    }%
    {}%
    %
    % init counters
    \setcounter{pgfpie@explodeLength}{0}%
    \foreach \e in \explode { \addtocounter{pgfpie@explodeLength}{1} }%
    %
    \setcounter{pgfpie@colorLength}{0}%
    \foreach \c in \color { \addtocounter{pgfpie@colorLength}{1} }%
    %
    \pgfmathsetlength{\pgfpie@angleEnd}{0}%
    %
    \setcounter{pgfpie@sliceLength}{0}%
    \foreach \p/\e in {#2} { \addtocounter{pgfpie@sliceLength}{1} }%
    %
    \iflegendonly
    \else
        \ifsquare
        %%%%%%%%%% SQUARE PIE BEGIN %%%%%%%%%%%
            \pgfmathparse{\radius*2}%
            \xdef\verticalLength{\pgfmathresult}%
            \xdef\horizontalLength{\pgfmathresult}%
            \path (\pos) -- ++(-\radius, -\radius) coordinate (start);%
            \pgfmathparse{\verticalLength * \horizontalLength / \pgfpie@sum}%
            \let\squareUnit\pgfmathresult
            %
            % drawing loop
            \foreach \p/\t [count=\i from 0] in {#2}{%
                \pgfpie@findColor{\i}
                %
                \ifthenelse{\lengthtest{\verticalLength cm > \horizontalLength cm}}{%
                    \pgfmathparse{\p * \squareUnit / \horizontalLength}%
                    \let\height\pgfmathresult
                    %
                    \pgfpie@square{start}{\horizontalLength,\height}%
                    {\p}%
                    {\thecolor}%
                    {\t}%
                    %
                    %label
                    \iflegend
                    \else
                        \ifthenelse{\equal{\pgfpie@text}{inside}}{}{%
                            \path (start) -- ++(\horizontalLength,\height*0.5) node[inner sep=0, \pgfpie@text=0:\t]{};%
                        }%
                    \fi
                    %
                    \pgfmathparse{\verticalLength - \height}%
                    \xdef\verticalLength{\pgfmathresult}%
                    \path (start) -- ++(0, \height) coordinate (start);%
                }{%
                    \pgfmathparse{\p * \squareUnit / \verticalLength }%
                    \let\width\pgfmathresult

                    \pgfpie@square{start}{\width,\verticalLength}%
                    {\p}%
                    {\thecolor}%
                    {\t}%
                    %
                    %label
                    \iflegend
                    \else
                        \ifthenelse{\equal{\pgfpie@text}{inside}}{}{%
                            \path (start) -- ++(\width*0.5,\verticalLength) node[inner sep=0, \pgfpie@text=90:\t]{};%
                        }%
                    \fi
                    %
                    \pgfmathparse{\horizontalLength - \width}%
                    \xdef\horizontalLength{\pgfmathresult}%
                    \path (start) -- ++(\width, 0) coordinate (start);%
                }%
            }%
        %%%%%%%%%% SQUARE PIE END %%%%%%%%%%%
        \else
        \ifcloud
        %%%%%%%%%% CLOUD PIE BEGIN %%%%%%%%%%%
            % drawing loop
            \foreach \p/\t [count=\i from 0] in {#2}{%
                % find explode
                \pgfpie@findExplode{\i}%
                \def\cloudGap{\theexplode + 0.1}%
                \pgfmathparse{sqrt(\p / \pgfpie@sum) * \radius}%
                \let\cloudR\pgfmathresult
                \ifnum \i = 0
                    % first cloud
                    \coordinate (O) at (\pos);%
                    \xdef\cloudRone{\cloudR}%
                    \xdef\cloudExtendDir{180+\rotate}%
                \else
                \ifnum \i = 1
                    % second cloud
                    \xdef\cloudRtwo{\cloudR}%
                    \xdef\cloudExtendDir{45+\rotate}%
                    \path (O) -- ++(\cloudExtendDir:\cloudRone+\cloudGap+\cloudRtwo) coordinate (O);%
                \else
                    % next cloud
                    \pgfmathparse{\cloudRone+\cloudGap+\cloudRtwo}%
                    \let\la\pgfmathresult
                    \pgfmathparse{\cloudRone+\cloudGap+\cloudR}%
                    \let\lb\pgfmathresult
                    \pgfmathparse{\cloudRtwo+\cloudGap+\cloudR}%
                    \let\lc\pgfmathresult
                    \pgfmathparse{\la^2+\lc^2-\lb^2}%
                    \let\tmp\pgfmathresult
                    \pgfmathparse{180 - acos(\tmp / 2 / \la / \lc)}%
                    \let\cloudRot\pgfmathresult
                    \ifodd \i
                        \pgfmathparse{-\cloudRot}%
                        \let\cloudRot\pgfmathresult
                    \fi
                    \pgfmathparse{\cloudExtendDir - \cloudRot}
                    \xdef\cloudExtendDir{\pgfmathresult}
                    \path (O) -- ++(\cloudExtendDir:\lc) coordinate (O);
                    \xdef\cloudRone{\cloudRtwo}
                    \xdef\cloudRtwo{\cloudR}
                \fi
                \fi
                %
                % find color
                \pgfpie@findColor{\i}%

                \pgfpie@cloud{O}{\cloudR}{\p}%
                {\thecolor}{\style}{\t}%

                % label
                \iflegend
                \else
                    \ifthenelse{\equal{\pgfpie@text}{inside}}{}{%
                        \path (O) -- ++(\cloudExtendDir:\cloudR)%
                        node[inner sep=0, \pgfpie@text=\cloudExtendDir:\t] {};%
                    }%
                \fi
            }
        %%%%%%%%%% CLOUD PIE END %%%%%%%%%%%
        \else
        %%%%%%%%%% CIRCLE PIE BEGIN %%%%%%%%%%%
            \ifpolar
                \xdef\maxValue{0}%
                \foreach \p/\e in {#2} {%
                    \ifnum \maxValue < \p
                        \xdef\maxValue{\p}%
                    \fi
                }%
                \pgfmathparse{\pgfpie@sum / \value{pgfpie@sliceLength}}%
                \xdef\polarangle{\pgfmathresult}%
                \pgfmathparse{\radius / sqrt(\maxValue)}%
                \xdef\polarRadiusUnit{\pgfmathresult}%
            \else
                \xdef\theradius{\radius}%
            \fi

            \xdef\pgfpie@angleBegin{\the\pgfpie@angleEnd}%
            % drawing loop
            \foreach \p/\t [count=\i from 0] in {#2}{%
                \pgfmathsetlength{\pgfpie@angleEnd}{\pgfpie@angleBegin}%
                \ifpolar
                    % Polar area diagram
                    \pgfmathaddtolength{\pgfpie@angleEnd}{\polarangle}%
                    \pgfmathparse{sqrt(\p) * \polarRadiusUnit}%
                    \xdef\theradius{\pgfmathresult}%
                \else
                    % normal pie
                    \pgfmathaddtolength{\pgfpie@angleEnd}{\p}%
                \fi
                %
                % find explode
                \pgfpie@findExplode{\i}%

                % find color
                \pgfpie@findColor{\i}%
                \pgfpie@slice{\pgfpie@angleBegin/\pgfpie@sum*360+\rotate}%
                {\the\pgfpie@angleEnd/\pgfpie@sum*360+\rotate}%
                {\p}%
                {\t}%
                {\theexplode}%
                {\thecolor}%
                {\theradius}%
                {\pos}%
                \xdef\pgfpie@angleBegin{\the\pgfpie@angleEnd}%
            }%
        %%%%%%%%%% CIRCLE PIE END %%%%%%%%%%%
        \fi
        \fi
    \fi
    %
    % legend
    \iflegend
        \ifnolegend
        \else
            \coordinate[xshift=0.8cm,yshift=(\value{pgfpie@sliceLength}*0.5+1)*0.5cm] (legendpos) at (current bounding box.east);%

            \begin{scope}[node distance=0.5cm]%
                \foreach \p/\t  [count=\i from 0] in {#2}{%
                    \pgfpie@findColor{\i}%
                    \node[draw, fill=\thecolor, \style, below of=legendpos, label=0:\t] (legendpos) {};%
                }%
            \end{scope}%
        \fi
    \fi
}
\end{filecontents}

\begin{filecontents}{pieplots.sty}
\usepackage{pgf-pie}
\usepackage{caption}
\usepackage{subfig}
\makeatletter
\newcounter{@sfcol}%
\newcounter{@sffig}%
\NewDocumentEnvironment{pieplots}{mm}{%
    \setcounter{@sfcol}{0}%
    \setcounter{@sffig}{0}%
    \setcounter{subfigure}{0}%
    %
    \def\@sfprefix{\hspace{\fill}}%
    \def\@sfsuffix{}%
    %
    \newcommand\pieplot[2]{%
        \@sfprefix%
        \subfloat[##1]{##2}%
        \@sfsuffix%
        %
        \def\@sfsuffix{}%
        \stepcounter{@sfcol}%
        \ifnum\value{@sfcol}=2%
            \def\@sfsuffix{\hspace*{\fill}}%
        \fi%
        \ifnum\value{@sfcol}=3%
            \setcounter{@sfcol}{0}%
            \stepcounter{@sffig}%
            \def\@sfprefix{%
                \caption{}%
                \label{#1:subfig\arabic{@sffig}}%
                \endfigure%
                \figure[H]%
                    \ContinuedFloat%
                    \hspace{\fill}%
            }%
        \fi%
    }%
    %
    \figure[H]%
}{%
        \caption{#2}%
        \label{#1}%
    \endfigure%
}
\makeatother
\end{filecontents}
\usepackage{pieplots}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The plots
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{filecontents}{ball1.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={cyan!60,yellow!60,orange!60,blue!60,red!60,blue!60!cyan!60,white!60}]{
            3.61/{pcg},
            3.23/{hggetbehavior},
            5.38/{isprop},
            56.96/{TopN\_Outlier\_Pruning\_Block},
            3.34/{localPeek},
            3.30/{drawGraph},
            24.19/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{connect4.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,cyan!60!yellow!60,white!60,orange!60!cyan!60}]{
            85.22/{TopN\_Outlier\_Pruning\_Block},
            7.77/{knn\_components\_sparse},
            3.28/{Other},
            3.73/{kdtree\_k\_nearest\_neighbors ()}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{letter-recognition.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,cyan!60!yellow!60,white!60}]{
            84.26/{TopN\_Outlier\_Pruning\_Block},
            7.00/{knn\_components\_sparse},
            8.74/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{magicgamma.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,cyan!60!yellow!60,white!60}]{
            85.12/{TopN\_Outlier\_Pruning\_Block},
            8.47/{knn\_components\_sparse},
            6.41/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{mesh_network.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60,purple!60,orange!60!cyan!60}]{
            68.01/{TopN\_Outlier\_Pruning\_Block},
            23.76/{Other},
            3.09/{princomp},
            5.15/{kdtree\_k\_nearest\_neighbors ()}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{musk.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,cyan!60!yellow!60,white!60,orange!60!cyan!60}]{
            82.39/{TopN\_Outlier\_Pruning\_Block},
            3.13/{knn\_components\_sparse},
            9.48/{Other},
            5.00/{kdtree\_k\_nearest\_neighbors ()}        
        }
    \end{tikzpicture}
    \end{filecontents}
\begin{filecontents}{pendigits.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,cyan!60!yellow!60,white!60}]{
            84.51/{TopN\_Outlier\_Pruning\_Block},
            6.01/{knn\_components\_sparse},
            9.48/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex1k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={orange!60,blue!60,white!60}]{
            3.57/{isprop},
            71.80/{TopN\_Outlier\_Pruning\_Block},
            24.62/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex10k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            94.57/{TopN\_Outlier\_Pruning\_Block},
            5.43/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex20k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            96.44/{TopN\_Outlier\_Pruning\_Block},
            3.56/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex30k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            97.01/{TopN\_Outlier\_Pruning\_Block},
            2.99/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex40k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            96.98/{TopN\_Outlier\_Pruning\_Block},
            3.02/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex50k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            96.88/{TopN\_Outlier\_Pruning\_Block},
            3.12/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{segmentation.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,red!60!cyan!60,white!60}]{
            70.72/{TopN\_Outlier\_Pruning\_Block},
            3.30/{prepare},
            25.98/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{spam.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={cyan!60,blue!60,cyan!60!yellow!60,white!60}]{
            3.96/{pcg},
            73.03/{TopN\_Outlier\_Pruning\_Block},
            4.56/{knn\_components\_sparse},
            18.46/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{spam_train.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={cyan!60,blue!60,cyan!60!yellow!60,white!60}]{
            4.71/{pcg},
            74.51/{TopN\_Outlier\_Pruning\_Block},
            4.14/{knn\_components\_sparse},
            16.64/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{testCD.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={magenta!60,orange!60,blue!60,white!60}]{
            3.09/{newplot},
            4.32/{isprop},
            62.28/{TopN\_Outlier\_Pruning\_Block},
            30.31/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{testCDST.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            79.76/{TopN\_Outlier\_Pruning\_Block},
            20.24/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{testCDST2.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            81.67/{TopN\_Outlier\_Pruning\_Block},
            18.33/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{testCDST3.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            81.67/{TopN\_Outlier\_Pruning\_Block},
            18.33/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{testoutrank.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={cyan!60,orange!60!cyan!60,orange!60,blue!60,green!60,magenta!60,white!60}]{
            19.31/{pcg},
            3.31/{@(b)mx\_d\_preconditioner(sH,b)},
            4.38/{isprop},
            31.94/{TopN\_Outlier\_Pruning\_Block},
            10.89/{iterapp},
            4.15/{mx\_d\_preconditioner ()},
            26.02/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{pieplots}{profiling:matlab}{Matlab profiling plots}
    \pieplot{testCDST}{\input{testCDST}}
    \pieplot{spam}{\input{spam}}
    \pieplot{testCD}{\input{testCD}}
    \pieplot{runningex30k}{\input{runningex30k}}
    \pieplot{testCDST2}{\input{testCDST2}}
    \pieplot{segmentation}{\input{segmentation}}
    \pieplot{magicgamma}{\input{magicgamma}}
    \pieplot{ball1}{\input{ball1}}
    \pieplot{pendigits}{\input{pendigits}}
    \pieplot{runningex20k}{\input{runningex20k}}
    \pieplot{musk}{\input{musk}}
    \pieplot{runningex10k}{\input{runningex10k}}
    \pieplot{runningex40k}{\input{runningex40k}}
    \pieplot{spam\_train}{\input{spam_train}}
    \pieplot{testoutrank}{\input{testoutrank}}
    \pieplot{testCDST3}{\input{testCDST3}}
    \pieplot{runningex1k}{\input{runningex1k}}
    \pieplot{mesh\_network}{\input{mesh_network}}
    \pieplot{letter-recognition}{\input{letter-recognition}}
    \pieplot{connect4}{\input{connect4}}
    \pieplot{runningex50k}{\input{runningex50k}}
\end{pieplots}

\end{document}
share|improve this question
add comment

2 Answers

Just a proof of concept.

\documentclass{article}
\usepackage{caption,kantlipsum}

% A command for producing empty ruled boxes
\newcommand\pieplot[2]{%
  \mbox{%
    \fboxsep=-\fboxrule
    \fbox{\rule{0pt}{3cm}\rule{.3\textwidth}{0pt}}%
  }%
  \hfil\ignorespaces}

\newenvironment{pieplots}[2]
 {\global\pieplotsstarttrue
  \def\pieplotslabel{#1}\def\pieplotscaption{#2}
  \setbox\pieplotsbox=\vbox\bgroup\parindent=0pt \offinterlineskip \parfillskip=0pt }
 {\par\egroup\splitpieplots}

\newcommand{\splitpieplots}{%
  \ifvoid\pieplotsbox\else
    \vbadness10000
    \setbox\pieplotspartialbox=\vsplit\pieplotsbox to .9\textheight
    \begin{figure}
    \ifpieplotsstart
    \else
      \ContinuedFloat
    \fi
    \unvbox\pieplotspartialbox
    \bigskip
    \caption{\pieplotscaption \ifpieplotsstart\else\space(continued)\fi}
    \ifpieplotsstart\label{\pieplotslabel}\fi
    \vfill
    \end{figure}
    \global\pieplotsstartfalse
    \expandafter\splitpieplots
  \fi}

\newif\ifpieplotsstart
\newbox\pieplotspartialbox
\newbox\pieplotsbox 

\begin{document}
\kant

\begin{pieplots}{profiling:matlab}{Matlab profiling plots}
    \pieplot{testCDST}{\input{testCDST}}
    \pieplot{spam}{\input{spam}}
    \pieplot{testCD}{\input{testCD}}
    \pieplot{runningex30k}{\input{runningex30k}}
    \pieplot{testCDST2}{\input{testCDST2}}
    \pieplot{segmentation}{\input{segmentation}}
    \pieplot{magicgamma}{\input{magicgamma}}
    \pieplot{ball1}{\input{ball1}}
    \pieplot{pendigits}{\input{pendigits}}
    \pieplot{runningex20k}{\input{runningex20k}}
    \pieplot{musk}{\input{musk}}
    \pieplot{runningex10k}{\input{runningex10k}}
    \pieplot{runningex40k}{\input{runningex40k}}
    \pieplot{spam\_train}{\input{spam_train}}
    \pieplot{testoutrank}{\input{testoutrank}}
    \pieplot{testCDST3}{\input{testCDST3}}
    \pieplot{runningex1k}{\input{runningex1k}}
    \pieplot{mesh\_network}{\input{mesh_network}}
    \pieplot{letter-recognition}{\input{letter-recognition}}
    \pieplot{connect4}{\input{connect4}}
    \pieplot{runningex50k}{\input{runningex50k}}
\end{pieplots}

\kant

\end{document}

You'll have to provide the definition of \pieplot so that the charts occupy the same space. Put them in a \mbox followed by \hfil\ignorespaces as in my code.

This will catch all the plots and then spit out them as much as a page can contain; the last page will be short, of course.

share|improve this answer
add comment

You can use a list environment to accomodate the 21 images; this will keep them together, allowing page breaks. The images will be aligned in rows using inner minipages environments; captions can be given using \captionof (from the caption package); to facilitate writing the inner minipages, I defined a \inputpie command with one mandatory argument (the name of the file to be included and to be used for the subcaption); vertical alignment of the images inside each row can be controlled with the optional argument for the minipage in the definition of \inputpie (in the example the images will be vertically aligned at the top):

\documentclass[a4paper]{report}

\usepackage{filecontents}
\usepackage{tikz}
\usepackage{xparse}
\usepackage{longtable}
\usepackage{caption}
\usepackage{subcaption}

\newcommand\inputpie[1]{%
  \begin{minipage}[t]{.33333\textwidth} % change the optional argument to c for vertical alignment at the center or to b for vertical alignment at the bottom
  \centering
  \input{#1}
  \captionof{subfigure}{#1}
\end{minipage}}

\begin{filecontents}{pgf-pie.sty}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Some LaTeX macros for pie chart by using PGF/Tikz package.
% Home page of project: http://pgf-pie.googlecode.com/
% Author: Xu Yuan <xuyuan.cn@gmail.com>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{pgf-pie}[2011/10/02 v0.2 Some LaTeX macros for pie
chart by using PGF/Tikz package.]

\RequirePackage{tikz}
\RequirePackage{ifthen}
\RequirePackage{scalefnt}

% args:
% #1: begin angle
% #2: end angle
% #3: number
% #4: label
% #5: explode
% #6: fill color
% #7: radius
% #8: center
\newcommand{\pgfpie@slice}[8]{%
    \pgfmathparse{0.5*(#1)+0.5*(#2)}%
    \let\midangle\pgfmathresult
    %
    \path (#8) -- ++(\midangle:#5) coordinate(O);%
    %
    \pgfmathparse{#7+#5}%
    \let\radius\pgfmathresult
    %
    % slice
    \draw[line join=round, fill=#6, \style] (O) -- ++(#1:#7) arc (#1:#2:#7) -- cycle;%
    %
    \pgfmathparse{min(((#2)-(#1)-10)/110*(-0.3),0)}%
    \let\temp\pgfmathresult%
    \pgfmathparse{(max(\temp,-0.5) + 0.8)*#7}%
    \let\innerpos\pgfmathresult
    %
    \ifthenelse{\equal{\pgfpie@text}{inside}}{%
        % label and number together
        \path (O) -- ++(\midangle:\innerpos) node%
        {\scalefont{#3}\shortstack{#4\\\beforenumber#3\afternumber}};%
    }{%
        % label
        \iflegend
        \else
            \path (O) -- ++ (\midangle:\radius)%
            node[inner sep=0, \pgfpie@text=\midangle:#4]{};%
        \fi
        %
        % number
        \path (O) -- ++(\midangle:\innerpos) node%
        {\scalefont{#3}\beforenumber#3\afternumber};%
    }%
}

\newcommand{\pgfpie@findColor}[1]{%
    \pgfmathparse{int(mod(#1,\value{pgfpie@colorLength}))}%
    \let\ci\pgfmathresult
    \foreach \c [count=\j from 0] in \color {%
        \ifnum \j=\ci
            \xdef\thecolor{\c}%
            \thecolor
            \breakforeach
        \fi
    }%
}

\newcommand{\pgfpie@findExplode}[1]{%
    \pgfmathparse{int(mod(#1,\value{pgfpie@explodeLength}))}%
    \let\ei\pgfmathresult
    \foreach \e [count=\j from 0] in \explode {%
        \ifnum \j=\ei
            \xdef\theexplode{\e}%
            \breakforeach
        \fi
    }%
}

% #1: bottom left point
% #2: size
% #3: number
% #4: color
% #5: text
\newcommand{\pgfpie@square}[5]{%
    \ifthenelse{\equal{\pgfpie@text}{inside}}{%
        \draw[fill=#4, \style] (#1) rectangle node%
        {\scalefont{#3}\shortstack{#5\\\beforenumber#3\afternumber}} ++(#2);%
    }{%
        \draw[fill=#4, \style] (#1) rectangle node%
        {\scalefont{#3}\beforenumber#3\afternumber} ++(#2);%
    }%
}

% #1: pos
% #2: radius
% #3: number
% #4: color
% $5: style
% $6: label
\newcommand{\pgfpie@cloud}[6]{%
    \draw[fill=#4, #5] (#1) circle[radius=#2];%
    \ifthenelse{\equal{\pgfpie@text}{inside}}{%
        \node at (#1) {\scalefont{#3}\shortstack{#6\\\beforenumber#3\afternumber}};%
    }{%
        \node at (#1) {\scalefont{#3}\beforenumber#3\afternumber};%
    }%
}

\newlength{\pgfpie@angleEnd}
\newcounter{pgfpie@explodeLength}
\newcounter{pgfpie@colorLength}
\newcounter{pgfpie@sliceLength}

\def\setexplode#1\pgfeov{\def\explode{#1}}
\pgfkeyslet{/explode/.@cmd}{\setexplode}

\def\setcolor#1\pgfeov{\def\color{#1}}
\pgfkeyslet{/color/.@cmd}{\setcolor}

\def\setradius#1\pgfeov{\def\radius{#1}}
\pgfkeyslet{/radius/.@cmd}{\setradius}

\def\setpos#1\pgfeov{\def\pos{#1}}
\pgfkeyslet{/pos/.@cmd}{\setpos}

\def\setstyle#1\pgfeov{\def\style{#1}}
\pgfkeyslet{/style/.@cmd}{\setstyle}

\def\setbeforenumber#1\pgfeov{\def\beforenumber{#1}}
\pgfkeyslet{/before number/.@cmd}{\setbeforenumber}

\def\setafternumber#1\pgfeov{\def\afternumber{#1}}
\pgfkeyslet{/after number/.@cmd}{\setafternumber}

\def\settext#1\pgfeov{\xdef\pgfpie@text{#1}}
\pgfkeyslet{/text/.@cmd}{\settext}

\def\setsum#1\pgfeov{\xdef\pgfpie@sum{#1}}
\pgfkeyslet{/sum/.@cmd}{\setsum}

\def\setrotate#1\pgfeov{\xdef\rotate{#1}}
\pgfkeyslet{/rotate/.@cmd}{\setrotate}

\newif\ifpolar
\pgfkeys{/polar/.is if=polar}

\newif\iflegend
\newif\ifnolegend
\newif\iflegendonly

\newif\ifsquare
\pgfkeys{/square/.is if=square}

\newif\ifcloud
\pgfkeys{/cloud/.is if=cloud}

\newif\ifscalefont
\pgfkeys{/scale font/.is if=scalefont}
\let\scalefontorg\scalefont
\renewcommand{\scalefont}[1]{%
    \ifscalefont
        \pgfmathparse{#1 / \pgfpie@sum * 3 + 0.9}%
        \scalefontorg{\pgfmathresult}%
    \fi
}

\newcommand{\pie}[2][]{%
    % load default parameters
    \pgfkeys{%
        explode=0,%
        color={blue!60, cyan!60, yellow!60, orange!60, red!60,%
               blue!60!cyan!60, cyan!60!yellow!60, red!60!cyan!60,%
               red!60!blue!60, orange!60!cyan!60},%
        radius=3,%
        pos={0,0},%
        style={thick},%
        before number=,%
        after number=,%
        text=label,%
        sum=100,%
        rotate=0,%
        polar=false,%
        square=false,%
        cloud=false,%
        scale font=false,%
    }%
    %
    % load user's parameters
    \pgfkeys{#1}%
    % add percentage automatically
    \ifthenelse{\equal{\pgfpie@sum}{100}}{%
        \pgfkeys{after number=\%}%
        \pgfkeys{#1}%
    }{}%
    %
    % legend or not
    \ifthenelse{\equal{\pgfpie@text}{legend}}%
    {\legendtrue}%
    {\legendfalse}%
    %
    % nolegend or not
    \ifthenelse{\equal{\pgfpie@text}{nolegend}}%
    {\nolegendtrue \legendtrue}%
    {\nolegendfalse}%
    %
    % legendonly or not
    \ifthenelse{\equal{\pgfpie@text}{legendonly}}%
    {\legendonlytrue \legendtrue}%
    {\legendonlyfalse}%
    %
    % handle sum
    \ifthenelse{\equal{\pgfpie@sum}{auto}}{%
        % sum all input
        \xdef\pgfpie@sum{0}%
        \foreach \p/\t in {#2}{%
            \pgfmathparse{\pgfpie@sum + \p}%
            \xdef\pgfpie@sum{\pgfmathresult}%
        }%
    }%
    {}%
    %
    % init counters
    \setcounter{pgfpie@explodeLength}{0}%
    \foreach \e in \explode { \addtocounter{pgfpie@explodeLength}{1} }%
    %
    \setcounter{pgfpie@colorLength}{0}%
    \foreach \c in \color { \addtocounter{pgfpie@colorLength}{1} }%
    %
    \pgfmathsetlength{\pgfpie@angleEnd}{0}%
    %
    \setcounter{pgfpie@sliceLength}{0}%
    \foreach \p/\e in {#2} { \addtocounter{pgfpie@sliceLength}{1} }%
    %
    \iflegendonly
    \else
        \ifsquare
        %%%%%%%%%% SQUARE PIE BEGIN %%%%%%%%%%%
            \pgfmathparse{\radius*2}%
            \xdef\verticalLength{\pgfmathresult}%
            \xdef\horizontalLength{\pgfmathresult}%
            \path (\pos) -- ++(-\radius, -\radius) coordinate (start);%
            \pgfmathparse{\verticalLength * \horizontalLength / \pgfpie@sum}%
            \let\squareUnit\pgfmathresult
            %
            % drawing loop
            \foreach \p/\t [count=\i from 0] in {#2}{%
                \pgfpie@findColor{\i}
                %
                \ifthenelse{\lengthtest{\verticalLength cm > \horizontalLength cm}}{%
                    \pgfmathparse{\p * \squareUnit / \horizontalLength}%
                    \let\height\pgfmathresult
                    %
                    \pgfpie@square{start}{\horizontalLength,\height}%
                    {\p}%
                    {\thecolor}%
                    {\t}%
                    %
                    %label
                    \iflegend
                    \else
                        \ifthenelse{\equal{\pgfpie@text}{inside}}{}{%
                            \path (start) -- ++(\horizontalLength,\height*0.5) node[inner sep=0, \pgfpie@text=0:\t]{};%
                        }%
                    \fi
                    %
                    \pgfmathparse{\verticalLength - \height}%
                    \xdef\verticalLength{\pgfmathresult}%
                    \path (start) -- ++(0, \height) coordinate (start);%
                }{%
                    \pgfmathparse{\p * \squareUnit / \verticalLength }%
                    \let\width\pgfmathresult

                    \pgfpie@square{start}{\width,\verticalLength}%
                    {\p}%
                    {\thecolor}%
                    {\t}%
                    %
                    %label
                    \iflegend
                    \else
                        \ifthenelse{\equal{\pgfpie@text}{inside}}{}{%
                            \path (start) -- ++(\width*0.5,\verticalLength) node[inner sep=0, \pgfpie@text=90:\t]{};%
                        }%
                    \fi
                    %
                    \pgfmathparse{\horizontalLength - \width}%
                    \xdef\horizontalLength{\pgfmathresult}%
                    \path (start) -- ++(\width, 0) coordinate (start);%
                }%
            }%
        %%%%%%%%%% SQUARE PIE END %%%%%%%%%%%
        \else
        \ifcloud
        %%%%%%%%%% CLOUD PIE BEGIN %%%%%%%%%%%
            % drawing loop
            \foreach \p/\t [count=\i from 0] in {#2}{%
                % find explode
                \pgfpie@findExplode{\i}%
                \def\cloudGap{\theexplode + 0.1}%
                \pgfmathparse{sqrt(\p / \pgfpie@sum) * \radius}%
                \let\cloudR\pgfmathresult
                \ifnum \i = 0
                    % first cloud
                    \coordinate (O) at (\pos);%
                    \xdef\cloudRone{\cloudR}%
                    \xdef\cloudExtendDir{180+\rotate}%
                \else
                \ifnum \i = 1
                    % second cloud
                    \xdef\cloudRtwo{\cloudR}%
                    \xdef\cloudExtendDir{45+\rotate}%
                    \path (O) -- ++(\cloudExtendDir:\cloudRone+\cloudGap+\cloudRtwo) coordinate (O);%
                \else
                    % next cloud
                    \pgfmathparse{\cloudRone+\cloudGap+\cloudRtwo}%
                    \let\la\pgfmathresult
                    \pgfmathparse{\cloudRone+\cloudGap+\cloudR}%
                    \let\lb\pgfmathresult
                    \pgfmathparse{\cloudRtwo+\cloudGap+\cloudR}%
                    \let\lc\pgfmathresult
                    \pgfmathparse{\la^2+\lc^2-\lb^2}%
                    \let\tmp\pgfmathresult
                    \pgfmathparse{180 - acos(\tmp / 2 / \la / \lc)}%
                    \let\cloudRot\pgfmathresult
                    \ifodd \i
                        \pgfmathparse{-\cloudRot}%
                        \let\cloudRot\pgfmathresult
                    \fi
                    \pgfmathparse{\cloudExtendDir - \cloudRot}
                    \xdef\cloudExtendDir{\pgfmathresult}
                    \path (O) -- ++(\cloudExtendDir:\lc) coordinate (O);
                    \xdef\cloudRone{\cloudRtwo}
                    \xdef\cloudRtwo{\cloudR}
                \fi
                \fi
                %
                % find color
                \pgfpie@findColor{\i}%

                \pgfpie@cloud{O}{\cloudR}{\p}%
                {\thecolor}{\style}{\t}%

                % label
                \iflegend
                \else
                    \ifthenelse{\equal{\pgfpie@text}{inside}}{}{%
                        \path (O) -- ++(\cloudExtendDir:\cloudR)%
                        node[inner sep=0, \pgfpie@text=\cloudExtendDir:\t] {};%
                    }%
                \fi
            }
        %%%%%%%%%% CLOUD PIE END %%%%%%%%%%%
        \else
        %%%%%%%%%% CIRCLE PIE BEGIN %%%%%%%%%%%
            \ifpolar
                \xdef\maxValue{0}%
                \foreach \p/\e in {#2} {%
                    \ifnum \maxValue < \p
                        \xdef\maxValue{\p}%
                    \fi
                }%
                \pgfmathparse{\pgfpie@sum / \value{pgfpie@sliceLength}}%
                \xdef\polarangle{\pgfmathresult}%
                \pgfmathparse{\radius / sqrt(\maxValue)}%
                \xdef\polarRadiusUnit{\pgfmathresult}%
            \else
                \xdef\theradius{\radius}%
            \fi

            \xdef\pgfpie@angleBegin{\the\pgfpie@angleEnd}%
            % drawing loop
            \foreach \p/\t [count=\i from 0] in {#2}{%
                \pgfmathsetlength{\pgfpie@angleEnd}{\pgfpie@angleBegin}%
                \ifpolar
                    % Polar area diagram
                    \pgfmathaddtolength{\pgfpie@angleEnd}{\polarangle}%
                    \pgfmathparse{sqrt(\p) * \polarRadiusUnit}%
                    \xdef\theradius{\pgfmathresult}%
                \else
                    % normal pie
                    \pgfmathaddtolength{\pgfpie@angleEnd}{\p}%
                \fi
                %
                % find explode
                \pgfpie@findExplode{\i}%

                % find color
                \pgfpie@findColor{\i}%
                \pgfpie@slice{\pgfpie@angleBegin/\pgfpie@sum*360+\rotate}%
                {\the\pgfpie@angleEnd/\pgfpie@sum*360+\rotate}%
                {\p}%
                {\t}%
                {\theexplode}%
                {\thecolor}%
                {\theradius}%
                {\pos}%
                \xdef\pgfpie@angleBegin{\the\pgfpie@angleEnd}%
            }%
        %%%%%%%%%% CIRCLE PIE END %%%%%%%%%%%
        \fi
        \fi
    \fi
    %
    % legend
    \iflegend
        \ifnolegend
        \else
            \coordinate[xshift=0.8cm,yshift=(\value{pgfpie@sliceLength}*0.5+1)*0.5cm] (legendpos) at (current bounding box.east);%

            \begin{scope}[node distance=0.5cm]%
                \foreach \p/\t  [count=\i from 0] in {#2}{%
                    \pgfpie@findColor{\i}%
                    \node[draw, fill=\thecolor, \style, below of=legendpos, label=0:\t] (legendpos) {};%
                }%
            \end{scope}%
        \fi
    \fi
}
\end{filecontents}

\begin{filecontents}{pieplots.sty}
\usepackage{pgf-pie}
\usepackage{caption}
\usepackage{subfig}
\makeatletter
\newcounter{@sfcol}%
\newcounter{@sffig}%
\NewDocumentEnvironment{pieplots}{mm}{%
    \setcounter{@sfcol}{0}%
    \setcounter{@sffig}{0}%
    \setcounter{subfigure}{0}%
    %
    \def\@sfprefix{\hspace{\fill}}%
    \def\@sfsuffix{}%
    %
    \newcommand\pieplot[2]{%
        \@sfprefix%
        \subfloat[##1]{##2}%
        \@sfsuffix%
        %
        \def\@sfsuffix{}%
        \stepcounter{@sfcol}%
        \ifnum\value{@sfcol}=2%
            \def\@sfsuffix{\hspace*{\fill}}%
        \fi%
        \ifnum\value{@sfcol}=3%
            \setcounter{@sfcol}{0}%
            \stepcounter{@sffig}%
            \def\@sfprefix{%
                \caption{}%
                \label{#1:subfig\arabic{@sffig}}%
                \endfigure%
                \figure[H]%
                    \ContinuedFloat%
                    \hspace{\fill}%
            }%
        \fi%
    }%
    %
    \figure[H]%
}{%
        \caption{#2}%
        \label{#1}%
    \endfigure%
}
\makeatother
\end{filecontents}
\usepackage{pieplots}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The plots
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{filecontents}{ball1.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={cyan!60,yellow!60,orange!60,blue!60,red!60,blue!60!cyan!60,white!60}]{
            3.61/{pcg},
            3.23/{hggetbehavior},
            5.38/{isprop},
            56.96/{TopN\_Outlier\_Pruning\_Block},
            3.34/{localPeek},
            3.30/{drawGraph},
            24.19/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{connect4.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,cyan!60!yellow!60,white!60,orange!60!cyan!60}]{
            85.22/{TopN\_Outlier\_Pruning\_Block},
            7.77/{knn\_components\_sparse},
            3.28/{Other},
            3.73/{kdtree\_k\_nearest\_neighbors ()}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{letter-recognition.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,cyan!60!yellow!60,white!60}]{
            84.26/{TopN\_Outlier\_Pruning\_Block},
            7.00/{knn\_components\_sparse},
            8.74/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{magicgamma.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,cyan!60!yellow!60,white!60}]{
            85.12/{TopN\_Outlier\_Pruning\_Block},
            8.47/{knn\_components\_sparse},
            6.41/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{mesh-network.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60,purple!60,orange!60!cyan!60}]{
            68.01/{TopN\_Outlier\_Pruning\_Block},
            23.76/{Other},
            3.09/{princomp},
            5.15/{kdtree\_k\_nearest\_neighbors ()}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{musk.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,cyan!60!yellow!60,white!60,orange!60!cyan!60}]{
            82.39/{TopN\_Outlier\_Pruning\_Block},
            3.13/{knn\_components\_sparse},
            9.48/{Other},
            5.00/{kdtree\_k\_nearest\_neighbors ()}        
        }
    \end{tikzpicture}
    \end{filecontents}
\begin{filecontents}{pendigits.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,cyan!60!yellow!60,white!60}]{
            84.51/{TopN\_Outlier\_Pruning\_Block},
            6.01/{knn\_components\_sparse},
            9.48/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex1k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={orange!60,blue!60,white!60}]{
            3.57/{isprop},
            71.80/{TopN\_Outlier\_Pruning\_Block},
            24.62/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex10k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            94.57/{TopN\_Outlier\_Pruning\_Block},
            5.43/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex20k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            96.44/{TopN\_Outlier\_Pruning\_Block},
            3.56/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex30k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            97.01/{TopN\_Outlier\_Pruning\_Block},
            2.99/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex40k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            96.98/{TopN\_Outlier\_Pruning\_Block},
            3.02/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{runningex50k.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            96.88/{TopN\_Outlier\_Pruning\_Block},
            3.12/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{segmentation.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,red!60!cyan!60,white!60}]{
            70.72/{TopN\_Outlier\_Pruning\_Block},
            3.30/{prepare},
            25.98/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{spam.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={cyan!60,blue!60,cyan!60!yellow!60,white!60}]{
            3.96/{pcg},
            73.03/{TopN\_Outlier\_Pruning\_Block},
            4.56/{knn\_components\_sparse},
            18.46/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{spam-train.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={cyan!60,blue!60,cyan!60!yellow!60,white!60}]{
            4.71/{pcg},
            74.51/{TopN\_Outlier\_Pruning\_Block},
            4.14/{knn\_components\_sparse},
            16.64/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{testCD.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={magenta!60,orange!60,blue!60,white!60}]{
            3.09/{newplot},
            4.32/{isprop},
            62.28/{TopN\_Outlier\_Pruning\_Block},
            30.31/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{testCDST.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            79.76/{TopN\_Outlier\_Pruning\_Block},
            20.24/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{testCDST2.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            81.67/{TopN\_Outlier\_Pruning\_Block},
            18.33/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{testCDST3.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={blue!60,white!60}]{
            81.67/{TopN\_Outlier\_Pruning\_Block},
            18.33/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
\begin{filecontents}{testoutrank.tex}
    \begin{tikzpicture}
        \pie[text=nolegend, radius=1.5, color={cyan!60,orange!60!cyan!60,orange!60,blue!60,green!60,magenta!60,white!60}]{
            19.31/{pcg},
            3.31/{@(b)mx\_d\_preconditioner(sH,b)},
            4.38/{isprop},
            31.94/{TopN\_Outlier\_Pruning\_Block},
            10.89/{iterapp},
            4.15/{mx\_d\_preconditioner ()},
            26.02/{Other}        
        }
    \end{tikzpicture}
\end{filecontents}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

%\begin{pieplots}{profiling:matlab}{Matlab profiling plots}
%    \pieplot{testCDST}{\input{testCDST}}
%    \pieplot{spam}{\input{spam}}
%    \pieplot{testCD}{\input{testCD}}
%    \pieplot{runningex30k}{\input{runningex30k}}
%    \pieplot{testCDST2}{\input{testCDST2}}
%    \pieplot{segmentation}{\input{segmentation}}
%    \pieplot{magicgamma}{\input{magicgamma}}
%    \pieplot{ball1}{\input{ball1}}
%    \pieplot{pendigits}{\input{pendigits}}
%    \pieplot{runningex20k}{\input{runningex20k}}
%    \pieplot{musk}{\input{musk}}
%    \pieplot{runningex10k}{\input{runningex10k}}
%    \pieplot{runningex40k}{\input{runningex40k}}
%    \pieplot{spam\_train}{\input{spam_train}}
%    \pieplot{testoutrank}{\input{testoutrank}}
%    \pieplot{testCDST3}{\input{testCDST3}}
%    \pieplot{runningex1k}{\input{runningex1k}}
%    \pieplot{mesh\_network}{\input{mesh_network}}
%    \pieplot{letter-recognition}{\input{letter-recognition}}
%    \pieplot{connect4}{\input{connect4}}
%    \pieplot{runningex50k}{\input{runningex50k}}
%\end{pieplots}

\clearpage
{
\setlength\leftmargini{0pt}
\begin{enumerate}\item[]
    \inputpie{testCDST}% 
    \inputpie{spam}%  
    \inputpie{testCD} \\
    \inputpie{runningex30k}%  
    \inputpie{testCDST2}% 
    \inputpie{segmentation} \\
    \inputpie{magicgamma}% 
    \inputpie{ball1}%  
    \inputpie{pendigits} \\
    \inputpie{runningex20k}% 
    \inputpie{musk}%  
    \inputpie{runningex10k} \\
    \inputpie{runningex40k}% 
    \inputpie{spam-train}% 
    \inputpie{testoutrank}\\%
    \inputpie{testCDST3}
    \inputpie{runningex1k}%
    \inputpie{mesh-network} \\
    \inputpie{letter-recognition} 
    \inputpie{connect4}%
    \inputpie{runningex50k}\par
    \captionof{figure}{A figure with 21 subfigures}
\end{enumerate}
}

\end{document}

enter image description here

share|improve this answer
    
This is a good solution, however I am really seeking a solution which does not rely on hardcoding the number of figures that can fit on the page. The main reason for this is that there may be text before the figures, and the length of this text may change. –  Joshua Spence Sep 21 '12 at 0:43
    
@JoshuaSpence I added a second option using a list; the number of subfigures is not hard-coded anymore. –  Gonzalo Medina Sep 21 '12 at 1:57
    
@GonzaloMedina... I cannot see the list option? –  Joshua Spence Sep 21 '12 at 2:43
    
@JoshuaSpence arghhh! Since the code was too long, it was deleted. I'll reproduce it and let you know. –  Gonzalo Medina Sep 21 '12 at 2:46
1  
@JoshuaSpence I updated my answer with the option using a list. –  Gonzalo Medina Sep 21 '12 at 2:52
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.