[Tex/LaTex] Problem producing a pie chart

multicolpgf-pietikz-pgf

I tried producing a pie chart with pgf-pie (which seemed easy to me), but it was not available on my system and on MiKTex. So I tried this unsuccessfully. Kindly help.

\documentclass{beamer}
\usepackage{multicol}
\usepackage{datapie}
\usetheme{Warsaw}
\begin{filecontents}{institutes.csv}
Name,Quantity
"ERD", 50
"NERD",50
\end{filecontents}
\begin{filecontents}{population.csv}
Name,Quantity
"ERD", 30
"NERD", 70
\end{filecontents}

\DTLloaddb{institute}{institutes.csv}
\DTLloaddb{population}{population.csv}

\begin{document}
\begin{frame}{Are all the gastroesophageal reflux disease patients same? }
\begin{exampleblock}
{All patients present with  heart burn \texttt{and/or} regurgitation of sour fluid in mouth }So all these patients are same with varying severity of symptoms?
\end{exampleblock}
\begin{itemize}
\item upper gastro-intestinal endoscopy 
\item 24 hour Ph-metry 
\end{itemize}
\end{frame}

%-------------------------------------------------------------------------------------------------------------------------
\begin{frame}{Endoscopy Data}
\begin{columns}[2]
\begin{column}[0.4\textwidth]
\begin{figure}[htbp]
\DTLpiechart{variable=\quantity,outerlabel=\name}{institute}{%
\name=Name,\quantity=Quantity}
\caption{A pie chart} 
\end{figure}
\end{column}
\begin{column}[0.4\textwidth]
\begin{figure}[htbp]
\DTLpiechart{variable=\quantity,outerlabel=\name}{population}{%
\name=Name,\quantity=Quantity}
\caption{A pie chart}
\end{figure}
\end{column}
\end{columns}
\end{frame}
\end{document}

Best Answer

You have two beamer syntax errors, so this isn't really related to the pie-charts at all:

  • \begin{columns}[2]: there is no optional argument 2 for columns, you don't have to specify the number of columns, if that is what you wanted. Just remove [2].

  • \begin{column}[0.4\textwidth]: the width of a column is a mandatory argument, and has to placed in braces, not brackets. Hence, write \begin{column}{0.4\textwidth} instead.

Note that beamers columns are not related to the multicol package, they are defined by the document class itself, so you don't actually need that package for this example.


If you want to use pgf-pie you have to download pgf-pie.sty from https://code.google.com/p/pgf-pie/ and make it available for use. The quickest way is to place it in the same folder as your .tex file.

Related Question