0

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/

Hugh
  • 15
  • 2
    Welcome to TeX.SE. Your code appears to require an external file (called desc.tex?) that only you have. Please make your code more readily compilable. – Mico Sep 15 '21 at 20:54
  • @Mico I have edited the MWE. I am still getting the error. Can you please let me know why that is the case? Thanks. – Hugh Sep 20 '21 at 08:52
  • are you asking about "Package siunitx Error: Invalid number 'e'."? – Mico Sep 20 '21 at 12:18
  • Incidentally, I have no idea what you're trying to achieve with \estauto, \estwide, etc are. Sorry, but my mind-reading capabilities are worthless. – Mico Sep 20 '21 at 12:22

1 Answers1

0

The solution to your problem can be found here:

Problems with \input{table.tex}\hline after 2020 fall LaTeX release

You need to replace "\let\estinput=\input" with "\let\estinput=@@input"

  • Thanks @Nicholas. I am now getting the error message ! LaTeX Error: Missing \begin{document}. I don't understand as it is clearly below the preamble. – Hugh Sep 20 '21 at 18:56
  • Try using the \makeatletter command:
    `` \makeatletter %this is needed to allow latex to revert to prior installations to fix noalign error \let\estinput=@@input %define a new input command so that we can still flatten the document

    \newcommand{\estwide}[3]{ %estwide environment \vspace{.75ex}{ \begin{tabular} {\textwidth}{@{\hskip\tabcolsep\extracolsep\fill}l{#2}{#3}} \toprule \estinput{#1} \bottomrule \addlinespace[.75ex] \end{tabular*} } } ``

    – Nicholas Sep 20 '21 at 21:12
  • Thanks @Nicholas. Your solution worked. I appreciate your help. I actually came across the link you sent a few days ago as I was looking for a solution but did not pay much attention to it. – Hugh Sep 20 '21 at 21:49
  • I have just discovered that Stata 17 (i.e. the latest version) has improved the functionality of the -table- command. I have not read the post yet but it may be an alternative to -esttab- to export tables to LaTeX. Here is the link: https://www.stata.com/stata-news/news36-3/customizable-tables/ – Hugh Sep 21 '21 at 08:52