!放错 \noalign。\bottomrule 与 \estauto \estwide 错误

!放错 \noalign。\bottomrule 与 \estauto \estwide 错误

我正在使用以下 Stata 代码创建一个包含三个回归模型的表。

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)

生成的 C_1_NM.tex 文件是

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

接下来我运行下面的手稿.tex 文件

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

但出现以下错误

! \noalign 放错了位置。\bottomrule ->\noalign {\ifnum 0=`}\fi @aboverulesep =\aboverulesep \global... l.486 \estauto{C_1_NM}{3}{S[table-format=4.4]} 我希望只在对齐的 \cr 之后看到 \noalign。继续,我会忽略这种情况。

你能告诉我该怎么办吗?错误显然与序言中的 \estauto(也可能是 \estwide)有关。我改编了以下代码:https://www.jwe.cc/2012/03/stata-latex-tables-estout/

答案1

您可以在这里找到问题的解决方案:

2020 年秋季 LaTeX 发布后 \input{table.tex}\hline 出现问题

您需要将“\let\estinput=\input”替换为“\let\estinput=@@input”

相关内容