
La siguiente pregunta ha sido resuelta. El guión ha sido editado.
Encontré una plantilla de subtabla en este foro, pero no puedo ejecutarla sin errores. ¿Como puedo resolver esto?
Mensaje de error:
! 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}
Respuesta1
(Observación: publiqué esta preguntaantesel OP aplicó varias ediciones sustanciales a la consulta. Por ejemplo, el subcaption
entorno no se cargaba en la forma inicial de la consulta y no había información sobre aspectos importantes de los tikzpicture
entornos).
Para utilizar subtable
entornos, debe cargar el subcaption
paquete. El subfig
paquete lo hacenoproporcionar un subtable
ambiente.
En el siguiente ejemplo, reemplacé los dos tikzpicture
entornos con tabular
entornos ficticios para simplificar la exposición. (Además, no indicastecualLos paquetes relacionados con tikz deben cargarse o cómo se definen rred
, bblue
etc.). Observe que debe insertar un %
carácter (comentario) inmediatamente después del primer subtable
entorno si desea que quepan uno al lado del otro.
\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}