
以下の質問は解決されました。スクリプトは編集されました。
このフォーラムからサブテーブルのテンプレートを見つけましたが、エラーなしで実行できません。どうすれば解決できますか?
エラーメッセージ:
! 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
。
以下の例では、説明を簡略化するために、 2つのtikzpicture
環境をダミー環境に置き換えました。(また、tabular
どれのtikz 関連のパッケージをロードする必要があるかrred
、bblue
または、などが定義されているかによって異なります。並べて表示したい場合は、%
最初の環境の直後に (コメント) 文字を挿入する必要があることに注意してください。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}