第一次发帖,如有错误/遗漏信息,请谅解
我有一些回归表,我试图将它们作为单独的子表放在一个跨两页的表格中,同时使用 \threeparttable 在分开的表格的每个部分下添加注释。但如下例所示,编号仍然存在两个问题:(1) 表 1 后面是表 4,(2) 每个表格中的子表 b 后面是子表 c。这在一定程度上基于这些解决方案(1)但仍然不起作用......
谢谢,非常感谢您的帮助!!
\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}
不确定是否相关,但我在 Stata 中将表格生成为 .tex,然后使用 \input{} 将其包含在表格中。因此 example.tex 看起来像:
{
\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}
}
答案1
同时使用
threeparttable
在表格的每个部分下面都有注释
环境threeparttable
具有三个 [3] 个形式组件:(a)\caption
指令,(b)tabular
类环境(也可以是tabular*
或tabularx
环境),其中可能包含\tnote
指令,以及(c)tablenotes
环境,它是一个列表类环境,用于显示与每个 相关的文本\tnote
。使用环境的主要目的threeparttable
是确保标题和表格注释的宽度不超过类tabular
环境的宽度,同时允许最大程度地自由选择允许的脚注标记类型:它们可以是数字、字母(大写和小写)或纯符号(例如\dagger
)。当然,由用户(还有谁?)决定是否滥用机器所提供的权力threeparttable
。
简单来说,你不是适当地使用 theeparttable 机制。如果你真的想使用threeparttable
环境,那么应该使用它们里面环境subtable
。
幸运的是,你的“表格注释”的结构实际上足够简单,以至于根本不需要任何特殊的机制。只需输入
{\scriptsize\textit{Notes} table notes}
在每个 实例之前\end{table}
。请注意,这\scriptsize
是一个开关,即,它不接受由花括号分隔的参数。
\ContinuedFloat
顺便说一句,每个持续table
环境不需要多个指令。
\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}
答案2
只是为了好玩,我创建了一个与 subcaption 兼容的 threeparttable 替代品。
TableNotes 像 threeparttable 一样设置边距,但\Tnote
实际上会生成一个 minipage 脚注(看起来很相似)。我使用\subfloat
它来代替,\subtable
因为它更具挑战性。
我还添加了\Tnotemarks
允许任何所需符号作为脚注标记的功能。一旦超出列表,它将恢复为阿拉伯语(偏移)。
\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}