1

I produced a table several weeks ago (reference image attached) that I am now trying to add into a larger document. The first issue I am running into is that I now get an error message "Illegal character in array argument." I don't recall getting this error previously, and I am having trouble pinpointing the exact issue. To be honest, I think I found the table setup online, and since it worked at the time, I didn't question it.

Some things to note: The preamble in the tex file I am trying to add the table to is different from the test version I was using. I wasn't calling the dcolumn package, so I am not sure why I didn't run into this issue earlier. When I did try to play around with the dcolumn package, I ran into an issue where the final row is way out of alignment since it doesn't have any decimal places.

I've attached two photos: one of how the table looked when I compiled it several weeks ago, and the other is how it looks in Overleaf now (which is closer than how it looks when I use the dcolumn package but is still not centered on the page).

Here is what I have to produce the table:

\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}

This is how it looks in Overleaf now, but I am still getting the error when I try to recompile and can't do so on my desktop compiler

This is what I want it to look like

Any help would be appreciated, thanks!

2
  • 1
    You do need to load dcolumn package to use column type D. The definition of \sym is also not provided in your example. Cells in the last row is still vertically centered on .. It's just for this time the . is omitted. Attempt: for example for the cell in last row, second column, use \multicolumn{1}{r}{97,879} instead of 97,879. Commented Sep 19, 2023 at 22:04
  • Welcome to TeX.SE.
    – Mico
    Commented Sep 19, 2023 at 22:42

1 Answer 1

1

The two main changes you should make -- other than, of course, making sure to load all required packages, and especially the dcolumn package, and that all macros, incl. \sym, are defined -- are (a) replace D{.}{.}{-1} with something less spatially profligate, say, D{.}{.}{2.6} and (b) center the cell contents in the final two rows (Rsquared and No. of obs., respectively). Oh, and do please replace all instances of \hline with suitable alternatives provided by the booktabs package, such as \toprule, \midrule, and \bottomrule.

enter image description here

\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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .