I am using the following Stata code to create a table with three regression models.
esttab model_E1* using "C_1_NM.tex", replace booktabs fragment alignment(S) varwidth(25) nomtitles label nobaselevels star(* 0.10 ** 0.05 *** 0.01) eqlabels(none)
The resulting C_1_NM.tex file is
&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} \\
\midrule
x1 & -0.143\sym{**} & -0.0191 & 0.0176 \\
& (-2.32) & (-0.32) & (0.05) \\
\addlinespace
x2 & -0.818\sym{***}& 0.887\sym{***}& 32.13\sym{***}\\
& (-7.78) & (9.14) & (56.79) \\
\addlinespace
x1 $\times$ x2 & -0.0864 & -0.149\sym{**} & -12.42\sym{***}\\
& (-1.18) & (-2.02) & (-24.75) \\
\addlinespace
x3 & -4.037\sym{***}& 6.329\sym{***}& 10.86\sym{**} \\
& (-4.80) & (5.62) & (2.08) \\
\addlinespace
x4 & 0.00180 & -0.111\sym{***}& -0.00565 \\
& (0.05) & (-4.33) & (-0.03) \\
\addlinespace
x5 & 0.371\sym{***}& 0.264\sym{***}& -0.119 \\
& (22.04) & (14.32) & (-0.91) \\
\addlinespace
x6 & 0.0149 & 0.0601\sym{**} & 0.287 \\
& (0.52) & (2.31) & (1.24) \\
\addlinespace
x7 & -0.626 & -0.473 & 2.455 \\
& (-1.11) & (-0.80) & (0.39) \\
\addlinespace
Constant & 1.258\sym{***}& -0.537\sym{***}& 13.56\sym{***}\\
& (8.95) & (-3.95) & (10.28) \\
\addlinespace
FE1 & Yes & Yes & Yes \\
\addlinespace
FE2 & Yes & Yes & Yes \\
\midrule
Observations & 1503 & 1503 & 1503 \\
Next I am running the manuscript.tex file below
\PassOptionsToPackage{force}{filehook}
\documentclass[preprint,12pt,authoryear,nonatbib]{elsarticle}
\usepackage{amssymb}
\usepackage{booktabs} % in order to automatically refer to the tables created in LaTeX - see \input{•} below.
\usepackage{lscape} % to create landscape tables
\usepackage{standalone} % needed for longtable - https://tex.stackexchange.com/questions/150085/how-to-include-a-multipage-table-from-an-external-file
\usepackage{longtable} % https://tex.stackexchange.com/questions/150085/how-to-include-a-multipage-table-from-an-external-file
\usepackage{amsmath}
\usepackage{threeparttablex}% For Notes below table
\makeatletter
\let\c@author\relax
\makeatother
% *****************************************************************
% Estout related things
% *****************************************************************
\newcommand{\sym}[1]{\rlap{#1}}% Thanks to David Carlisle
\let\estinput=\input% define a new input command so that we can still flatten the document
\newcommand{\estwide}[3]{
\vspace{.75ex}{
\begin{tabular}
{\textwidth}{@{\hskip\tabcolsep\extracolsep\fill}l{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular*}
}
}
\newcommand{\estauto}[3]{
\vspace{.75ex}{
\begin{tabular}{l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular}
}
}
% Allow line breaks with \ in specialcells
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
% *****************************************************************
% Custom subcaptions
% *****************************************************************
% Note/Source/Text after Tables
\newcommand{\figtext}[1]{
\vspace{-1.9ex}
\captionsetup{justification=justified,font=footnotesize}
\caption*{\hspace{6pt}\hangindent=1.5em #1}
}
\newcommand{\fignote}[1]{\figtext{\emph{Note:~}~#1}}
\newcommand{\figsource}[1]{\figtext{\emph{Source:~}~#1}}
% Add significance note with \starnote
\newcommand{\starnote}{\figtext{* p < 0.1, ** p < 0.05, *** p < 0.01. Standard errors in parentheses.}}
% *****************************************************************
% siunitx
% *****************************************************************
\usepackage{siunitx} % centering in tables
\sisetup{
detect-mode,
tight-spacing = true,
group-digits = false ,
input-signs = ,
input-symbols = ( ) [ ] - + *,
input-open-uncertainty = ,
input-close-uncertainty = ,
table-align-text-post = false
}
\begin{document}
blahblahblah...........
\clearpage
% Table 7
\begin{table}
\caption{Regression}
\estauto{C_1_NM}{3}{S[table-format=4.4]}
\starnote
\label{tab7}
\end{table}
\end{document}
but am getting the following error
! Misplaced \noalign. \bottomrule ->\noalign {\ifnum 0=`}\fi @aboverulesep =\aboverulesep \global... l.486 \estauto{C_1_NM}{3}{S[table-format=4.4]} I expect to see \noalign only after the \cr of an alignment. Proceed, and I'll ignore this case.
Can you please advise what I should do? The error is clearly related to \estauto (and possibly \estwide) in the preamble. I have adapted the code from https://www.jwe.cc/2012/03/stata-latex-tables-estout/
desc.tex?) that only you have. Please make your code more readily compilable. – Mico Sep 15 '21 at 20:54\estauto,\estwide, etc are. Sorry, but my mind-reading capabilities are worthless. – Mico Sep 20 '21 at 12:22