我正在使用书籍文档类,我想知道如何为节.表.子表格式的子表(通常在同一节中)制作像 1.1.a.、1.1.b 这样的表格编号样式?制作子表的目的只是为了分别解释它们。
\documentclass{book}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{txfonts}
\usepackage{mathdots}
\usepackage[classicReIm]{kpfonts}
\begin{document}
\chapter{Some chapter}
\section{Some section}
\noindent First subtable
\begin{table}[h]
\centering
\caption{a}
\begin{tabular}{|p{0.2in}|p{0.8in}|p{0.8in}|p{0.8in}|p{0.7in}|} \hline
& $\mathrm{\spadesuit}$ & $\mathrm{\varheartsuit}$ & $\mathrm{\vardiamondsuit}$ & $\mathrm{\clubsuit}$ \\
\hline
1. & A & K & 9 & K \\
\hline
\end{tabular}
\end{table}
\noindent Another subtable
\begin{table}[h]
\centering
\caption{b}
\begin{tabular}{|p{0.2in}|p{0.8in}|p{0.8in}|p{0.8in}|p{0.7in}|} \hline
& $\mathrm{\spadesuit}$ & $\mathrm{\varheartsuit}$ & $\mathrm{\vardiamondsuit}$ & $\mathrm{\clubsuit}$ \\
\hline
2. & A & B & C & D \\
\hline
\end{tabular}
\end{table}
\end{document}
答案1
以下是两个没有共享标题的版本:
\documentclass{book}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{txfonts}
\usepackage{mathdots}
\usepackage[classicReIm]{kpfonts}
\usepackage{subcaption,array}
\DeclareCaptionSubType*[alph]{table}
\DeclareCaptionLabelFormat{mystyle}{Table~\bothIfFirst{#1}{ }#2}
\captionsetup[subtable]{labelformat=mystyle}
\begin{document}
\chapter{Some chapter}
\section{Some section}
\begin{table}[htbp]
\begin{subtable}{0.475\linewidth}
\centering
\caption{subcaption} \label{subtab:left}
\begin{tabular}{|wl{0.1in}|wl{0.3in}|wl{0.3in}|wl{0.3in}|wl{0.3in}|}
\hline
& $\mathrm{\spadesuit}$ & $\mathrm{\varheartsuit}$ & $\mathrm{\vardiamondsuit}$ & $\mathrm{\clubsuit}$ \\
\hline
1. & A & K & 9 & K \\
\hline
\end{tabular}
\end{subtable}\hfill
\begin{subtable}{0.475\linewidth}
\centering
\caption{subcaption} \label{subtab:right}
\begin{tabular}{|wl{0.1in}|wl{0.3in}|wl{0.3in}|wl{0.3in}|wl{0.3in}|}
\hline
& $\mathrm{\spadesuit}$ & $\mathrm{\varheartsuit}$ & $\mathrm{\vardiamondsuit}$ & $\mathrm{\clubsuit}$ \\
\hline
1. & A & K & 9 & K \\
\hline
\end{tabular}
\end{subtable}
\end{table}
Reference to first subtable: \ref{subtab:left}
Reference to second subtable: \ref{subtab:right}
\newpage
First subtable
\begin{table}[htbp]
\begin{subtable}{\linewidth}
\centering
\caption{caption text} \label{subtab:upper}
\begin{tabular}{|p{0.2in}|p{0.8in}|p{0.8in}|p{0.8in}|p{0.7in}|} \hline
& $\mathrm{\spadesuit}$ & $\mathrm{\varheartsuit}$ & $\mathrm{\vardiamondsuit}$ & $\mathrm{\clubsuit}$ \\
\hline
1. & A & K & 9 & K \\
\hline
\end{tabular}
\end{subtable}
\end{table}
Another subtable
\begin{table}[htbp]
\ContinuedFloat
\begin{subtable}{\linewidth}
\centering
\caption{caption text} \label{subtab:lower}
\begin{tabular}{|p{0.2in}|p{0.8in}|p{0.8in}|p{0.8in}|p{0.7in}|} \hline
& $\mathrm{\spadesuit}$ & $\mathrm{\varheartsuit}$ & $\mathrm{\vardiamondsuit}$ & $\mathrm{\clubsuit}$ \\
\hline
2. & A & B & C & D \\
\hline
\end{tabular}
\end{subtable}
\end{table}
Reference to first subtable: \ref{subtab:upper}
Reference to second subtable: \ref{subtab:lower}
\end{document}