Latex 错误:未定义的控制序列、外部 par 模式、水平盒子未满和过满

Latex 错误:未定义的控制序列、外部 par 模式、水平盒子未满和过满

我试图将 Stata 回归表放入 Latex 中,但我的代码出现以下错误:

Undefined control sequence \estwide{PEAssignment2tabl1.tex}{6}{c}
Not in outer par mode. \begin{table}[htbp]
Undefined control sequence \estwide{PEAssignment2tabl1.tex}{6}{c}
Undefined control sequence \estwide{PEAssignment2tabl1.tex}{6}{c}
Underfull \hbox (badness 10000) in paragraph
Underfull \hbox (badness 10000) in paragraph
Overfull \hbox (240.51797pt too wide) in paragraph

代码开始:

\documentclass[10pt]{article}
\usepackage[left=0.5in, right=0.5in, top=0.5in, bottom=0.5in]{geometry}

\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}
\title{Assignment 2 \\ \vspace{0.001 mm} {\large Program Evaluation, Spring 2014} \\             \vspace{0.001 mm} {\large Sarah Armstrong}}
\maketitle

\begin{table}
\caption{Sample Characteristics by the Amount of Co-Holding (\pounds)}
\estwide{PEAssignment2tabl1.tex}{6}{c}
\label{table2}
\end{table}


\end{document}

我找到了序言代码http://www.jwe.cc/2012/03/stata-latex-tables-estout/

答案1

发布的代码中来自 tex 的(第一个)错误不是您列出的错误之一,它是:

! Undefined control sequence.
\estwide ...tracolsep \fill }l*{#2}{#3}} \toprule 

\toprule由您尚未加载的 booktabs 包定义。如果我添加

\usepackage{booktabs}

并注释掉

  %\estinput{#1}

因为我没有该文件

您的示例运行时没有错误。

相关内容