我正在根据以下模板撰写论文,其中子表被检测为新表并从中递增,1.1
而不是标记为(a)
和(b)
。我不知道是什么阻止了这一点。
\documentclass[a4paper,oneside,12pt]{report}
\usepackage{float}
\usepackage{multirow}
\usepackage{subfigure}
\usepackage{array}
\usepackage{subfigure} %
\usepackage{amsmath}
\usepackage{subcaption}
\begin{document}
\chapter{INTRODUCTION}
\label{chapter:introduction}
\begin{table}[!htp]
\caption{Average ...}~\label{tab:mytable}
\begin{subtable}% {1\linewidth}
\centering
\begin{tabular}{|l|c|c|c|}
\hline
\textbf{Method} & \textbf{Gas Used} & \textbf{Ethereum} & \textbf{Polygon} \\
& \textbf{(gas)} & \textbf{USD cost} & \textbf{USD cost} \\
\hline
submitJob & 264967 & 7.04 & 0.019 \\ \hline
\end{tabular}
\caption{Obtained from A environment.}
\vspace{0.5cm}
\begin{tabular}{|l|c|c|c|}
\hline
\textbf{Method} & \textbf{Gas Used} & \textbf{Ethereum} & \textbf{Polygon} \\
& \textbf{(gas)} & \textbf{USD cost} & \textbf{USD cost} \\
\hline
updateProviderInfo & 33284 & 0.88 & 0.002 \\ \hline
\end{tabular}
\caption{Obtained from B platform.}
\end{subtable}%
\end{table}
\end{document}
输出:
想要的输出:
答案1
引用CTAN 页面包装内容subfigure
:
简而言之:不使用该subfigure
包。
以下解决方案使用了该subcaption
包。请注意,此包subtable
和subfigure
环境需要一个,强制的参数:预期宽度。对于当前的用例,我建议您使用\textwidth
(或等效地,\linewidth
)作为预期宽度。
\documentclass[a4paper,oneside,12pt]{report}
\usepackage{array} % for 'w' column type and '\extrarowheight' length parameter
\usepackage{subcaption}
\captionsetup[table]{skip=0.333\baselineskip}
% handy utility macro:
\newcommand\mytab[1]{\smash{%
\begin{tabular}[t]{@{}c@{}} #1 \end{tabular}}}
\newlength\mylen
\begin{document}
\setcounter{chapter}{1}
\begin{table}[!htp]
\settowidth\mylen{updateProviderInfo} % calculate target width of first column
\setlength\extrarowheight{2pt} % for a less-cramped look
\caption{Average ...} \label{tab:mytable}
\begin{subtable}{\linewidth}
\centering
\begin{tabular}{|wl{\mylen}|c|c|c|}
\hline
Method & \mytab{Gas Used\\(gas)}
& \mytab{Ethereum\\USD cost}
& \mytab{Polygon\\USD cost} \\
& & & \\ \hline
submitJob & 264967 & 7.04 & 0.019 \\ \hline
\end{tabular}
\medskip
\caption{Obtained from A environment.}
\end{subtable}
\bigskip
\begin{subtable}{\linewidth}
\centering
\begin{tabular}{|wl{\mylen}|c|c|c|}
\hline
Method & \mytab{Gas Used\\(gas)}
& \mytab{Ethereum\\USD cost}
& \mytab{Polygon\\USD cost} \\
& & & \\ \hline
updateProviderInfo & 33284 & 0.88 & 0.002 \\ \hline
\end{tabular}
\medskip
\caption{Obtained from B platform.}
\end{subtable}
\end{table}
\end{document}