1

Hi I am trying to create a pie chart and have used the following code to do so. I import everything properly, however, I cannot use my created "data" command for some reason. I get the error "Undefined Control Sequence". What am I doing wrong:

\documentclass[tikz]{article}
\usepackage[utf8]{inputenc}
\usepackage{pdflscape}
\usepackage[table]{xcolor}
\usepackage[landscape, a4paper, bottom=0cm, margin=0in, top=2cm]{geometry}
\usepackage{pgfplots}
\usepackage{array}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[T1]{fontenc}
\usepackage[cm]{sfmath}
\usepackage{fancyhdr}
\usepackage{eso-pic}
\usepackage{titleps}
\usepackage{lipsum}
\usepackage[pdf]{pstricks}


%Header Stuff
\newpagestyle{myheader}{%
\sethead{}{\sffamily\large\raisebox{6ex}{\parbox{2cm}{
    \hspace*{10cm}
    \includegraphics[width=2in]{images/toptrack_logo.png}
}}}{}
}

%Customization
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\pgfplotsset{compat=newest} % Allows to place the legend below plot
\usepgfplotslibrary{
  units, % Allows to enter the units nicely
  groupplots
}

%Piechart
\degrees[100]
\newcounter{counter}
\SpecialCoor
\newcommand\data[2][gray]{%
    \pswedge[fillstyle=solid,fillcolor=#1,opacity=.5](0,0){4}{!\thecounter}{!\thecounter\space #2 add}%
    \uput{2}[!#2 2 div \thecounter\space add](0,0){#2\%}%
    \addtocounter{counter}{#2}%
}


\newcommand{\tabitem}{}
\pagenumbering{gobble}
\renewcommand{\familydefault}{\sfdefault}
\definecolor{customgrey}{RGB}{78,74,68}
\definecolor{customblue}{RGB}{70,179,211}
\definecolor{customblack1}{RGB}{35,31,32}
\definecolor{customblack2}{RGB}{64,64,66}
\definecolor{customdarkblue}{RGB}{79,129,189}
\definecolor{customlightblue}{RGB}{142,174,213}
\definecolor{customdarkred}{RGB}{192,80,77}
\definecolor{customlightred}{RGB}{217,147,145}



\title{test}
\author{sinasohi}
\date{January 2017}

\begin{document}
%\maketitle

\include{Page0}
\pagestyle{myheader}{
\AddToShipoutPictureBG{%
 \AtPageLowerLeft{
    \hspace{-0.25cm}
    \includegraphics[width=30cm]{images/toptrack_footer.png}
 }}{
\include{Page1}
\include{Page2}
\include{Page3}
\include{Page4}
\include{Page5}
}}

\end{document}

Where I "use" my piechart in a Page3:

\hspace{2cm}{\Huge \color{customblack1} ABCD inddeling}

\begin{pspicture}(-4.5,-4.5)(4.5,4.5)
    \data[red]{10}
    \data[orange]{40}
    \data[yellow]{30}
    \data[blue]{20}
\end{pspicture}
1
  • Nobody but you can reproduce your issue as your code is useless to us. We will just get unrelated errors. In any case, please give the exact text of the error. It will have told you which control sequence is undefined, which should help you to diagnose the problem. That said, you cannot \include something into a page style like that. \include always starts a new page, so it can't go into the background of this one.
    – cfr
    Commented Jan 27, 2017 at 1:54

1 Answer 1

2

There is a macro for pie charts:

\documentclass{article}    
\usepackage{pstricks-add}
\begin{document}

\psset{unit=1.5}
\begin{pspicture}(-3,-3)(3,3)
\psChart[userColor={red!30,green!30,blue!40,gray,cyan!50,
    magenta!60,cyan},chartSep=30pt,shadow=true,shadowsize=5pt
]{34.5,17.2,20.7,15.5,5.2,6.9}{6}{2}
\psset{nodesepA=5pt,nodesepB=-10pt}
\ncline{psChartO1}{psChart1}\nput{0}{psChartO1}{1000 (34.5\%)}
\ncline{psChartO2}{psChart2}\nput{150}{psChartO2}{500 (17.2\%)}
\ncline{psChartO3}{psChart3}\nput{-90}{psChartO3}{600 (20.7\%)}
\ncline{psChartO4}{psChart4}\nput{0}{psChartO4}{450 (15.5\%)}
\ncline{psChartO5}{psChart5}\nput{0}{psChartO5}{150 (5.2\%)}
\ncline{psChartO6}{psChart6}\nput{0}{psChartO6}{200 (6.9\%)}
\bfseries
\rput(psChartI1){Taxes}\rput(psChartI2){Rent}\rput(psChartI3){Bills}
\rput(psChartI4){Car}\rput(psChartI5){Gas}\rput(psChartI6){Food}
\end{pspicture} 
\end{document}

enter image description here

6

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .