包含多个 tabularx 的 threeparttable 的标签编号

包含多个 tabularx 的 threeparttable 的标签编号

我的表格有子表,我使用tabularx。要为子表添加脚注,我使用threeparttable。但编号全乱了。(没有threeparttable,这个问题就消失了。)根据我的研究,此链接似乎是最接近的,但对我没用。有人能帮忙吗?这是我的感冒:

\documentclass[12pt]{article}

\usepackage{array, boldline}
\newcolumntype{Q}{>{\centering\arraybackslash}X}
\usepackage{booktabs}
\usepackage{subcaption} 
\usepackage{tabularx}   

\usepackage{threeparttable} 

\begin{document}

Table \ref{tab:US} is the demand and supply in the U.S. with tables \ref{tab:A-US} and \ref{tab:B-US} for market A and B in the U.S.
\begin{table}
\caption{Demand and Supply in the U.S.} \label{tab:US}
\begin{threeparttable}
\centering
\begin{subtable}{0.8\textwidth}
\caption{Market A} \label{tab:A-US}
\begin{tabularx}{\textwidth}{QQQ}
\toprule
Price & Demand & Supply \\
\cmidrule{2-3}
35\tnote{a} & 230 & 940 \\
30 & 410 & 750 \\ 
\bottomrule
\end{tabularx}
\end{subtable}\qquad
\begin{subtable}{0.8\textwidth}
\caption{Market B} \label{tab:B-US}
\begin{tabularx}{\textwidth}{QQQ}
\toprule
Price & Demand & Supply \\
\cmidrule{2-3}
35 & 300 & 800 \\
30 & 500 & 650 \\ 
\bottomrule
\end{tabularx}
\end{subtable}
\begin{tablenotes}
\footnotesize
\item[a] This is a price.
\end{tablenotes}
\end{threeparttable}
\end{table}



Table \ref{tab:canada} is the demand and supply in Canada with tables \ref{tab:A-canada} and \ref{tab:B-canada} for market A and B in Canada.
\begin{table}
\caption{Demand and Supply in Canada} \label{tab:canada}
\begin{threeparttable}
\centering
\begin{subtable}{0.8\textwidth}
\caption{Market AA} \label{tab:A-canada}
\begin{tabularx}{\textwidth}{QQQ}
\toprule
Price & Demand & Supply \\
\midrule
35\tnote{a} & 200 & 900 \\
30 & 400 & 750 \\ 
\bottomrule
\end{tabularx}
\end{subtable}\qquad
\begin{subtable}{0.8\textwidth}
\caption{Market BB} \label{tab:B-canada}
\begin{tabularx}{\textwidth}{QQQ}
\toprule
Price & Demand & Supply \\
\midrule
35 & 300 & 800 \\
30 & 500 & 650 \\ 
\bottomrule
\end{tabularx}
\end{subtable}
\begin{tablenotes}
\footnotesize
\item[a] This is a price.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}

答案1

我认为您没有threeparttable正确使用包装的机械装置。

环境threeparttable最多可以包含三个正式组件:标题、表格类型环境(此处:环境tabularx)和tablenotes环境。没有规定在环境subtable内部出现环境threeparttable。碰巧您的代码不会直接崩溃。但是,正如您所发现的,包含subtable环境确实有一个不好的副作用:表格和子表的编号会变得混乱。另一个表明事情不完全正确的指标是材料tablefootnote没有与环境的左边缘齐平tabularx

通常,threeparttable环境是嵌入在table环境中的。但是,它们也可以嵌入在subtable环境中。这就是以下示例中子表 1a 所追求的路线。

如果表格相关的脚注应专门且连续地标记为ab等,并且如果您不需要对基于表格的脚注材料应用花哨的格式,则在环境threeparttable内部署机器subtable可能会过度。由于subtable环境就是minipage环境,因此您可以使用\footnote指令,如下表 2a 所示。(可以通过更改 的定义来重置小页面特定的脚注标记的外观\thempfootnote。例如,告诉 LaTeX 使用直立字母字符;默认样式为斜体字母。您可能还想在 内\renewcommand{\thempfootnote}{\alph{mpfootnote}}运行。)\let\footnoterule\relaxsubtable

在此处输入图片描述

\documentclass[12pt]{article}

\usepackage{tabularx, boldline}
\newcolumntype{Q}{>{\centering\arraybackslash}X}
\usepackage{booktabs,subcaption,threeparttable} 
\usepackage{cleveref} % optional, for '\cref' and '\Cref' commands

\begin{document}

\Cref{tab:US} is the demand and supply in the U.S., with 
\cref{tab:A-US,tab:B-US} for markets A and B in the U.S.

\begin{table}[h!]
\centering
\caption{Demand and Supply in the U.S.} \label{tab:US}

