我希望在标题下方和表格本身上方有一个表格描述。此外,我希望描述的宽度与表格本身一样宽。我知道在网上经常有人问到描述部分,但到目前为止我还没能找到关于宽度的答案。在 Jörg Weber 的教程的帮助下(参见:1 2和3)我想出了以下代码,其中我想将 \figtext 部分放在标题和表格之间:
\newcommand{\sym}[1]{\rlap{#1}}% Thanks to David Carlisle
\let\estinput=\input% define a new input command so that we can still flatten the document
\newcommand{\estwide}[3]{
\vspace{.75ex}{
\begin{tabular*}
{\textwidth}{@{\hskip\tabcolsep\extracolsep\fill}l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular*}
}
}
\newcommand{\estauto}[3]{
\vspace{.75ex}{
\begin{tabular}{l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular}
}
}
% Allow line breaks with \\ in specialcells
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
% *****************************************************************
% Custom subcaptions
% *****************************************************************
% Note/Source/Text after Tables
\newcommand{\figtext}[1]{
\vspace{-1.9ex}
\captionsetup{justification=justified,font=footnotesize}
\caption*{\hspace{6pt}\hangindent=1.5em #1}
}
\usepackage{threeparttable}% Alternative for Notes below table
% Note/Source/Text after Tables
\newcommand{\Figtext}[1]{%
\begin{tablenotes}[para,flushleft]
%\hspace{6pt}
%\hangindent=1.75em
#1
\end{tablenotes}
}
\begin{document}
...
\begin{table}[H]\centering
\begin{threeparttable}
\caption{Descriptive statistics per REIT}
\estauto{C:/Users/.../Panel_Constituents.tex}{6}{r}
\Figtext{\small{All values depict the averages per REIT over the whole analyzed period. Values for Assets, Debt, Equity and Market Capitalization are reported in thousand US.}}
\label{Descriptives}
\end{threeparttable}
\end{table}
...
\end{document}
& Assets& Debt& Equity& MarketCap& Leverage& Return\\
\midrule
mean & 2,884,654& 1,443,272& 1,226,602& 2,169,579& 0.4753& 3.17\\
min & 8,142& 0& -1,787,348& 1,910& 0.0000& -8.31\\
max & 25,324,830& 17,978,696& 9,999,590& 32,474,382& 1.1650& 31.46\\
sd & 3,679,338& 2,163,937& 1,443,727& 3,809,827& 0.1712& 2.89\\
此外,现在行之间的垂直空间比我使用表格和表格环境的其他表格要宽得多。有没有办法解决这个问题?如果我说得不清楚,请原谅,我对这些都很陌生……
编辑:我设法通过删除 Stata 代码中的一部分来删除表格中的额外垂直间距,更具体地说,通过从 esttab 中删除 -gaps- 选项。
编辑2:我不清楚 \estauto 命令的具体工作原理(这就是我基本上复制它的原因),但在 panel_constituents.tex 文件里面有显示在底部的代码。
答案1
一些改进siunitx
,以及使用简单的描述\multicolumn
:
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tabularx, booktabs, caption, makecell, float}
\captionsetup{justification=justified,font=footnotesize}
\usepackage{siunitx}
\begin{document}
\begin{table}[H]
\sisetup{table-format = 8.0, table-number-alignment = center, group-separator = {,}}
\centering\setlength{\tabcolsep}{5pt}\setlength{\extrarowheight}{2pt}
\caption{Descriptive statistics per REIT}
\begin{tabularx}{\linewidth}{@{\,}>{\bfseries}X*{4}{S}S[table-format = 1.4]S[table-format = -1.2]@{\,}}
\multicolumn{7}{@{}>{\footnotesize}p{\linewidth}@{}}
{All values depict the averages per REIT over the whole analyzed period. Values for Assets, Debt, Equity and Market Capitalization are reported in thousand US.} \\
\addlinespace[1ex]
\toprule
& {Assets} & {Debt} & {Equity} & {MarketCap} & {Leverage} & {Return} \\
\midrule
mean & 2884654 & 1443272 & 1226602 & 2169579 & 0.4753 & 3.17 \\
min & 8142 & 0 & -1787348 & 1910 & 0.0000 & -8.31 \\
max & 25324830 & 17978696 & 9999590 & 32474382 & 1.1650 & 31.46 \\
sd & 3679338 & 2163937 & 1443727 & 3809827 & 0.1712 & 2.89 \\
\bottomrule
\end{tabularx}
\label{Descriptives}
\end{table}
\end{document}
答案2
我猜你正在寻找这样的东西(但我不确定,从你的代码片段不可能弄清楚你喜欢做什么):
\documentclass{article}
\usepackage{geometry}
\usepackage[table]{xcolor}
\usepackage{booktabs, tabularx, threeparttable}
%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begin{table}
\caption{Descriptive statistics per REIT}
\label{Descriptives}
\begin{threeparttable}
{\medskip\small
All values depict the averages per REIT over the whole analyzed period. Values for Assets, Debt, Equity and Market Capitalization are reported in thousand US.
}
\medskip
\begin{tabularx}{\linewidth}{l *{6}{X}}
\toprule
& Assets & Debt & Equity & MarketCap & Leverage & Return \\
\midrule
mean & 2,884,654 & 1,443,272 & 1,226,602 & 2,169,579 & 0.4753 & 3.17 \\
min & 8,142 & 0 & -1,787,348 & 1,910 & 0.0000 & -8.31 \\
max & 25,324,830 & 17,978,696 & 9,999,590 & 32,474,382 & 1.1650 & 31.46 \\
sd & 3,679,338 & 2,163,937 & 1,443,727 & 3,809,827 & 0.1712 & 2.89 \\
\bottomrule
\end{tabularx}
\end{threeparttable}
\end{table}
\end{document}
得出:
可以使用包S
中的列来改进表格siunitx
,但请首先让我知道,我是否走在正确的轨道上......
编辑:
使用siunitx
和caption
包装的替代解决方案:
\documentclass{article}
\usepackage{geometry}
\usepackage[table]{xcolor}
\usepackage{booktabs, tabularx, threeparttable}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}
%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begin{table}
\sisetup{group-four-digits,
group-separator={,}
}
\caption{Descriptive statistics per REIT}
\label{Descriptives}
\centering
\begin{threeparttable}
\caption*{\footnotesize
All values depict the averages per REIT over the whole analyzed period. Values for Assets, Debt, Equity and Market Capitalization are reported in thousand US.
}
\begin{tabular}{l *{4}{S[table-format=8.0]}
*{2}{S[table-format=2.4,
group-separator={\;}]} }
\toprule
& {Assets} & {Debt} & {Equity} & {MarketCap}& {Leverage} & {Return} \\
\midrule
mean & 2 884 654 & 1 443 272 & 1 226 602 & 2 169 579 & 0.4753 & 3.17 \\
min & 8 142 & 0 & -1 787 348 & 1 910 & 0.0000 & -8.31 \\
max & 25 324 830 & 17 978 696 & 9 999 590 & 32 474 382 & 1.1650 & 31.46 \\
sd & 3 679 338 & 2 163 937 & 1 443 727 & 3 809 827 & 0.1712 & 2.89 \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}