我正在使用 threepart 表格环境来创建表格。我用它tablenotes
来做表格注释。但是,表格注释超出了表格宽度。我该如何将注释包含在表格宽度内。我还用它flushleft
来做左对齐。以下是表格注释的部分代码:
\begin{tablenotes}[flushleft]
\small
\item\leavevmode\kern-\scriptspace\kern-\labelsep \textit{Notes:} Table Notes. Standard errors clustered at the XXXXX level. */**/*** denotes significance at the 10/5/1 percent levels.
\item hgahgalhgalghlsghslhga hglahlllllll lllllllllll llllllllllllllllllll lllllllllllllllhalhgaghal halghalgha galghalhg
\end{tablenotes}
\end{threeparttable}
完整 MWE
\documentclass[11pt]{article}
\usepackage{etex}
\usepackage{palatino}
\usepackage[bottom,hang,flushmargin]{footmisc}
\usepackage[usenames,dvipsnames]{color}
\usepackage{xr-hyper}
%\usepackage[pdfborder={0 0 0}, bookmarksnumbered=true, bookmarksopenlevel=1, colorlinks=true, linkcolor=BrickRed, urlcolor=BrickRed, citecolor=Blue, hyperfootnotes=false]{hyperref}
\usepackage[pdfborder={0 0 0}, bookmarksnumbered=true, bookmarksopenlevel=1, colorlinks=true, allcolors=BrickRed, citecolor=Blue, hyperfootnotes=false]{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{array}
%\usepackage[blocks, auth-sc, affil-it]{authblk}
\usepackage{bbm}
\usepackage{caption}
\usepackage{datetime}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{epsf}
\usepackage{epstopdf}
\usepackage{fancyhdr}
%\usepackage{float}
\usepackage{floatrow}
\usepackage{multicol}
\usepackage{multirow}
\usepackage[round]{natbib}
\usepackage{setspace}
%\usepackage[position=top]{subfig}
\usepackage{lscape}
\usepackage{placeins}
\usepackage{pdfpages}
\usepackage{pgffor}
\usepackage{pdflscape}
\usepackage{tikz}
\usepackage{ctable}
\usepackage{verbatim}
\usepackage[margin=2cm]{geometry}
\usepackage[normalem]{ulem}
\usepackage{booktabs}
\usepackage{bigdelim}
\usepackage{tocloft}
\usepackage{threeparttable}
\usepackage{adjustbox}
\captionsetup{margin=10pt,font=large,labelfont={bf,large},position=below,justification=justified}
%\usepackage{etoc}
%\externaldocument{MigSim_Appendix_Final}
%\setlength{\affilsep}{0pt}
%\usepackage{geometry}
%\geometry{left=.95in,right=.95in,top=.925in,bottom=.925in}
%\usepackage{titling}
%\settowidth{\thanksmarkwidth}{*}
%\setlength{\thanksmargin}{-\thanksmarkwidth}
\newcommand{\nocontentsline}[3]{}
\newcommand{\tocless}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}\egroup}
\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}}
\DeclareRobustCommand{\prob}[1][P]{\ensuremath {\mathbb{#1}}}
\DeclareRobustCommand{\expect}[0]{{\mathbb E}}
\DeclareRobustCommand{\variance}[0]{{\mathbb V}}
\DeclareRobustCommand{\indicator}[0]{{\mathbbm 1}}
\newcommand{\Var}{\mathbb{V}}
\newcommand{\Cov}{\mathbb{C}}
\newcommand{\var}{\mathrm{Var}}
\newcommand{\cov}{\mathrm{Cov}}
\newcommand{\plim}{\mathrm{plim}}
\newcommand{\indep}{\perp\!\!\!\perp}
%\renewcommand{\sout}{\vphantom}
%\renewcommand*\thetable{\Roman{table}}
%\renewcommand*\thefigure{\Roman{figure}}
\newcommand{\ag}{\color{OliveGreen}}
\newcommand{\agt}[1]{{\color{OliveGreen}#1}}
\newcommand{\agst}[1]{{\color{OliveGreen}\sout{#1}}}
\newcommand{\mpc}{\color{Red}}
\newcommand{\mpt}[1]{{\color{Red}#1}}
\newcommand{\mpst}[1]{{\color{Red}\sout{#1}}}
\renewcommand{\cftbeforesubsecskip}{5pt}
\renewcommand{\cftsecfont}{\normalfont\scshape}
\renewcommand{\cftsubsecfont}{\normalfont\bfseries}
\newdateformat{monthyeardate}{\monthname[\THEMONTH] \THEYEAR}
\newcommand{\stoptocwriting}{%
\addtocontents{toc}{\protect\setcounter{tocdepth}{-5}}}
\newcommand{\resumetocwriting}{%
\addtocontents{toc}{\protect\setcounter{tocdepth}{\arabic{tocdepth}}}}
\providecommand\phantomsection{}
\newtheorem{lemma}{Lemma}[section]
\newtheorem{theorem}[lemma]{Theorem}
\newtheorem{assumption}[lemma]{Assumption}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\newcommand{\seper}{\setlength{\itemsep}}
\floatsetup[table]{style=plaintop}
\begin{table}[htbp!]
\begin{threeparttable}[b]
\caption{Treatment Effects With New Strategy}
\scalebox{0.75}{
\begin{tabular}{@{\extracolsep{8pt}}lccccccccc@{}} \hline
\multicolumn{1}{l}{} &
\multicolumn{3}{c}{Avg Test Score} &
\multicolumn{3}{c}{Avg Passing Rate} &
\multicolumn{3}{c}{Avg Participation Rate} \\\\
\cline{2-4}
\cline{5-7}
\cline{8-10}
VARIABLES & Male & Female & All & Male & Female & All & Male & Female& All \\
& (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) \\
\hline
& & & & & & & & &\\
Treatment & -26.21 & -22.18 & 34.08* & 35.83* & -59.34* & 17.13 & -26.21 & 9.84 & -8.46 \\
& [-2.02] & [-0.50] & [2.42] & [2.23] & [-2.46] & [1.22] & [-2.02] & [1.24] & [-0.78] \\
& (13.00) & (44.77) & (14.06) & (16.04) & (24.12) & (14.03) & (13.00) & (7.93) & (10.82) \\
Post & -26.50** & -25.47 & -11.53 & 40.49***& 52.71***& 52.68***& -26.50** & 2.28 & -16.49* \\
& [-3.52] & [-1.35] & [-1.34] & [4.36] & [5.18] & [6.15] & [-3.52] & [0.68] & [-2.49] \\
& (7.52) & (18.90) & (8.59) & (9.28) & (10.18) & (8.57) & (7.52) & (3.35) & (6.61) \\
DiD & 29.65* & 31.22 & 5.33 & 9.17 & 141.80** & 11.56 & 29.65* & -15.08 & 1.07 \\
& [2.13] & [0.39] & [0.32] & [0.53] & [3.25] & [0.70] & [2.13] & [-1.05] & [0.08] \\
& (13.89) & (80.90) & (16.45) & (17.14) & (43.58) & (16.42) & (13.89) & (14.34) & (12.67) \\
Constant & 42.02 & 271.27* & 222.43***& 65.29* & -23.66 & -38.16 & 42.02 & 23.55 & -46.42 \\
& [1.87] & [2.58] & [6.20] & [2.36] & [-0.42] & [-1.07] & [1.87] & [1.26] & [-1.68] \\
& (22.46) & (105.12) & (35.85) & (27.71) & (56.63) & (35.78) & (22.46) & (18.63) & (27.59) \\
Obs & 39.00 & 38.00 & 47.00 & 39.00 & 38.00 & 47.00 & 39.00 & 38.00 & 47.00 \\ \\ \hline
\end{tabular}}
\begin{tablenotes}[flushleft]
\small
\item \textit{Notes:} Table Notes. Standard errors clustered at
the XXXXX level. */**/*** denotes significance at the 10/5/1 percent levels. The outcome variable is the share of observations that passed the intervention
\end{tablenotes}
\end{threeparttable}
\end{table}
这是我得到的输出。我需要做的就是使表格注释与表格对齐。现在它甚至跨越了页边距。
答案1
表格注释比表格本身更宽的原因是使用了\scalebox
。为了确保表格适合文本宽度,我结合使用了较小的字体大小tabular*
。我还用包中的行(您已经加载的)替换了水平线booktabs
。在下面的例子中,我还整理了序言,只保留了与特定表格相关的包:
\documentclass[11pt]{article}
\usepackage{palatino}
\usepackage{caption}
\captionsetup{margin=10pt,font=large,labelfont={bf,large},position=below,justification=justified}
\usepackage[margin=2cm]{geometry}
\usepackage{booktabs}
\usepackage{threeparttable}
\begin{document}
\begin{table}[htbp!]
\begin{threeparttable}[b]
\setlength{\tabcolsep}{0pt}
\small
\caption{Treatment Effects With New Strategy}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lccccccccc@{}}
\toprule
\multicolumn{1}{l}{} &
\multicolumn{3}{c}{Avg Test Score} &
\multicolumn{3}{c}{Avg Passing Rate} &
\multicolumn{3}{c}{Avg Participation Rate} \\
\cmidrule{2-4}
\cmidrule{5-7}
\cmidrule{8-10}
VARIABLES & Male & Female & All & Male & Female & All & Male & Female& All \\
& (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) \\
\midrule
& & & & & & & & &\\
Treatment & -26.21 & -22.18 & 34.08* & 35.83* & -59.34* & 17.13 & -26.21 & 9.84 & -8.46 \\
& [-2.02] & [-0.50] & [2.42] & [2.23] & [-2.46] & [1.22] & [-2.02] & [1.24] & [-0.78] \\
& (13.00) & (44.77) & (14.06) & (16.04) & (24.12) & (14.03) & (13.00) & (7.93) & (10.82) \\
Post & -26.50** & -25.47 & -11.53 & 40.49***& 52.71***& 52.68***& -26.50** & 2.28 & -16.49* \\
& [-3.52] & [-1.35] & [-1.34] & [4.36] & [5.18] & [6.15] & [-3.52] & [0.68] & [-2.49] \\
& (7.52) & (18.90) & (8.59) & (9.28) & (10.18) & (8.57) & (7.52) & (3.35) & (6.61) \\
DiD & 29.65* & 31.22 & 5.33 & 9.17 & 141.80** & 11.56 & 29.65* & -15.08 & 1.07 \\
& [2.13] & [0.39] & [0.32] & [0.53] & [3.25] & [0.70] & [2.13] & [-1.05] & [0.08] \\
& (13.89) & (80.90) & (16.45) & (17.14) & (43.58) & (16.42) & (13.89) & (14.34) & (12.67) \\
Constant & 42.02 & 271.27* & 222.43***& 65.29* & -23.66 & -38.16 & 42.02 & 23.55 & -46.42 \\
& [1.87] & [2.58] & [6.20] & [2.36] & [-0.42] & [-1.07] & [1.87] & [1.26] & [-1.68] \\
& (22.46) & (105.12) & (35.85) & (27.71) & (56.63) & (35.78) & (22.46) & (18.63) & (27.59) \\
Obs & 39.00 & 38.00 & 47.00 & 39.00 & 38.00 & 47.00 & 39.00 & 38.00 & 47.00 \\ \bottomrule
\end{tabular*}
\begin{tablenotes}[flushleft]
\footnotesize
\item \textit{Notes:} Table Notes. Standard errors clustered at
the XXXXX level. */**/*** denotes significance at the 10/5/1 percent levels. The outcome variable is the share of observations that passed the intervention
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
以下屏幕截图显示表格的宽度与文本宽度相同(红线标记边距):
答案2
对 进行了一些改进siunitx
,mathpazo
以适应主字体,并且makecell
:
\documentclass[11pt]{article}
\usepackage{palatino}
\usepackage{mathpazo}
\usepackage{caption}
\captionsetup{
labelfont={bf,large}, skip =6pt}
\usepackage[margin=2cm, showframe]{geometry}
\usepackage{makecell}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{siunitx}
\begin{document}
\begin{table}[htbp!]
\sisetup{table-format = -2.2, table-space-text-pre={[}, table-align-text-pre=false, table-space-text-post={***}, detect-family}
\begin{threeparttable}[b]
\setlength{\tabcolsep}{0pt}
\small
\caption{Treatment Effects With New Strategy}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}p{2cm}*{9}{S}@{}}
\toprule
\multicolumn{1}{l}{} &
\multicolumn{3}{c}{Avg Test Score} &
\multicolumn{3}{c}{Avg Passing Rate} &
\multicolumn{3}{c}{Avg Participation Rate} \\
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
\cmidrule(lr){8-10}
VARIABLES & {\thead{Male\\(1)}} &{\thead{Female\\(2)}} & {\thead{All\\(3)}} & {\thead{Male\\(4)}} & {\thead{Female\\(5)}} & {\thead{All\\(6)}} & {\thead{Male\\(7)}} & {\thead{Female\\(8)}} &{\thead{All\\(9)}} \\
\midrule
\addlinespace[2ex]
Treatment & -26.21 & -22.18 & 34.08* & 35.83* & -59.34* & 17.13 & -26.21 & 9.84 & -8.46 \\
& [-2.02] & [-0.50] & [2.42] & {[}2.23] & [-2.46] & [1.22] & [-2.02] & [1.24] & [-0.78] \\
& {(}13.00{)} & {(}44.77{)} & {(}14.06{)} & {(}16.04{)} & {(}24.12{)} & {(}14.03{)} & {(}13.00{)} & {(}7.93{)} & {(}10.82{)} \\
\addlinespace
Post & -26.50** & -25.47 & -11.53 & 40.49***& 52.71***& 52.68***& -26.50** & 2.28 & -16.49* \\
& [-3.52] & [-1.35] & [-1.34] & [4.36] & [5.18] & [6.15] & [-3.52] & [0.68] & [-2.49] \\
& {(}7.52{)} & {(}18.90{)} & {(}8.59{)} & {(}9.28{)} & {(}10.18{)} & {(}8.57{)} & {(}7.52{)} & {(}3.35{)} & {(}6.61{)} \\
\addlinespace
DiD & 29.65* & 31.22 & 5.33 & 9.17 & 141.80** & 11.56 & 29.65* & -15.08 & 1.07 \\
& [2.13] & [0.39] & [0.32] & [0.53] & [3.25] & [0.70] & [2.13] & [-1.05] & [0.08] \\
& {(}13.89{)} & {(}80.90{)} & {(}16.45{)} & {(}17.14{)} & {(}43.58{)} & {(}16.42{)} & {(}13.89{)} & {(}14.34{)} & {(}12.67{)} \\
\addlinespace
Constant & 42.02 & 271.27* & 222.43***& 65.29* & -23.66 & -38.16 & 42.02 & 23.55 & -46.42 \\
& [1.87] & [2.58] & [6.20] & [2.36] & [-0.42] & [-1.07] & [1.87] & [1.26] & [-1.68] \\
& {(}22.46{)} & {(}105.12{)} & {(}35.85{)} & {(}27.71{)} & {(}56.63{)} & {(}35.78{)} & {(}22.46{)} & {(}18.63{)} & {(}27.59{)} \\
\addlinespace
Obs & 39.00 & 38.00 & 47.00 & 39.00 & 38.00 & 47.00 & 39.00 & 38.00 & 47.00 \\ \bottomrule
\end{tabular*}
\smallskip
\begin{tablenotes}[flushleft]
\footnotesize
\item \textit{Notes:} Table Notes. Standard errors clustered at
the XXXXX level. */**/*** denotes significance at the 10/5/1 percent levels. The outcome variable is the share of observations that passed the intervention
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
答案3
@Bernard 答案的小变化。设置已更改siunitx
,因此表格主体中括号内数字的书写方式threeparttable
已改为[referable]{threeparttablex}
:
\documentclass[11pt]{article}
\usepackage{palatino}
\usepackage{mathpazo}
\usepackage{caption}
\captionsetup{labelfont={bf,large}, skip =6pt}
\usepackage[margin=2cm]{geometry}
\usepackage{booktabs, makecell}
\usepackage[referable]{threeparttablex} % <---
\usepackage{siunitx}
%---------------- show page layoutdon't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begin{table}[htbp!]
\sisetup{table-format = -2.2,
input-symbols = {( )}, % <---
table-space-text-pre={[},
table-align-text-pre=false,
table-space-text-post={***},
detect-family}
\begin{threeparttable}
\setlength{\tabcolsep}{0pt}
\small
\caption{Treatment Effects With New Strategy}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}p{2cm}*{9}{S}@{}}
\toprule
& \multicolumn{3}{c}{Avg Test Score}
& \multicolumn{3}{c}{Avg Passing Rate}
& \multicolumn{3}{c}{Avg Participation Rate} \\
\cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(lr){8-10}
VARIABLES
& {\thead{Male\\(1)}} & {\thead{Female\\(2)}} & {\thead{All\\(3)}}
& {\thead{Male\\(4)}} & {\thead{Female\\(5)}} & {\thead{All\\(6)}}
& {\thead{Male\\(7)}} & {\thead{Female\\(8)}} & {\thead{All\\(9)}} \\
\midrule
Treatment
& -26.21 & -22.18 & 34.08* & 35.83* & -59.34*
& 17.13 & -26.21 & 9.84 & -8.46 \\
& [-2.02] & [-0.50] & [2.42] & [2.23] & [-2.46]
& [1.22] & [-2.02] & [1.24] & [-0.78] \\
& (13.00) & (44.77) & (14.06) & (16.04)
& (24.12) & (14.03) & (13.00) & (7.93) & (10.82) \\
\addlinespace
Post & -26.50** & -25.47 & -11.53 & 40.49***& 52.71***& 52.68***& -26.50** & 2.28 & -16.49* \\
& [-3.52] & [-1.35] & [-1.34] & [4.36] & [5.18] & [6.15] & [-3.52] & [0.68] & [-2.49] \\
& (7.52) & (18.90) & (8.59) & (9.28) & (10.18) & (8.57) & (7.52) & (3.35) & (6.61) \\
\addlinespace
DiD & 29.65* & 31.22 & 5.33 & 9.17 & 141.80** & 11.56 & 29.65* & -15.08 & 1.07 \\
& [2.13] & [0.39] & [0.32] & [0.53] & [3.25] & [0.70] & [2.13] & [-1.05] & [0.08] \\
& (13.89) & (80.90) & (16.45) & (17.14) & (43.58) & (16.42) & (13.89) & (14.34) & (12.67) \\
\addlinespace
Constant & 42.02 & 271.27* & 222.43***& 65.29* & -23.66 & -38.16 & 42.02 & 23.55 & -46.42 \\
& [1.87] & [2.58] & [6.20] & [2.36] & [-0.42] & [-1.07] & [1.87] & [1.26] & [-1.68] \\
& (22.46) & (105.12) & (35.85) & (27.71) & (56.63) & (35.78) & (22.46) & (18.63) & (27.59) \\
\addlinespace
Obs & 39.00 & 38.00 & 47.00 & 39.00 & 38.00 & 47.00 & 39.00 & 38.00 & 47.00 \\ \bottomrule
\end{tabular*}
\smallskip
\begin{tablenotes}[flushleft]
\note Table Notes. Standard errors clustered at
the XXXXX level. */**/*** denotes significance at the 10/5/1 percent levels. The outcome variable is the share of observations that passed the intervention
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
结果:
笔记:您可以考虑使用宏\tnote
在表格中写注释。