几周前我制作了一个表格(附有参考图片),现在我正尝试将其添加到一个更大的文档中。我遇到的第一个问题是,我现在收到一条错误消息“数组参数中的非法字符”。我不记得以前收到过这个错误,而且我很难确定确切的问题。说实话,我想我在网上找到了表格设置,而且由于当时它可以工作,所以我没有质疑它。
需要注意的几点:我尝试将表格添加到的 tex 文件中的序言与我使用的测试版本不同。我没有调用 dcolumn 包,所以我不确定为什么我之前没有遇到这个问题。当我尝试使用 dcolumn 包时,我遇到了一个问题,即最后一行完全不对齐,因为它没有任何小数位。
我附上了两张照片:一张是我几周前编译表格时的样子,另一张是它现在在 Overleaf 中的样子(比我使用 dcolumn 包时的样子更接近,但仍然没有位于页面中央)。
以下是我制作的表格:
\documentclass[11pt, english, letterpaper, fleqn]{article}%
\usepackage{amsmath}
\usepackage[singlespacing]{setspace}
\usepackage{graphicx}
\usepackage{changepage}
\usepackage{morefloats}
\usepackage{afterpage}
\usepackage{float}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[top=1in, bottom=1.in, left=.75in, right=.75in]{geometry}
\usepackage{pgffor}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{pdflscape}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{rotating}
\newenvironment{fignote}{\begin{quote}\footnotesize}{\end{quote}}
\captionsetup{belowskip=0pt}
\pagenumbering{gobble}
\newcommand{\noi}{\noindent}
\newif\ifw
\title{abcd}}
\author{
yyy
\and
zzz
}
\begin{document}
\maketitle
\section{Introduction}
\begin{sidewaystable}[!htbp]
\caption{Disaster Severity}
\begin{tabular}{l*{9}{D{.}{.}{-1}}}
\hline\hline
& && & \multicolumn{3}{c}{Years After Disaster} \\
&\multicolumn{1}{c}{0} &\multicolumn{1}{c}{1} &\multicolumn{1}{c}{2} &\multicolumn{1}{c}{3} &\multicolumn{1}{c}{4} &\multicolumn{1}{c}{5} &\multicolumn{1}{c}{6} &\multicolumn{1}{c}{7} &\multicolumn{1}{c}{8} \\
\hline
Disaster & -0.151 & 0.125 & 0.086 & 0.022 & 0.032 & -0.025 & 0.305 & 0.419\sym{*} & 0.399\sym{*} \\
& (-1.60) & (1.12) & (0.62) & (0.14) & (0.18) & (-0.12) & (1.51) & (1.91) & (1.73) \\
[1em]
Disaster $\times$ Damages& 0.000\sym{**} & 0.000\sym{**} & 0.000\sym{*} & 0.001\sym{*} & 0.001\sym{*} & 0.001\sym{*} & 0.001\sym{*} & 0.001\sym{*} & 0.001\sym{*} \\
& (2.49) & (2.54) & (1.83) & (1.84) & (1.74) & (1.78) & (1.81) & (1.79) & (1.89) \\
[1em]
Disaster $\times$ Damages$^2$& -0.000 & -0.000 & 0.000 & -0.000 & -0.000 & -0.000 & -0.000 & -0.000 & -0.000 \\
& (-1.03) & (-0.54) & (0.08) & (-0.86) & (-0.93) & (-0.92) & (-1.15) & (-1.25) & (-1.36) \\
[1em]
Disaster $\times$ Damages$^3$& 0.000 & -0.000 & -0.000 & 0.000 & 0.000 & 0.000 & 0.000 & 0.000 & 0.000 \\
& (0.57) & (-0.40) & (-0.98) & (0.22) & (0.49) & (0.51) & (0.86) & (0.84) & (0.96) \\
\hline
\rule{0pt}{1ex} & & & & & & & & & \\
\emph{Net Effects}& & & & & & & & & \\
25th Percentile & -0.151 & 0.126 & 0.087 & 0.024 & 0.033 & -0.023 & 0.306 & 0.421* & 0.401* \\
& (-1.60) & ( 1.13) & ( 0.63) & ( 0.15) & ( 0.18) & (-0.12) & ( 1.52) & ( 1.92) & ( 1.73) \\
50th Percentile & -0.147 & 0.133 & 0.094 & 0.033 & 0.042 & -0.014 & 0.315 & 0.430** & 0.410* \\
& (-1.57) & ( 1.20) & ( 0.69) & ( 0.21) & ( 0.23) & (-0.07) & ( 1.57) & ( 1.97) & ( 1.78) \\
75th Percentile & -0.132 & 0.164 & 0.130 & 0.077 & 0.083 & 0.028 & 0.358* & 0.473** & 0.454** \\
& (-1.41) & ( 1.49) & ( 0.96) & ( 0.50) & ( 0.46) & ( 0.14) & ( 1.80) & ( 2.19) & ( 1.99) \\
90th Percentile & -0.064 & 0.302** & 0.286* & 0.271 & 0.263 & 0.216 & 0.545** & 0.664*** & 0.645*** \\
& (-0.66) & ( 2.48) & ( 1.81) & ( 1.45) & ( 1.26) & ( 0.98) & ( 2.48) & ( 2.81) & ( 2.64) \\
95th Percentile & 0.099 & 0.640*** & 0.668** & 0.741* & 0.698* & 0.668* & 0.992** & 1.120*** & 1.102*** \\
& ( 0.77) & ( 2.97) & ( 2.11) & ( 1.90) & ( 1.77) & ( 1.67) & ( 2.52) & ( 2.74) & ( 2.77) \\
97th Percentile & 0.237 & 0.928*** & 0.997** & 1.140* & 1.066* & 1.050* & 1.368** & 1.502** & 1.483*** \\
& ( 1.41) & ( 2.91) & ( 2.09) & ( 1.93) & ( 1.83) & ( 1.78) & ( 2.37) & ( 2.52) & ( 2.60) \\
98th Percentile & 0.449* & 1.383*** & 1.524** & 1.763* & 1.637* & 1.644* & 1.946** & 2.087** & 2.065** \\
& ( 1.90) & ( 2.82) & ( 2.06) & ( 1.95) & ( 1.85) & ( 1.84) & ( 2.24) & ( 2.33) & ( 2.43) \\
99th Percentile & 0.923** & 2.448*** & 2.781** & 3.191** & 2.929* & 2.989* & 3.231** & 3.377** & 3.336** \\
& ( 2.40) & ( 2.69) & ( 2.06) & ( 1.98) & ( 1.90) & ( 1.92) & ( 2.14) & ( 2.17) & ( 2.28) \\
\hline & & & & & & & & & \\
R-squared & 0.28 & 0.33 & 0.34 & 0.36 & 0.40 & 0.44 & 0.47 & 0.51 & 0.52 \\
Observations & 97,879 & 97,800 & 94,804 & 91,809 & 88,819 & 85,828 & 82,839 & 79,855 & 76,871 \\
\hline\hline
\multicolumn{10}{l}{\footnotesize \textit{t} statistics in parentheses}\\
\multicolumn{10}{l}{\footnotesize \sym{*} \(p<0.1\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)}\\
\end{tabular}
\end{sidewaystable}
\end{document}
任何帮助都将不胜感激,谢谢!
答案1
您应该进行的两个主要更改(当然,除了确保加载所有必需的包,尤其是包,以及定义dcolumn
所有宏(包括)之外)是(a)用占用空间较少的东西替换,例如(b)将单元格内容居中在最后两行(分别为 Rsquared 和 No. of obs.)。哦,请用 提供的合适替代方案替换所有实例\sym
D{.}{.}{-1}
D{.}{.}{2.6}
\hline
书签包,例如\toprule
、\midrule
和\bottomrule
。
\documentclass[11pt, english, letterpaper, fleqn]{article}
\usepackage{amsmath}
\usepackage[singlespacing]{setspace}
\usepackage{graphicx}
\usepackage{changepage}
\usepackage{morefloats}
\usepackage{afterpage}
\usepackage{float}
\usepackage{caption,subcaption}
\captionsetup{skip=0.333\baselineskip}
\usepackage[vmargin=1.0in, hmargin=0.75in]{geometry}
\usepackage{pgffor}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{pdflscape}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{rotating}
\newenvironment{fignote}{%
\begin{quote}\footnotesize}{%
\end{quote}}
\captionsetup{belowskip=0pt}
%%\pagenumbering{gobble}
% new code:
\providecommand\sym[1]{^{#1}} % ??
\usepackage{dcolumn}
\usepackage{booktabs}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{sidewaystable} %[!htbp] % '[!htbp]' has no effect on 'sideways[table/figure]'
\caption{Disaster severity}
\centering
\begin{tabular}{@{} l *{9}{D..{2.6}} @{}}
\toprule
& \multicolumn{9}{c@{}}{Years after disaster}\\
\cmidrule(l){2-10}
&\mc{0} &\mc{1} &\mc{2} &\mc{3} &\mc{4} &\mc{5} &\mc{6} &\mc{7} &\mc{8} \\
\midrule
Disaster & -0.151 & 0.125 & 0.086 & 0.022 & 0.032 & -0.025 & 0.305 & 0.419\sym{*} & 0.399\sym{*} \\
& (-1.60) & (1.12) & (0.62) & (0.14) & (0.18) & (-0.12) & (1.51) & (1.91) & (1.73) \\ \addlinespace
Disaster $\times$ Damages & 0.000\sym{**} & 0.000\sym{**} & 0.000\sym{*} & 0.001\sym{*} & 0.001\sym{*} & 0.001\sym{*} & 0.001\sym{*} & 0.001\sym{*} & 0.001\sym{*} \\
& (2.49) & (2.54) & (1.83) & (1.84) & (1.74) & (1.78) & (1.81) & (1.79) & (1.89) \\ \addlinespace
Disaster $\times$ Damages$^2$ & -0.000 & -0.000 & 0.000 & -0.000 & -0.000 & -0.000 & -0.000 & -0.000 & -0.000 \\
& (-1.03) & (-0.54) & (0.08) & (-0.86) & (-0.93) & (-0.92) & (-1.15) & (-1.25) & (-1.36) \\ \addlinespace
Disaster $\times$ Damages$^3$ & 0.000 & -0.000 & -0.000 & 0.000 & 0.000 & 0.000 & 0.000 & 0.000 & 0.000 \\
& (0.57) & (-0.40) & (-0.98) & (0.22) & (0.49) & (0.51) & (0.86) & (0.84) & (0.96) \\
\midrule
\emph{Net Effects} \\[0.5ex]
25th percentile & -0.151 & 0.126 & 0.087 & 0.024 & 0.033 & -0.023 & 0.306 & 0.421\sym{*} & 0.401\sym{*} \\
& (-1.60) & (1.13) & (0.63) & (0.15) & (0.18) & (-0.12) & (1.52) & (1.92) & (1.73) \\
50th percentile & -0.147 & 0.133 & 0.094 & 0.033 & 0.042 & -0.014 & 0.315 & 0.430\sym{**} & 0.410\sym{*} \\
& (-1.57) & (1.20) & (0.69) & (0.21) & (0.23) & (-0.07) & (1.57) & (1.97) & (1.78) \\
75th percentile & -0.132 & 0.164 & 0.130 & 0.077 & 0.083 & 0.028 & 0.358\sym{*} & 0.473\sym{**} & 0.454\sym{**}\\
& (-1.41) & (1.49) & (0.96) & (0.50) & (0.46) & (0.14) & (1.80) & (2.19) & (1.99) \\
90th percentile & -0.064 & 0.302\sym{**} & 0.286\sym{*} & 0.271 & 0.263 & 0.216 & 0.545\sym{**} & 0.664\sym{***} & 0.645\sym{***} \\
& (-0.66) & (2.48) & (1.81) & (1.45) & (1.26) & (0.98) & (2.48) & (2.81) & (2.64) \\
95th percentile & 0.099 & 0.640\sym{***} & 0.668\sym{**} & 0.741\sym{*} & 0.698\sym{*} & 0.668\sym{*} & 0.992\sym{**} & 1.120\sym{***} & 1.102\sym{***} \\
& (0.77) & (2.97) & (2.11) & (1.90) & (1.77) & (1.67) & (2.52) & (2.74) & (2.77) \\
97th percentile & 0.237 & 0.928\sym{***} & 0.997\sym{**} & 1.140\sym{*} & 1.066\sym{*} & 1.050\sym{*} & 1.368\sym{**} & 1.502\sym{**} & 1.483\sym{***} \\
& (1.41) & (2.91) & (2.09) & (1.93) & (1.83) & (1.78) & (2.37) & (2.52) & (2.60) \\
98th percentile & 0.449\sym{*} & 1.383\sym{***} & 1.524\sym{**} & 1.763\sym{*} & 1.637\sym{*} & 1.644\sym{*} & 1.946\sym{**} & 2.087\sym{**} & 2.065\sym{**} \\
& (1.90) & (2.82) & (2.06) & (1.95) & (1.85) & (1.84) & (2.24) & (2.33) & (2.43) \\
99th percentile & 0.923\sym{**} & 2.448\sym{***} & 2.781\sym{**} & 3.191\sym{**} & 2.929\sym{*} & 2.989\sym{*} & 3.231\sym{**} & 3.377\sym{**} & 3.336\sym{**} \\
& (2.40) & (2.69) & (2.06) & (1.98) & (1.90) & (1.92) & (2.14) & (2.17) & (2.28) \\
\midrule
R-squared & \mc{0.28} & \mc{0.33} & \mc{0.34} & \mc{0.36} & \mc{0.40} & \mc{0.44} & \mc{0.47} & \mc{0.51} & \mc{0.52} \\
No.\ of obs. & \mc{97,879} & \mc{97,800} & \mc{94,804} & \mc{91,809} & \mc{88,819} & \mc{85,828} & \mc{82,839} & \mc{79,855} & \mc{76,871} \\
\bottomrule
\multicolumn{10}{@{}l}{\footnotesize $t$-statistics in parentheses}\\
\multicolumn{10}{@{}l}{\footnotesize $\sym{*}\ p<0.1$; $\sym{**}\ p<0.05$; $\sym{***}\ p<0.01$.}
\end{tabular}
\end{sidewaystable}
\end{document}