我使用 RStudio 中的“stargazer”包创建了这些描述性统计表,我想在这个表下写一个注释,但我做不到。我唯一能做的就是写一个注释,但这没有道理。
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{breqn}
\usepackage[super]{nth}
\usepackage{amsmath}
\usepackage{breqn}
\beamerdefaultoverlayspecification{<+->}
\usepackage[utf8]{inputenc}
\usepackage{ragged2e}
\usepackage{etoolbox}
\usepackage{lipsum}
\begin{document}
\maketitle
\begin{frame}{Expected results}
% Table created by stargazer v.5.2.2 by Marek Hlavac, Harvard University. E-mail: hlavac at fas.harvard.edu
% Date and time: Wed, Oct 21, 2020 - 15:39:55
\begin{table}[!htbp] \centering
\caption{Descriptive statistics}
\label{}
\resizebox{\textwidth}{!} {%
\begin{tabular}{@{\extracolsep{5pt}}lccccc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
Variable & \multicolumn{1}{c}{N} & \multicolumn{1}{c}{Mean} & \multicolumn{1}{c}{St. Dev.} & \multicolumn{1}{c}{Min} & \multicolumn{1}{c}{Max} \\
\hline \\[-1.8ex]
Child deaths caused by infectious diseases & 28,119 & 0.486 & 2.487 & 0 & 230 \\
Access to piped water and sewage (\%) & 28,119 & 57.197 & 29.119 & 0.000 & 99.474 \\
Illiteracy rate (\%) & 28,119 & 30.453 & 15.129 & 2.022 & 70.261 \\
Years of schooling (population above 25) & 28,119 & 3.780 & 1.217 & 0.814 & 8.577 \\
Gini index & 28,119 & 0.582 & 0.092 & 0.364 & 0.880 \\
Population & 28,119 & 23,850.370 & 116,238.000 & 958 & 10,434,252 \\ Income per capita (R\$) & 28,119 & 148.598 & 84.234 & 34.527 & 762.052 \\
\hline \\[-1.8ex]
\end{tabular}%
}
\end{table}
\end{frame}
答案1
\resizebox
我建议使用而不是 ,tabularx
并结合较小的字体大小和缩小的\tabcolsep
。在下面的例子中,我还用包中的线条替换了水平线booktabs
,并在相邻行之间添加了一个小的垂直空白作为眼睛的引导。对于表格注释,我使用了\multicolumn
:
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}
\begin{frame}{Expected results}
\begin{table}[!htbp]
\centering
\footnotesize
\setlength{\tabcolsep}{4pt}
\setlength{\defaultaddspace}{0.9pt}
\caption{Descriptive statistics}
\begin{tabularx}{\textwidth}{@{}>{\raggedright\arraybackslash}Xccccc@{}}
\toprule
Variable & N & Mean & St. Dev. & Min & Max \\
\midrule
Child deaths caused by infectious diseases & 28,119 & 0.486 & 2.487 & 0 & 230 \\ \addlinespace
Access to piped water and sewage (\%) & 28,119 & 57.197 & 29.119 & 0.000 & 99.474 \\ \addlinespace
Illiteracy rate (\%) & 28,119 & 30.453 & 15.129 & 2.022 & 70.261 \\ \addlinespace
Years of schooling (population above 25) & 28,119 & 3.780 & 1.217 & 0.814 & 8.577 \\ \addlinespace
Gini index & 28,119 & 0.582 & 0.092 & 0.364 & 0.880 \\ \addlinespace
Population & 28,119 & 23,850.370 & 116,238.000 & 958 & 10,434,252 \\ \addlinespace
Income per capita (R\$) & 28,119 & 148.598 & 84.234 & 34.527 & 762.052 \\
\bottomrule
\multicolumn{6}{@{}p{\textwidth}@{}}{The table shows the descriptive statistics of the data used in the paper. Child deaths caused by infectious diseases were obtained in the dataset. Access to piped water, illiteracy rate, years of schooling of the population above 25, Gini index, population, and income per capita were all obtained in the Ipeadata that uses the data provided by the 2000 census.}
\end{tabularx}
\end{table}
\end{frame}
\end{document}
由于“N”列中的所有条目基本相同,您可以完全删除该列并将此信息添加到表格的标题中吗?结果可能如下所示:
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}
\begin{frame}{Expected results}
\begin{table}[!htbp]
\centering
\footnotesize
\setlength{\tabcolsep}{4pt}
\setlength{\defaultaddspace}{2.75pt}
\caption{Descriptive statistics; N = 28,119}
\begin{tabularx}{\textwidth}{@{}>{\raggedright\arraybackslash}Xcccc@{}}
\toprule
Variable & Mean & St. Dev. & Min & Max \\
\midrule
Child deaths caused by infectious diseases & 0.486 & 2.487 & 0 & 230 \\ \addlinespace
Access to piped water and sewage (\%) & 57.197 & 29.119 & 0.000 & 99.474 \\ \addlinespace
Illiteracy rate (\%) & 30.453 & 15.129 & 2.022 & 70.261 \\ \addlinespace
Years of schooling (population above 25) & 3.780 & 1.217 & 0.814 & 8.577 \\ \addlinespace
Gini index & 0.582 & 0.092 & 0.364 & 0.880 \\ \addlinespace
Population & 23,850.370 & 116,238.000 & 958 & 10,434,252 \\ \addlinespace
Income per capita (R\$) & 148.598 & 84.234 & 34.527 & 762.052 \\
\bottomrule
\multicolumn{5}{@{}p{\textwidth}@{}}{The table shows the descriptive statistics of the data used in the paper. Child deaths caused by infectious diseases were obtained in the dataset. Access to piped water, illiteracy rate, years of schooling of the population above 25, Gini index, population, and income per capita were all obtained in the Ipeadata that uses the data provided by the 2000 census.}
\end{tabularx}
\end{table}
\end{frame}
\end{document}
答案2
我怀疑你正在寻找这样的东西:
使用threeparttable
、cellspace
和siunitx
包:
\documentclass{beamer}
\usetheme{Madrid}
\beamerdefaultoverlayspecification{<+->}
\usepackage{ragged2e}
\usepackage{array, booktabs, threeparttable}
\usepackage[column=O]{cellspace}
\usepackage{siunitx}
\begin{document}
\begin{frame}{Expected results}
\begin{table}
\footnotesize\linespread{0.84}\selectfont
\setlength\cellspacetoplimit{3pt}
\setlength\cellspacebottomlimit{3pt}
\setlength\tabcolsep{0pt}
\begin{threeparttable}
\caption{Descriptive statistics}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
O{m{0.33\linewidth}}
S[table-format=5.0]
*{2}{S[table-format=2.3]}
S[table-format=1.3]
S[table-format=2.3]}
\toprule
Variable & {N} & {Mean} & {St. Dev.} & {Min} & {Max} \\
\midrule
Child deaths caused by infectious diseases
& 28 119 & 0.486 & 2.487 & 0 & 230 \\
Access to piped water and sewage (\%)
& 28 119 & 57.197 & 29.119 & 0.000 & 99.474 \\
Illiteracy rate (\%)
& 28 119 & 30.453 & 15.129 & 2.022 & 70.261 \\
Years of schooling (population above 25)
& 28 119 & 3.780 & 1.217 & 0.814 & 8.577 \\
Gini index
& 28 119 & 0.582 & 0.092 & 0.364 & 0.880 \\
Population
& {28 119} & {23 850 370} & {116 238 000} & {958} & {10 434 252} \\
Income per capita (R\$)
& {28 119} & {148 598} & {84 234} & {34 527} & {762 052} \\
\midrule[\heavyrulewidth]
\end{tabular*}\scriptsize
\begin{tablenotes}[para, flushleft]
\item[*] \(p<0.1\)
\item[**] \(p<0.01\)
\item[***] \(p<0.001\)
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{frame}
\end{document}
附录:
如果要在表格下方输入所需文本,则threeparttable
使用 ˙[referable]{threeparttablex}`,第一列中的文本位于一行中
\documentclass{beamer}
\usetheme{Madrid}
\beamerdefaultoverlayspecification{<+->}
\usepackage{ragged2e}
\usepackage{array, booktabs}
\usepackage[referable]{threeparttablex}
\usepackage[column=O]{cellspace}
\usepackage{siunitx}
\begin{document}
\begin{frame}{Expected results}
\begin{table}
\footnotesize
\setlength\cellspacetoplimit{2pt}
\setlength\cellspacebottomlimit{2pt}
\setlength\tabcolsep{0pt}
\begin{threeparttable}
\caption{Descriptive statistics for $N=\num{28 112}$}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
Ol
*{2}{S[table-format=2.3]}
S[table-format=1.3]
S[table-format=2.3]}
\toprule
Variable & {Mean} & {St. Dev.} & {Min} & {Max} \\
\midrule
Child deaths caused by infectious diseases
& 0.486 & 2.487 & 0 & 230 \\
Access to piped water and sewage (\%)
& 57.197 & 29.119 & 0.000 & 99.474 \\
Illiteracy rate (\%)
& 30.453 & 15.129 & 2.022 & 70.261 \\
Years of schooling (population above 25)
& 3.780 & 1.217 & 0.814 & 8.577 \\
Gini index
& 0.582 & 0.092 & 0.364 & 0.880 \\
\addlinespace
Population
& {23 850 370} & {116 238 000} & {958} & {10 434 252} \\
Income per capita (R\$)
& {148 598} & {84 234} & {34 527} & {762 052} \\
\midrule[\heavyrulewidth]
\end{tabular*}\scriptsize
\begin{tablenotes}[flushleft]
\note{
the table shows the descriptive statistics of the data used in the paper. Child deaths caused by infectious diseases were obtained in the dataset. Access to piped water, illiteracy rate, years of schooling of the population above 25, Gini index, population, and income per capita were all obtained in the Ipeadata that uses the data provided by the 2000 census.
}
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{frame}
\end{document}