1

I am trying to center columns using
\newcolumntype{Y}{>{\centering\arraybackslash}X}. However, it does not work in the following example.

\documentclass[11pt]{article}
\usepackage{setspace}
\usepackage{amssymb,colortbl}
\usepackage[capposition=top]{floatrow}
\usepackage[tablename=TABLE,labelsep=newline,aboveskip=0pt,bf, justification = centering]{caption}
\usepackage{clipboard}
\usepackage{booktabs}
\usepackage[svgnames]{xcolor}
\usepackage[capposition=top]{floatrow}
\usepackage{ltablex}
\usepackage{threeparttablex}
\usepackage{fancyvrb}

\newcolumntype{Y}{>{\centering\arraybackslash}X}
\newcommand{\gmc}[2]{\multicolumn{#1}{@{}#2@{}}}
\newcommand*{\tabnospace}{\item \noindent \hspace{-0.05in}}

\begin{document}
\begin{ThreePartTable}    
\footnotesize
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\renewcommand\TPTminimum{\textwidth}

\begin{TableNotes}[flushleft]       
\small      
\tabnospace 
Notes: The table reports results from regression models of future forecast errors of real estate price changes on the corresponding-region accounting profitability change. Forecast errors are actual realizations of real estate price changes minus the corresponding-period forecasts from Econoday and Zillow. Table 1 provides more details on the variables and the sample. \hrule
\end{TableNotes}        

\singlespacing  
\captionof{table}{\textbf{How is Regional Accounting Information Processed by Real Estate Forecasters?}}
\begin{tabularx}{\textwidth}{@{\extracolsep{\fill}}XYYY@{\extracolsep{\fill}}}
\toprule
\endfirsthead\endhead
\bottomrule\insertTableNotes
\endlastfoot
\gmc{4}{l}{Panel A. Econoday forecasts} \\\hline
& \gmc{3}{c}{Future Forecast error of regional real estate price change} \\\hline
& Estimate & Standard Error & t-statistic \\\hline
\rowcolor{gray!25}$\Delta Prof_{region}$ &  0.100&  0.046&  2.165\\
Intercept & 0.000&  0.001&  0.147 \\
Adjusted $R^2$ &    0.154        \\\\\hline
\gmc{4}{l}{Panel A. Zillow forecasts} \\\hline  
&Estimate&  Standard Error& t-statistic\\
\rowcolor{gray!25}  $\Delta Prof_{region}$ &    0.068&  0.029&  2.389 \\
Intercept&  0.000&  0.000&  0.347\\\\
Adjusted $R^2$ &    0.145        \\
\end{tabularx}   
\end{ThreePartTable}

\end{document}
  • 1
    Does this actually compile? I did not know that tabularx supported endfirsthead endhead! I thought you'd need longtable for that. I think you are mixing things up quite a bit. Inserttablenotes is means for longtable, with tabularx you need the standard constructions – daleif Jun 19 '16 at 6:10
  • Likewise, @{\extracolsep{\fill}} doesn't make much sense except when used in a tabular* environment. – Mico Jun 19 '16 at 7:10
  • @daleif It does apparently. I have using the same style for so long (which is a wrong way of doing things). Only that Y never used to work. Haha. – Sumit Jun 19 '16 at 15:44
4

You appear to be mixing up various concepts and methods from longtable, tabularx, tabular*, and still additional environments. Disentangling the mixture to figure out why the column contents aren't centered is rather difficult.

I would like to suggest that you simplify the code by using just one environment -- and the commands that are appropriate for it. In the example below, I use a tabularx environment. I would also like to suggest that you reorganize the structure of the tabular material, say along the lines pursued below.

enter image description here

\documentclass[11pt]{article}
\usepackage{setspace,amssymb}
\usepackage[tablename=TABLE,labelsep=newline,
   aboveskip=0pt,font=bf,justification=centering]{caption}
\usepackage{booktabs,tabularx}

\newcolumntype{Y}{>{\centering\arraybackslash}X}
\newcommand{\gmc}[3]{\multicolumn{#1}{@{}#2@{}}{#3}}

\begin{document}

\begingroup % keep any font size changes local to group
\setlength\tabcolsep{2pt} % default value: 6pt
\captionof{table}{How is Regional Accounting Information Processed by Real Estate Forecasters?}

\begin{tabularx}{\textwidth}{@{}lYYY@{}}
\toprule
& \multicolumn{3}{>{\hsize=3\hsize}Y}{Future forecast error of regional real estate price change} 
\\\cmidrule(l){2-4}
& Estimate & Standard Error & $t$-statistic \\\midrule
\gmc{4}{l}{Panel A\@. Econoday forecasts} \\\addlinespace
$\Delta \textit{Prof}_{\textit{region}}$ &  0.100&  0.046&  2.165\\
Intercept & 0.000&  0.001&  0.147 \\[1ex]
Adjusted $R^2$ &    0.154        \\[3ex]
\gmc{4}{l}{Panel B\@. Zillow forecasts} \\\addlinespace  
$\Delta \textit{Prof}_{\textit{region}}$ &  0.068&  0.029&  2.389 \\
Intercept              &  0.000&  0.000&  0.347\\[1ex]
Adjusted $R^2$ &    0.145        \\
\bottomrule
\end{tabularx}   

\medskip\small      
Notes: The table reports results from regression models of future forecast errors of real estate price changes on the corresponding-region accounting profitability change. Forecast errors are actual realizations of real estate price changes minus the corresponding-period forecasts from Econoday and Zillow. Table~1 provides more details on the variables and the sample. \par
\endgroup


\end{document}
| improve this answer | |
  • 1
    Thanks a lot! I understand that there were a lot of things I was doing wrong. – Sumit Jun 19 '16 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.