I have this code to my pie graphs and I am trying to have the labels of the subfloats and each pie centered.
Here is my code:
\documentclass[oneside,12pt]{scrbook}
\usepackage{tikz}%esquema
\usepackage{subfig}
\begin{document}
\newcommand{\slicepie}[4]{
\pgfmathsetmacro\midangle{0.5*#1+0.5*#2}
% slice
\draw[thick,fill=black!10] (0,0) -- (#1:1) arc (#1:#2:1) -- cycle;
\ifnum\p<11
\def\plabel{#3 (\p\%)}%
\def\slabel{}%
\else
\def\plabel{#3}%
\def\slabel{\p\%}%
\fi
%outer label
\node [label={[name=l \j]\midangle:\plabel}, yshift=#4] at (\midangle:1.15) {};
%inner label
\pgfmathsetmacro\innerpos{max(min((#2-#1-10)/110*(-0.3),0),-.5) +.8}
\pgfmathsetmacro\labelanchor{ ( \midangle < 90 ) ? "south west" : ( ( \midangle < 180 ) ? "east" : ( ( \midangle < 270 ) ? "north" : "west" ) ) }
\node (slabel \j) at (\midangle:\innerpos) {\slabel};
\draw (slabel \j) -- (l \j.\labelanchor) ;
}
\begin{center}
\begin{figure}[!ht]
\subfloat[Strategy no. 2]{\label{fig:in}
\begin{tikzpicture}[thick,scale=0.76, every node/.style={transform shape}]
\centering
\newcounter{z}
\newcounter{g}
\foreach \p/\t/\n [count=\j] in {
83/Global equities/-10pt,
9/Absolute Return Bonds/10pt,
8/Others\footnote\smallskip/10pt}
{
\setcounter{z}{\value{g}}
\addtocounter{g}{\p}
\slicepie{\thez/100*360}
{\theg/100*360}
{\t}
{\n}
}
\end{tikzpicture}
}
\subfloat[Strategy no. 3]{\label{fig:in}
\begin{tikzpicture}[thick,scale=0.76, every node/.style={transform shape}]
\centering
\newcounter{q}
\newcounter{w}
\foreach \p/\t/\n [count=\j] in {
35/Absolute Return Bonds/0pt,
7/Euro Corporate bonds ($>$10 years)/0pt,
4/Eurozone Equities/0pt,
4/Fixed Interest euro govt Bonds ($>$10years)/-5pt,
43/Global equities/0pt,
3/Index-Linked euro govts (AS)/10pt,
8/Others\footnote\smallskip/15pt}
{
\setcounter{q}{\value{w}}
\addtocounter{w}{\p}
\slicepie{\theq/100*360}
{\thew/100*360}
{\t}
{\n}
}
\end{tikzpicture}
}
\subfloat[Strategy no. 4]{\label{fig:in}
\begin{tikzpicture}[thick,scale=0.76, every node/.style={transform shape}]
\centering
\newcounter{k}
\newcounter{l}
\foreach \p/\t/\n [count=\j] in {
41/Global equities/-15pt,
41/Absolute Return Bonds/15pt,
9/Euro Corporate bonds ($>$10 years)/15pt,
9/Others\footnote\smallskip/10pt}
{
\setcounter{k}{\value{l}}
\addtocounter{l}{\p}
\slicepie{\thek/100*360}
{\thel/100*360}
{\t}
{\n}
}
\end{tikzpicture}
}
\subfloat[Strategy no. 5]{\label{fig:in}
\begin{tikzpicture}[thick,scale=0.76, every node/.style={transform shape}]
\centering
\newcounter{y}
\newcounter{r}
\foreach \p/\t/\n [count=\j] in {
33/Absolute Return Bonds/0pt,
52/Global equities/-3pt,
5/Cash/10pt,
5/Others\footnote\smallskip/13pt,
5/Euro Corporate bonds ($>$10 years)/15pt}
{
\setcounter{y}{\value{r}}
\addtocounter{r}{\p}
\slicepie{\they/100*360}
{\ther/100*360}
{\t}
{\n}
}
\end{tikzpicture}
}
\subfloat[Strategy no. 6]{\label{fig:in}
\begin{tikzpicture}[thick,scale=0.76, every node/.style={transform shape}]
\centering
\newcounter{v}
\newcounter{f}
\foreach \p/\t/\n [count=\j] in {
37/Absolute Return Bonds/-15pt,
6/Euro Corporate bonds ($>$10 years)/-10pt,
3/Fixed Interest euro govt Bonds ($>$10years)/-15pt,
47/Global equities/15pt,
4/Others\footnotemark\smallskip/5pt,
3/Eurozone Equities/10pt}
{
\setcounter{v}{\value{f}}
\addtocounter{f}{\p}
\slicepie{\thev/100*360}
{\thef/100*360}
{\t}
{\n}
}
\end{tikzpicture}
}
\caption{Alocation of the amount invested in each sub-asset class for the five strategies}
\label{fi2}
\end{figure}
\end{center}
\footnotetext[1]{Euro Corporate Bonds ($>$10 years) (2\%), Eurozone Equities (2\%), Index-Linked Euro Government (1\%), Fixed Interest Euro Government Bonds ($>$10 years) (1\%), Cash (1\%), Others (1\%)}
\footnotetext[2]{Property (2\%), Eurozone Equities (2\%), Fixed Interest Euro Government Bonds ($>$5 years) (1\%), Cash (1\%), Emerging Market Debt (2\%)}
\footnotetext[3]{Eurozone Equities (2\%), Index-Linked Euro Government (2\%), Fixed Interest Euro Government Bonds ($>$5 years) (1\%), Fixed Interest Euro Government Bonds ($>$10 years) (2\%), Cash (2\%)}
\footnotetext[4]{Eurozone Equities (1\%), Index-Linked Euro Government (1\%), Fixed Interest Euro Government Bonds ($>$10 years) (1\%), Property (3\%)}
\footnotetext[5]{Index-Linked Euro Government (1\%), Fixed Interest Euro Government Bonds ($>$5 years) (2\%), Cash (1\%)}
\end{document}
Could u give me some help? thanks.


trim left=-0.5\linewidth,trim right=0.5\linewidthas option totikzpicture. However, then the text in the picture is too long and will run out in the left margin. So I am not sure it is an improvement for this case. – StefanH Oct 11 '16 at 13:28