[Tex/LaTex] Caption outside float in tabularx

captionstabularx

I am getting an error, while processing this latex file. Please help me. Thanks.

\documentclass{article}
\usepackage{tabularx}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage{booktabs}
\usepackage{setspace}
\usepackage[tablename=TABLE,labelsep=newline,aboveskip=0pt,bf,justification = centering]{caption}
\usepackage[dvipsnames]{xcolor}
\usepackage[capposition=top]{floatrow}
\newcommand*{\tabnospace}{\item \noindent \hspace{-0.05in}}
\newcommand{\gmc}[2]{\multicolumn{#1}{@{}#2@{}}}

\begin{document}

\begin{ThreePartTable}    
\footnotesize  

\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  

\begin{tabularx}{\textwidth}{XXXX}
    \caption{\textbf{How is Regional Accounting Information Processed by Real Estate Forecasters?}}\\
    \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
    $\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\\
    $\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}

Best Answer

The \caption is within the tabularx environment, which is an error. But even outside it won't work, since Threeparttable is no floating environment. Use the caption package and \captionof{table}{\textbf{How is ...}} outside of tabularx instead, either below or above the tabularx environment, according to your needs.

\documentclass{article}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage{booktabs}
\usepackage{setspace}
\usepackage[tablename=TABLE,labelsep=newline,aboveskip=0pt,bf,justification = centering]{caption}
\usepackage[dvipsnames]{xcolor}
\usepackage[capposition=top]{floatrow}
\newcommand*{\tabnospace}{\item \noindent \hspace{-0.05in}}
\newcommand{\gmc}[2]{\multicolumn{#1}{@{}#2@{}}}

\begin{document}

\begin{ThreePartTable}    
\footnotesize  

\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}{XXXX}
    \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
    $\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\\
    $\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}
Related Question