테이블 형식 환경에서 각 원형 차트(tikzpicture로 생성)에 캡션을 추가하는 방법은 무엇입니까?

테이블 형식 환경에서 각 원형 차트(tikzpicture로 생성)에 캡션을 추가하는 방법은 무엇입니까?

두 개의 서로 다른 원형 차트에 대해 표 형식 환경에서 다음 그림을 만들었습니다. 하지만 각각의 셀에 캡션을 제공할 수는 없습니다. 여기에 이미지 설명을 입력하세요

다음 코드를 사용했는데 그림에 표시된 대로만 캡션을 추가할 수 있었습니다. 친절하게 도와주세요.

\usepackage{pgf-pie}
\usepackage{tikz}
\usepackage{capt-of}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.8}
\newcommand\mycom[2]{\genfrac{}{}{0pt}{}{#1}{#2}}

\begin{document}

\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}

\begin{table}[h]
     \centering
     \begin{tabular}{|l|l|}
     \hline

\begin{tikzpicture}[scale=0.75,line join=round]
  \pie [rotate = 180]
    {57/A,
    5/B,
    3/C,
    9/D,
    3/E,
    22/F,
    1/G}
\end{tikzpicture}

&

\begin{tikzpicture}[scale=0.75,line join=round]
  \pie [rotate = 180]
    {60/A,
    5/B,
    2/C,
    10/D,
    2/E,
    20/F,
    1/G}
\end{tikzpicture}
\\ \hline
\end{tabular}
\captionof{figure}{Pie Chart}
\label{samples}
\end{table}

\end{document}

답변1

패키지 를 이용하시면 됩니다 subcaption. 그리고 내부 table를 사용한다고 해서 반드시 환경을 사용할 필요는 없습니다 tabular.

\documentclass{article}
\usepackage{array}
\usepackage{pgf-pie}
\usepackage{subcaption}

\begin{document}

\setlength{\abovedisplayskip}{3pt}
\setlength{\belowdisplayskip}{3pt}

\begin{figure}[h]
     \centering
     \begin{tabular}{|W{c}{0.45\textwidth}|W{c}{0.45\textwidth}|}
     \hline
\begin{subfigure}[b]{0.44\linewidth}
 \centering
 \begin{tikzpicture}[scale=0.75,line join=round]
  \pie [rotate = 180]
    {57/A,
    5/B,
    3/C,
    9/D,
    3/E,
    22/F,
    1/G}
 \end{tikzpicture}
 \caption{A pie chart.}
\end{subfigure}
&
\begin{subfigure}[b]{0.44\linewidth}
 \centering
 \begin{tikzpicture}[scale=0.75,line join=round]
  \pie [rotate = 180]
    {60/A,
    5/B,
    2/C,
    10/D,
    2/E,
    20/F,
    1/G}
 \end{tikzpicture}
 \caption{Another pie chart.}
\end{subfigure}
\\ \hline
\end{tabular}
\caption{Pie charts.}
\label{samples}
\end{figure}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보