![错误:未处于 estwide 表的外部 par 模式](https://linux22.com/image/351167/%E9%94%99%E8%AF%AF%EF%BC%9A%E6%9C%AA%E5%A4%84%E4%BA%8E%20estwide%20%E8%A1%A8%E7%9A%84%E5%A4%96%E9%83%A8%20par%20%E6%A8%A1%E5%BC%8F.png)
我是 TeX 新手。我尝试将表格作为在 Stata 14 中创建的 tex 文件调用。我正在使用 estwide 命令。但我收到一条错误消息“不在外部 par 模式中”。我查看了之前发布的相关问题和答案,但更改并没有纠正错误。我附上了我的代码和 tex 文件。请注意,我有 Stata 以 tex 形式创建的表格的 tex 代码。当我复制并粘贴该 tex 时,没有错误。表格已编译。但是,我正在尝试自动在 TeX 文件中添加表格和图形。我使用的是 OS X El Capitan v.10.11.4。任何帮助都将不胜感激!我无法上传我想添加的 tex 文件。但它在代码“注释”中。谢谢 E. Watson
\documentclass[letterpaper,oneside,11pt]{book}
\usepackage{graphicx}
\usepackage{amssymb,amsmath,amsthm}
%\usepackage{bm}
\usepackage[total={6in,9in}, top=1.0in, bottom=1.0in, left=1.25in, right=1.25in, includefoot]{geometry}
\usepackage{url}
\usepackage{ifthen}
\usepackage{setspace}
\usepackage{url}
\usepackage[usenames,dvipsnames]{color}
\usepackage{hyperref}
%\usepackage{longtable}
%\usepackage{lscape}
\usepackage{rotating}
\usepackage{natbib}
\usepackage{cite}
\usepackage{multirow}
%\usepackage{endfloat}
\usepackage{makebox}
\usepackage{caption}
\usepackage{subfig}
\usepackage{fancyhdr}
\usepackage{geometry}
\usepackage{bbm}
\usepackage{setspace}
\usepackage{natbib}
\usepackage{amsmath}
\usepackage{cite}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{array}
\usepackage{microtype}
\usepackage{indentfirst}
\usepackage{booktabs}
\usepackage{float}
%\renewcommand{\thetable}{\Roman{table}}
\graphicspath{{png/}}
\newcommand{\comment}[1]{}
\setcounter{MaxMatrixCols}{10}
% Alter some LaTeX defaults for better treatment of figures:
% See p.105 of "TeX Unbound" for suggested values.
% See pp. 199-200 of Lamport's "LaTeX" book for details.
% General parameters, for ALL pages:
\renewcommand{\topfraction}{0.9} % max fraction of floats at top
\renewcommand{\bottomfraction}{0.8} % max fraction of floats at bottom
% Parameters for TEXT pages (not float pages):
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4} % 2 may work better
\setcounter{dbltopnumber}{2} % for 2-column pages
\renewcommand{\dbltopfraction}{0.9} % fit big float above 2-col. text
\renewcommand{\textfraction}{0.07} % allow minimal text w. figs
% Parameters for FLOAT pages (not text pages):
\renewcommand{\floatpagefraction}{0.7} % require fuller float pages
% N.B.: floatpagefraction MUST be less than topfraction !!
\renewcommand{\dblfloatpagefraction}{0.7} % require fuller float pages
\pagestyle{empty}
%\input{math.tex}
%\input{include.tex}
\newboolean{issolution}
\setboolean{issolution}{false}
\newboolean{isdraft}
\setboolean{isdraft}{true}
%\input{tcilatex}
%%%%%% NEW PRE %%%%%
% Packages for tables
\usepackage{booktabs}% Pretty tables
\usepackage{threeparttablex}% For Notes below table
% *****************************************************************
% siunitx
% *****************************************************************
\newcommand{\sym}[1]{\rlap{#1}} % Thanks to Joseph Wright & David Carlisle
\usepackage{siunitx}
\sisetup{
detect-mode,
group-digits = false,
input-symbols = ( ) [ ] - +,
table-align-text-post = false,
input-signs = ,
}
% Character substitution that prints brackets and the minus symbol in text mode. Thanks to David Carlisle
\def\yyy{%
\bgroup\uccode`\~\expandafter`\string-%
\uppercase{\egroup\edef~{\noexpand\text{\llap{\textendash}\relax}}}%
\mathcode\expandafter`\string-"8000 }
\def\xxxl#1{%
\bgroup\uccode`\~\expandafter`\string#1%
\uppercase{\egroup\edef~{\noexpand\text{\noexpand\llap{\string#1}}}}%
\mathcode\expandafter`\string#1"8000 }
\def\xxxr#1{%
\bgroup\uccode`\~\expandafter`\string#1%
\uppercase{\egroup\edef~{\noexpand\text{\noexpand\rlap{\string#1}}}}%
\mathcode\expandafter`\string#1"8000 }
\def\textsymbols{\xxxl[\xxxr]\xxxl(\xxxr)\yyy}
% *****************************************************************
% Estout related things
% *****************************************************************
\let\estinput=\input % define a new input command so that we can still flatten the document
\newcommand{\estwide}[3]{
\vspace{.75ex}{
\textsymbols% Note the added command here
\begin{tabular*}
{\textwidth}{@{\hskip\tabcolsep\extracolsep\fill}l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular*}
}
}
\newcommand{\estauto}[3]{
\vspace{.75ex}{
\textsymbols% Note the added command here
\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
% The new approach using threeparttables to generate notes that are the exact width of the table.
\newcommand{\Figtext}[1]{%
\begin{tablenotes}[para,flushleft]
\hspace{6pt}
\hangindent=1.75em
#1
\end{tablenotes}
}
\newcommand{\Fignote}[1]{\Figtext{\emph{Note:~}~#1}}
\newcommand{\Figsource}[1]{\Figtext{\emph{Source:~}~#1}}
\newcommand{\Starnote}{\Figtext{* p < 0.1, ** p < 0.05, *** p < 0.01. Standard errors in parentheses.}}% Add significance note with \starnote
\begin{document}
\doublespacing
\section{Appendix}
%%%%%% TABLES %%%%%
\begin{table}
\centering
\begin{threeparttable}
\caption{Table1}
\estwide{/Users/Shared/Example/table1.tex}{2}{c}
\end{threeparttable}
\end{table}
%%% This part pasted from tex file stata created.
%% It compiles without error.
%\begin{table}[htbp]\centering
%\caption{Regression table\label{tab1}}
%\begin{tabular}{l*{2}{c}}
%\hline\hline
% &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}\\
% &\multicolumn{1}{c}{Price}&\multicolumn{1}{c}{Price}\\
%\hline
%Weight (lbs.) & 1.747& 3.465\\
% & (2.72)& (5.49)\\
%[1em]
%Mileage (mpg) & -49.51& 21.85\\
% & (-0.57)& (0.29)\\
%[1em]
%Car type & & 3673.1\\
% & & (5.37)\\
%[1em]
%Constant & 1946.1& -5853.7\\
% & (0.54)& (-1.73)\\
%\hline
%Observations & 74& 74\\
%\hline\hline
%\multicolumn{3}{l}{\footnotesize \textit{t} statistics in parentheses}\\
%\end{tabular}
%\end{table}
\end{document}
答案1
不在外部 par 模式中意味着您有一个table
嵌套在某个不允许表格的环境中的环境。这是另一个表格环境。
您的输入文件开始
\begin{table}[htbp]\centering
\caption{Regression table\label{tab1}}
因此它已经是一个带有标题的完整的表格浮点数,而不仅仅是表格本身。
但你试图输入它
\begin{table}
\centering
\begin{threeparttable}
\caption{Table1}
\estwide{/Users/Shared/Example/table1.tex}{2}{c}
\end{threeparttable}
\end{table}
因此将 atable
放入 a 中,threeparttable
再放入 a 中table
。这行不通,只需使用
\input{table1.tex}
或者(如果可能的话)让你的应用程序只将内部表格写入文件table1.tex
而不是将其包装起来table
,然后\caption