\begin{subtable}{0.8\textwidth}
   \begin{threeparttable}
   \caption{Market A} \label{tab:A-US}
   \begin{tabularx}{\textwidth}{QQQ}
   \toprule
   Price & Demand & Supply \\
   \cmidrule{2-3}
   35\tnote{a} & 230 & 940 \\
   30 & 410 & 750 \\ 
   \bottomrule
   \end{tabularx}
   
   \smallskip\footnotesize
   \begin{tablenotes}
   \item[a] This is a price.
   \end{tablenotes}
   \end{threeparttable}
\end{subtable} 

\medskip
\begin{subtable}{0.8\textwidth}
   \caption{Market B} \label{tab:B-US}
   \begin{tabularx}{\textwidth}{QQQ}
   \toprule
   Price & Demand & Supply \\
   \cmidrule{2-3}
   35 & 300 & 800 \\
   30 & 500 & 650 \\ 
   \bottomrule
   \end{tabularx}
\end{subtable} 
\end{table}



\Cref{tab:canada} is the demand and supply in Canada, with 
\cref{tab:A-canada,tab:B-canada} for markets A and B in Canada.

\begin{table}[h!]
\caption{Demand and Supply in Canada} \label{tab:canada}
\centering

%% Note: No 'threepartable'-type directives in the following subtable:
\begin{subtable}{0.8\textwidth}
   \let\footnoterule\relax
   \renewcommand{\thempfootnote}{\alph{mpfootnote}} % upright-alph characters
   \caption{Market AA} \label{tab:A-canada}
   \begin{tabularx}{\textwidth}{QQQ}
   \toprule
   Price & Demand & Supply \\
   \midrule
   35\footnote{This is a price.} & 200 & 900 \\ % Note: \footnote, not \tnote
   30 & 400 & 750 \\ 
   \bottomrule
   \end{tabularx}
\end{subtable}

\medskip
   \begin{subtable}{0.8\textwidth}
   \caption{Market BB} \label{tab:B-canada}
   \begin{tabularx}{\textwidth}{QQQ}
   \toprule
   Price & Demand & Supply \\
   \midrule
   35 & 300 & 800 \\
   30 & 500 & 650 \\ 
   \bottomrule
   \end{tabularx}
\end{subtable}

\end{table}
\end{document}

答案2

目前我只有一个解决方法,类似于您链接的内容。不知何故\subtable似乎看不到它在表中,并增加了计数器。

\documentclass[12pt]{article}

\usepackage{array, boldline}
\newcolumntype{Q}{>{\centering\arraybackslash}X}
\usepackage{booktabs}
\usepackage{subcaption} 
\usepackage{tabularx}   

\usepackage{threeparttable} 

\begin{document}

Table \ref{tab:US} is the demand and supply in the U.S. with tables \ref{tab:A-US} and \ref{tab:B-US} for market A and B in the U.S.
\begin{table}
\caption{Demand and Supply in the U.S.} \label{tab:US}
\begin{threeparttable}
\centering\addtocounter{table}{-1}%
\begin{subtable}{0.8\textwidth}
\caption{Market A} \label{tab:A-US}
\begin{tabularx}{\textwidth}{QQQ}
\toprule
Price & Demand & Supply \\
\cmidrule{2-3}
35\tnote{a} & 230 & 940 \\
30 & 410 & 750 \\ 
\bottomrule
\end{tabularx}
\end{subtable}\qquad
\begin{subtable}{0.8\textwidth}
\caption{Market B} \label{tab:B-US}
\begin{tabularx}{\textwidth}{QQQ}
\toprule
Price & Demand & Supply \\
\cmidrule{2-3}
35 & 300 & 800 \\
30 & 500 & 650 \\ 
\bottomrule
\end{tabularx}
\end{subtable}
\begin{tablenotes}
\footnotesize
\item[a] This is a price.
\end{tablenotes}
\end{threeparttable}
\end{table}



Table \ref{tab:canada} is the demand and supply in Canada with tables \ref{tab:A-canada} and \ref{tab:B-canada} for market A and B in Canada.
\begin{table}
\caption{Demand and Supply in Canada} \label{tab:canada}
\begin{threeparttable}
\centering\addtocounter{table}{-1}%
\begin{subtable}{0.8\textwidth}
\caption{Market AA} \label{tab:A-canada}
\begin{tabularx}{\textwidth}{QQQ}
\toprule
Price & Demand & Supply \\
\midrule
35\tnote{a} & 200 & 900 \\
30 & 400 & 750 \\ 
\bottomrule
\end{tabularx}
\end{subtable}\qquad
\begin{subtable}{0.8\textwidth}
\caption{Market BB} \label{tab:B-canada}
\begin{tabularx}{\textwidth}{QQQ}
\toprule
Price & Demand & Supply \\
\midrule
35 & 300 & 800 \\
30 & 500 & 650 \\ 
\bottomrule
\end{tabularx}
\end{subtable}
\begin{tablenotes}
\footnotesize
\item[a] This is a price.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}

在此处输入图片描述

相关内容