2

My tables have subtables, for which I'm using tabularx. To add footnote to the subtables, I'm using threeparttable. But the numbering is all messed up. (Without threeparttable, this issue is gone.) According to my research, this link seems to be the closest, but wasn't helpful for me. Can anyone help please? Here is my cold:

\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}

2 Answers 2

2

I don't think you're using the machinery of the threeparttable package appropriately.

A threeparttable environment can have up to three formal components: a caption, a tabular-type environment (here: a tabularx environment), and a tablenotes environment. There is no provision for subtable environments occurring inside threeparttable environments. It so happens that your code doesn't crash outright. However, as you've discovered, including subtable environments does have a bad side-effect: the numbering of the tables and subtables gets messed up. Another indicator of things not being entirely correct is the fact that the tablefootnote material isn't being placed flush with the left-hand edge of the tabularx environments.

Usually, threeparttable environments are embedded in table environments. However, they can just as well be embedded in subtable environments. That's the route pursued in subtable 1a in the following example.

If the tabular-related footnotes should be labeled exclusively and consecutively as a, b, etc., and if you don't need to apply fancy formatting to the table-based footnote material, deploying the threeparttable machinery inside subtable environments may amount to overkill. As subtable environments are minipage environments, you can make do with \footnote directives, as is shown in subtable 2a below. (The appearance of the minipage-specific footnote markers may be reset by changing the definition of \thempfootnote. E.g., \renewcommand{\thempfootnote}{\alph{mpfootnote}} tells LaTeX to use upright-alphabetic characters; the default style is italic-alphabetic. You will probably also want to run \let\footnoterule\relax inside the subtable.)

enter image description here

\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}
1
  • Thanks very much, Mico!
    – ppp
    Jun 13, 2020 at 0:33
1

At this point I only have a workaround, similar to what you link to. Somehow \subtable does not seem to see that it is in a table, and increases the counter.

\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}

enter image description here

2
  • A give-away that more than the table and subtable numbering is messed up is the fact that the material of the tablenotes environments is not placed correctly, i.e., not flush with the associated tabularx environment. I believe that unless one is willing to rewrite major portions of the threeparttable code, one shouldn't place subtable environments inside threeparttable environments.
    – Mico
    Jun 11, 2020 at 6:08
  • Thanks so much!
    – ppp
    Jun 11, 2020 at 17:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .