![如何強制子表的標題從 (a) 開始?](https://rvso.com/image/476260/%E5%A6%82%E4%BD%95%E5%BC%B7%E5%88%B6%E5%AD%90%E8%A1%A8%E7%9A%84%E6%A8%99%E9%A1%8C%E5%BE%9E%20(a)%20%E9%96%8B%E5%A7%8B%EF%BC%9F.png)
我正在以下範本的基礎上撰寫我的論文,其中子表檢測為新表並從 和 遞增,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}