我想在一个表中对齐多个不同大小的饼图。具体来说,我希望这些饼图水平和垂直对齐,使得饼图的中心分别位于一条水平线和垂直线上。到目前为止,我还没有成功。有什么想法吗?
%
% Examples for pgf-pie, by Yuan Xu
%
% Based on the manual from:
% http://code.google.com/p/pgf-pie/
%
\documentclass{article}
\usepackage{fullpage}
\usepackage{pgf-pie}
\begin{document}
\maketitle
\begin{table}[h!]
\centering
\begin{tabular}{m{2cm} c c}
\hline
& A & B \\ \hline
A &
\begin{center}
\begin{tabular}{m}
\begin{tikzpicture}
\pie[radius = 0.3*3,
color = {green, gray, red}, sum=auto]{1/, 5/, 1/}
\end{tikzpicture}
\end{tabular}
\end{center}&
\begin{center}
\begin{tabular}{m}
\begin{tikzpicture}
\pie[radius = 0.3*1.25992104989,
color = {gray}, sum=auto]{2/}
\end{tikzpicture}
\end{tabular}
\end{center}\\
B &
\begin{center}
\begin{tabular}{m}
\begin{tikzpicture}
\pie[radius = 0.3*1.44224957031,
color = {gray}, sum=auto]{3/}
\end{tikzpicture}
\end{tabular}
\end{center}&
\begin{center}
\begin{tabular}{m}
\begin{tikzpicture}
\pie[radius = 0.3*1.58740105197,
color = {gray, red}, sum=auto]{2/ , 2/}
\end{tikzpicture}
\end{tabular}
\end{center}
\end{tabular}
\end{table}
\end{document}
目前看起来是这样的:
它看起来应该像这样:
答案1
通过剪辑到特定区域,它可以工作:
\documentclass{article}
\usepackage{fullpage}
\usepackage{pgf-pie}
\usepackage{array}
\usepackage{ragged2e}
\newcolumntype{M}[1]{>{\Centering}m{#1}}
\begin{document}
\begin{tabular}{c | M{2.5cm} | M{1.75cm} |}\hline
& A & B \\ \hline
A & \frame{\begin{tikzpicture}\clip (0,0) circle (1cm);
\pie[radius=0.3*3,
color={green,gray,red},sum=auto]{1/,5/,1/}
\end{tikzpicture}}%
& \frame{\begin{tikzpicture}\clip (0,0) circle (0.5cm);
\pie[radius=0.3*1.2599,color={gray},sum=auto]{2/}%
\end{tikzpicture}}\\
B & \frame{\begin{tikzpicture}\clip (0,0) circle (1cm);
\pie[radius = 0.3*1.442,
color = {gray}, sum=auto]{3/}
\end{tikzpicture}}
& \frame{\begin{tikzpicture}\clip (0,0) circle (0.5cm);
\pie[radius = 0.3*1.587,
color = {gray, red}, sum=auto]{2/ , 2/}
\end{tikzpicture}}
\end{tabular}
\end{document}