1

First time posting so apologies if any mistakes/ommitted info

I have some regression tables that I am trying to put as separate subtables within a table that spans over two pages, while using \threeparttable to have notes under each portion of the tables that are separated. But as the example below shows, there are still two problems, with the numbering: (1) Table 1 is followed by Table 4 and (2) Subtable b within each table is followed by Subtable c. This was based somewhat on these solutions (1) but still not working...

Thank you, any help is much appreciated!!

\documentclass[a4, 12pt]{article}

\usepackage{tabularx} \usepackage[flushleft]{threeparttable} \usepackage{floatrow} \floatsetup[table]{style=plaintop} \usepackage{subcaption}

\pagestyle{plain}

\usepackage[tablename=Table]{caption} \DeclareCaptionTextFormat{up}{#1} % \MakeTextUppercase \captionsetup[table]{ labelsep=period, justification=centering, textformat=up, }

\begin{document}

Some text, for example noting the numbers in the tables are nonsense

% First table with subtitles \begin{table} [htp] \caption{Main table title}\label{tab:main} % \centering \begin{threeparttable} \footnotesize \begin{subtable}[c]{\textwidth} \centering \caption{Subtitle 1} \input{tables/example} \vspace{3mm}
\end{subtable} \
\begin{subtable}[c]{\textwidth} \centering \caption{Subtitle 2} \input{tables/example} \vspace{3mm} \end{subtable}
\end{threeparttable} \begin{tablenotes}[flushleft] \item \scriptsize{\textit{Notes:} table notes} \end{tablenotes} \end{table}

\begin{table} [htp] \ContinuedFloat % If possible it would be great here to have the same main table title as above but with the appended text "contd." \centering \begin{threeparttable} \footnotesize \begin{subtable}[c]{\textwidth} \centering \ContinuedFloat \caption{Subtitle 3} \input{tables/example} \vspace{3mm} \end{subtable} \
\begin{subtable}[c]{\textwidth} \centering \caption{Subtitle 4} \input{tables/example} \vspace{3mm} \end{subtable}
\end{threeparttable} \begin{tablenotes}[flushleft] \item \scriptsize{\textit{Notes:} table notes} \end{tablenotes} \end{table}

More text noting the numbers in the tables are the same and still nonsense

% Second table with subtitles \begin{table} [htp] \caption{Main table title}\label{tab:main} \centering \begin{threeparttable} \footnotesize \begin{subtable}[c]{\textwidth} \centering \caption{Subtitle 1} \input{tables/example} \vspace{3mm}
\end{subtable} \
\begin{subtable}[c]{\textwidth} \centering \caption{Subtitle 2} \input{tables/example} \vspace{3mm} \end{subtable}
\end{threeparttable} \begin{tablenotes}[flushleft] \item \scriptsize{\textit{Notes:} table notes} \end{tablenotes} \end{table}

\begin{table} [htp] \ContinuedFloat % If possible it would be great here to have the same main table title as above but with the appended text "contd." \centering \begin{threeparttable} \footnotesize \begin{subtable}[c]{\textwidth} \centering \ContinuedFloat \caption{Subtitle 3} \input{tables/example} \vspace{3mm} \end{subtable} \
\begin{subtable}[c]{\textwidth} \centering \caption{Subtitle 4} \input{tables/example} \vspace{3mm} \end{subtable}
\end{threeparttable} \begin{tablenotes}[flushleft] \item \scriptsize{\textit{Notes:} table notes} \end{tablenotes} \end{table}

\end{document}

Not sure if it relevant, but I am generating my tables as a .tex in Stata then including in table using \input{}. So then example.tex looks like:

{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{tabular}{l*{6}{c}}
\hline\hline
                     &\multicolumn{2}{c}{model group 1}             &\multicolumn{2}{c}{model group 2}           &\multicolumn{2}{c}{model group 3}    \\
                    &\multicolumn{1}{c}{(1)}         &\multicolumn{1}{c}{(2)}         &\multicolumn{1}{c}{(3)}         &\multicolumn{1}{c}{(4)}         &\multicolumn{1}{c}{(5)}         &\multicolumn{1}{c}{(6)}         \\
\hline
Foo=1&       1.571         &       1.578         &       1.551\sym{***}&       1.177\sym{**} &      1.157         &       1.665         \\
                    &     (1.918)         &     (1.565)         &     (1.986)         &     (1.919)         &     (1.771)         &     (1.567)         \\
Goo&      -1.111         &      -1.111         &       1.119\sym{**} &       1.117         &       1.115\sym{**} &       1.116\sym{**} \\
                    &     (1.117)         &     (1.117)         &     (1.117)         &     (1.117)         &     (1.116)         &     (1.116)         \\
Foo=1 $\times$ Goo&      -1.115         &      -1.115         &      -1.111\sym{***}&      -1.111\sym{***}&      -1.117\sym{***}&      -1.118\sym{***}\\
                    &     (1.115)         &     (1.115)         &     (1.115)         &     (1.115)         &     (1.115)         &     (1.115)         \\
\hline
Some FE    &           Y         &           Y         &           Y         &           Y         &           Y         &           Y         \\
Var1       &           N         &           Y         &           N         &           Y         &           N         &           Y         \\
\hline\hline
\multicolumn{7}{l}{\footnotesize text}\\
\multicolumn{7}{l}{\footnotesize * p $<$ 1.11, ** p $<$ 1.15, *** p $<$ 1.11}\\
\end{tabular}
}

JacobG
  • 13

2 Answers2

0

Just for fun, I created an alternative to threeparttable which is compatible with subcaption.

TableNotes sets the margins like threeparttable, but \Tnote actually generates a minipage footnote (look alike). I used \subfloat instead of \subtable as it is more of a challenge.

I also added \Tnotemarks to allow any desired symbols as footnote marks. Once the list is exceeded, it reverts to arabic (offset).

\documentclass[a4paper, 12pt]{article}

\usepackage{tabularx} \usepackage{subcaption}

\pagestyle{plain}

\usepackage[tablename=Table]{caption} \DeclareCaptionTextFormat{up}{#1} % \MakeTextUppercase \captionsetup[table]{ labelsep=period, justification=centering, textformat=up, } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \Tnote %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{environ} \usepackage{varwidth} \usepackage{xparse} \makeatletter \newsavebox{\Tnotebox} \newcommand{\TN@Tnote}[2][0]{% #1 = count (optonal), #2 = note \count1=#1\relax \ifnum\count1=0\relax \footnotemark \global\setbox\Tnotebox=\vbox{@parboxrestore \unvbox\Tnotebox \normalfont\footnotesize \makebox[\Tnotewidth][r]{\footnotemark[\c@footnote]}#2\strut}% \else \footnotemark[#1]% \global\setbox\Tnotebox=\vbox{@parboxrestore \unvbox\Tnotebox \normalfont\footnotesize \makebox[\Tnotewidth][r]{\footnotemark[#1]}#2\strut}% \fi} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \Tnotemarks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\Tnotemax}{0} \newcommand{\Tnotewidth}{1em} \newcommand{\Tnotemarks}[1]% #1 = list of comma delimited symbols {\bgroup \dimen0=1em \count1=0 @Tnotemarks#1,\empty, \xdef\Tnotemax{\number\count1}% \xdef\Tnotewidth{\the\dimen0}% \egroup} \def\quark{\quark} \def@Tnotemarks#1,{\ifx\empty#1\relax \else \advance\count1 by 1 \settowidth{\dimen1}{\textsuperscript{#1}}% \ifdim\dimen1>\dimen0 \dimen0=\dimen1 \fi \expandafter\gdef\csname Tnotemark\number\count1\endcsname{#1}% \expandafter@Tnotemarks \fi} % \newcommand{\Tnotemark}{% \ifnum\c@footnote>\Tnotemax\relax \advance\c@footnote by -\Tnotemax @arabic\c@footnote \advance\c@footnote by \Tnotemax \else \ifnum\c@footnote>0\relax \csname Tnotemark\arabic{footnote}\endcsname \fi \fi} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TableNotes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand{\captiongobble}[2][]{\par} \AtBeginDocument{@ifundefined{subfloat}{\global\let\normalsubfloat=\relax}% {\global\let\normalsubfloat=\subfloat}}% for out of order packages \NewDocumentCommand{\subfloatgobble}{oom}{\normalsubfloat{#3}}% no caption \newcommand{\Tmarkgobble}[1][]{}% do not increment footnote counter \newlength{\TNwidth} % \NewEnviron{TableNotes}[1][0pt]{% #1 = width (optional) \setlength{\TNwidth}{#1}% \ifdim\TNwidth>0pt \else \sbox0{\begin{varwidth}{\linewidth}% measure width \let\Tnote=\captiongobble \let\Tmark=\Tmarkgobble \let\caption=\captiongobble \let\subfloat=\subfloatgobble \let\label=@gobble \BODY \end{varwidth}}% \TNwidth=\wd0 \fi \centering \begin{minipage}{\TNwidth} \let\Tnote=\TN@Tnote \let\Tmark=\footnotemark \let\thefootnote=\Tnotemark \BODY \par\vskip\skip@mpfootins \footnoterule \unvbox\Tnotebox \end{minipage}\par } \makeatother %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{showframe}

\begin{document} \Tnotemarks{,*}

\begin{table} [htp] \begin{TableNotes} \caption{Main table title}\label{tab:main} \centering \subfloat[]{\begin{tabular}{c} \hline This is a test\Tnote{Footnote 1}\ \hline \end{tabular}}

\subfloat[]{\begin{tabular}{c}
  \hline
  This is a test\Tnote{Footnote 2}\\
  This is a repeat\Tmark[1]\\
  \hline
\end{tabular}}

\end{TableNotes} \end{table}

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • "Frankly, I always thought they could have done a better job." Well, I would not blame the author(s) of the threeparttable package for a case of complete and utter misuse of the package's machinery. It's sort of like blaming Ferrari (the company) for a testarossa driver not obeying a town's posted speed limit... – Mico Mar 29 '24 at 18:51
  • 1
    @Mico - I meant they could have actually implemented footnotes instead of using separate \tfoot (footnote marks) and an itemized list. It would take an environ if you don't know the width. – John Kormylo Mar 29 '24 at 20:12
  • The beauty of threeparttable is that it lets users employ numeric, alphabetic, and symbolic footnote markers all at once, in one and the same tabular-like environment. Natuarally, it's up to the user not to abuse this power. Of course, the OP doesn't appear to use any \tnote directives at all, begging the question as to why they employ a threeparttable to begin with. – Mico Mar 29 '24 at 20:14
0

while using threeparttable to have notes under each portion of the tables that are separated

A threeparttable environment has three [3] formal components: (a) A \caption directive, (b) a tabular-like environment (it could also be a tabular* or tabularx environment) which may contain \tnote directives, and (c) a tablenotes environment, which is a list-like environment to show the texts associated with each \tnote. The main purpose of using a threeparttable environment is to assure that the widths of the caption and table notes do not exceed the width of the tabular-like environment, while allowing maximum freedom regarding the types of allowable footnote markers: They can be numeric, alphabetic (upper- and lowercase), or purely symbolic (e.g., \dagger). Naturally, it's up to the user (who else?) not to misuse the power afforded by the threeparttable machinery.

Simply put, you are not using the theeparttable machinery appropriately. If you really wanted to use threeparttable environments, they should be used inside the subtable environments.

Fortunately, the structure of your "table notes" is actually sufficiently simple so as not to require any special machinery at all. Just type

{\scriptsize\textit{Notes} table notes}

right before each instance of \end{table}. Do note that \scriptsize is a switch, i.e., it does not take an argument delimited by curly braces.

Incidentally, there's no need for more than one \ContinuedFloat directive per continued table environment.

enter image description here

\documentclass[a4paper, 12pt]{article}

\usepackage[tablename=Table]{caption} \DeclareCaptionTextFormat{up}{#1} % \MakeTextUppercase \captionsetup[table]{ labelsep=period, justification=centering, textformat=up, } \usepackage{subcaption}

\begin{document}

\noindent Some text, for example noting the numbers in the tables are nonsense

% First table \begin{table}[htp] \caption{Main table title}\label{tab:main1} \footnotesize \begin{subtable}{\textwidth} \centering \caption{Subtitle 1} %\input{tables/example11}
\end{subtable}

\vspace{3mm}  
\begin{subtable}{\textwidth}
    \centering
    \caption{Subtitle 2}
    %\input{tables/example12}
\end{subtable}  

{\scriptsize\textit{Notes} table notes} \end{table}

\begin{table} [htp] \ContinuedFloat \caption*{Table \thetable, continued} \footnotesize \begin{subtable}{\textwidth} \centering \caption{Subtitle 3} %\input{tables/example13} \end{subtable}

\vspace{3mm}  
\begin{subtable}{\textwidth}
    \centering
    \caption{Subtitle 4}
    %\input{tables/example14}
\end{subtable}  

{\scriptsize\textit{Notes} table notes} \end{table}

\noindent More text noting the numbers in the tables are the same and still nonsense

% Second table \begin{table} [htp] \caption{Another main table title}\label{tab:main2} \footnotesize

\begin{subtable}{\textwidth}
    \centering
    \caption{Subtitle 1}
    %\input{tables/example21}
\end{subtable}

\vspace{3mm}   
\begin{subtable}{\textwidth}
    \centering
    \caption{Subtitle 2}
    %\input{tables/example22}
\end{subtable}  

{\scriptsize\textit{Notes} table notes} \end{table}

\begin{table} [htp!] \ContinuedFloat \caption*{Table \thetable, continued} \footnotesize \begin{subtable}{\textwidth} \centering \caption{Subtitle 3} %\input{tables/example23} \end{subtable}

\vspace{3mm} 
\begin{subtable}{\textwidth}
    \centering
    \caption{Subtitle 4}
    %\input{tables/example24}
\end{subtable}  

{\scriptsize\textit{Notes} table notes} \end{table}

\end{document}

Mico
  • 506,678
  • Thank you, this worked perfectly! Only addition I needed to make, in order to have the "table notes" not centered as well but left aligned (which I did not specify requiring), was to include \raggedright in the line between \end{subtable} and {\scriptsize\textit{Notes} table notes} – JacobG Mar 29 '24 at 23:21