如何強制子表的標題從 (a) 開始?

如何強制子表的標題從 (a) 開始?

我正在以下範本的基礎上撰寫我的論文,其中子表檢測為新表並從 和 遞增,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] 套件現在被認為已過時:它已被取代子圖,但用戶可能會發現更新的副標題包包比較滿意。

簡而言之:使用該subfigure包。

以下解決方案使用了該subcaption套件。請注意,此包subtablesubfigure環境採用一個,強制的參數:預期的寬度。對於目前的用例,我建議您使用\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}

相關內容