我想在饼图旁边放一个表格。我试图将它们放在表格或矩阵中,但饼图比表格略高。
我该如何表达呢?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgf-pie}
\begin{document}
\begin{table}
\begin{tabular}{cc}
\begin{tabular}{c c c c}
Kromosoma & Hamartarra & $ f(x)$ & $f(x)/\sum_x f(x)$ \\ \hline
01100 & 12 & 144 & 0,1181\\
11001 & 25 & 625 & 0,5127\\
00101 & 5 & 25 & 0,0205\\
10011 & 19 & 361 & 0,2962 \\
01000 & 8 & 64 & 0,0525\\\hline
Batura && 1219\\
\end{tabular}
&
\begin{tikzpicture}
\pie[,radius=1.5,hide number,rotate = 90,text= inside]{10, 20, 30, 30, 10}
\end{tikzpicture} \\
\end{tabular}
\end{table}
\end{document}
答案1
您可以使用baseline
tikzpicture 的选项(外部表格不是真正必要的,您可以将元素放在彼此旁边):
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgf-pie}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{c c c c}
Kromosoma & Hamartarra & $ f(x)$ & $f(x)/\sum_x f(x)$ \\ \hline
01100 & 12 & 144 & 0,1181\\
11001 & 25 & 625 & 0,5127\\
00101 & 5 & 25 & 0,0205\\
10011 & 19 & 361 & 0,2962 \\
01000 & 8 & 64 & 0,0525\\\hline
Batura && 1219\\
\end{tabular}%
\hfill%
\begin{tikzpicture}[baseline]
\pie[,radius=1.5,hide number,rotate = 90,text= inside]{10, 20, 30, 30, 10}
\end{tikzpicture}%
\end{table}
\end{document}
答案2
正如 Sam Carter 刚刚发布的,您可以调整基线,但通常最好“用眼睛”定位这些东西,并根据喜好调整偏移量:
\documentclass{article}
\usepackage{pgf-pie}
\begin{document}
\begin{table}
\begin{tabular}{cc}
\begin{tabular}{@{}c c c c}
Kromosoma & Hamartarra & $ f(x)$ & $f(x)/\sum_x f(x)$ \\ \hline
01100 & 12 & 144 & 0,1181\\
11001 & 25 & 625 & 0,5127\\
00101 & 5 & 25 & 0,0205\\
10011 & 19 & 361 & 0,2962 \\
01000 & 8 & 64 & 0,0525\\\hline
Batura && 1219\\
\end{tabular}
&
\hspace{-10pt}%
\raisebox{-40pt}{\begin{tikzpicture}
\pie[,radius=1.5,hide number,rotate = 90,text= inside]{10, 20, 30, 30, 10}
\end{tikzpicture}} \\
\end{tabular}
\end{table}
\end{document}