정의되지 않은 하위 테이블

정의되지 않은 하위 테이블

아래 질문이 해결되었습니다. 스크립트가 편집되었습니다.

이 포럼에서 하위 테이블 템플릿을 찾았지만 오류 없이 실행할 수 없습니다. 이 문제를 어떻게 해결할 수 있나요?

오류 메시지:

! LaTeX Error: Environment subtable undefined.
! Missing number, treated as zero.
! Illegal unit of measure (pt inserted).
! LaTeX Error: \begin{table} on input line 164 ended by \end{subtable}.

MWE:

\documentclass{article}
\usepackage{subfig}
\usepackage{array, booktabs, caption}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{xcolor}
\usepackage{subcaption}
\usepackage{pgfplots}
\usepackage{tikz}
\definecolor{bblue}{HTML}{4F81BD}
\definecolor{rred}{HTML}{C0504D}
\definecolor{ggreen}{HTML}{9BBB59}
\definecolor{ppurple}{HTML}{9F4C7C}

\begin{document}
\begin{table}   
\centering
\begin{subtable}{.5\textwidth}
\centering
\begin{tikzpicture}
    \begin{axis}[
        width  = 1.3*\textwidth,
        height = 8cm,
        enlarge y limits={upper, value=0.4},
        ymin=0,
        major x tick style = transparent,
        ybar=2*\pgflinewidth,
        bar width=20pt,
        ymajorgrids = true,
        ylabel = {\%},
        symbolic x coords={A,B,C},
        xtick = data,
        nodes near coords,
        scaled y ticks = false,
        enlarge x limits=0.25,
        ymin=0,
        legend cell align=left,
        legend style={
                at={(1,1.05)},
                anchor=south east,
                column sep=1ex
        }
    ]
        \addplot[style={bblue,fill=bblue,mark=none]}]
            coordinates {(A, 100) (B,100) (C,100)};

        \addplot[style={rred,fill=rred,mark=none}]
             coordinates {(A, 106) (B,113) (C,177)};
        \legend{MADYMO,Vivo}
    \end{axis}
\end{tikzpicture}
\caption{Phase 1}
\end{subtable}
\begin{subtable}{.5\textwidth}
\centering 
\begin{tikzpicture}
    \begin{axis}[
        width  = 1.3*\textwidth,
        height = 8cm,
        enlarge y limits={upper, value=0.4},
        ymin=0,
        major x tick style = transparent,
        ybar=2*\pgflinewidth,
        bar width=20pt,
        ymajorgrids = true,
        ylabel = {\%},
        symbolic x coords={A,B,C},
        xtick = data,
        nodes near coords,
        scaled y ticks = false,
        enlarge x limits=0.25,
        ymin=0,
        legend cell align=left,
        legend style={
                at={(1,1.05)},
                anchor=south east,
                column sep=1ex
        }
    ]
        \addplot[style={ggreen,fill=ggreen,mark=none]}]
            coordinates {(A, 100) (B,100) (C,100)};

        \addplot[style={ppurple,fill=ppurple,mark=none}]
             coordinates {(A, 98) (B,113) (C,178)};
        \legend{X,Y}
    \end{axis}
\end{tikzpicture}
\caption{Phase 2}
\end{subtable}
\caption{aaaaaaa}
\label{tab:EmMaxPE_bar_X}
\end{table}
\end{document}

답변1

(참고: 이 질문을 게시했습니다.~ 전에OP는 쿼리에 몇 가지 실질적인 편집을 적용했습니다. 예를 들어 subcaption쿼리의 초기 형태로는 환경이 로드되지 않았고, 환경의 중요한 측면에 대한 정보가 없었습니다 tikzpicture.)

환경을 사용하려면 패키지 subtable를 로드해야 합니다 subcaption. 패키지 subfig~ 아니다환경 을 제공합니다 subtable.

다음 예에서는 설명을 단순화하기 위해 두 tikzpicture환경을 더미 환경으로 대체했습니다 . tabular(또한 당신은 표시하지 않았습니다어느tikz 관련 패키지를 로드해야 하거나 어떻게 정의해야 하는지 등 rredbblue정의해야 합니다.) 나란히 맞추려면 %첫 번째 환경 바로 뒤에 (주석) 문자를 삽입해야 한다는 점에 유의하세요.subtable

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

\documentclass{article}
\usepackage{subcaption,booktabs}
\begin{document}

\begin{table}   
%\centering  <--- not needed!
\begin{subtable}{.5\textwidth}
\centering
   % dummy 'tabular' env.
   \begin{tabular}{lll}
   \toprule
   aaa bbb ccc\\
   \bottomrule
   \end{tabular}
\caption{Phase 1}
\end{subtable}% <--- new
\begin{subtable}{.5\textwidth}
\centering 
   % dummy 'tabular' env.
   \begin{tabular}{lll}
   \toprule
   xxx yyy zzz\\
   \bottomrule
   \end{tabular}
\caption{Phase 2}
\end{subtable}
\caption{aaaaaaa} \label{tab:EmMaxPE_bar_X}
\end{table}
\end{document}

관련 정보