您好:我正在尝试执行包含文件 (\include{...}) 中包含景观表的主文件。主文件总是停止执行并在控制台输出中打印错误:
> Output loop---1000 consecutive dead cycles. \clearpage ...rite \m@ne
> {}\vbox {}\penalty -\@Mi
> l.232 \end{landscape}
另外还有以下警告:
> Package scrlayer-scrpage Warning: \headheight to low. At least
> 23.99747pt needed, but only 18.125pt found. I'll enlarge \headheight, for further processing, but you should do this yourself, e.g., setting
> typearea's option headheight=23.99747pt'. I'll also decrease
> \topmargin on input line 20. Package scrlayer-scrpage Warning:
> \footheight to low. At least 23.99747pt needed, but only 18.125pt
> found. I'll enlarge \footheight, for further processing, but you
> should do this yourself, e.g., setting typearea's option
> footheight=23.99747pt'. I'll also increase \footskip on input line 20.
还有几个溢出的 \hbox 如下:
> Overfull \hbox (3.99596pt too wide) detected at line 14
\usepackage{scrpage2}
我以前在 Mac 上使用而不是可以毫无问题地执行同一个文件\usepackage{scrlayer-scrpage}
。最近我换用 PC 了。
感谢您提供任何帮助。
来自主文件的 MWE:
\documentclass[oneside,12pt]{scrbook}
\pagestyle{plain}
\usepackage{adjustbox}
\usepackage{pdflscape}
\usepackage{tabulary}
\usepackage{tabularx, booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage{scrlayer-scrpage}
\usepackage{threeparttable}
\let\estinput=\input
\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{-0.75ex}{
\textsymbols% Note the added command here
\begin{tabular}{l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular}
}
}
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}
}
\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.}}
\maxdeadcycles=1000\relax
\begin{document}
\begin{onehalfspacing}
\section*{Intro}
Lots of text. This first table below, which executes without problems (does not use landscape).
\begin{table}\centering
\begin{threeparttable}
\caption{Table 1: Descriptive statistics for public state investment per capita (DV)}
\estwide{descriptive_stats3_Mexico}{5}{l}
\end{threeparttable}
\end{table}
More text.
\vspace{-10 mm}
\begin{landscape}
\begin{table}\centering
\begin{threeparttable}
\caption{Table 2: Benchmark regression}
\estauto{table2_benchmark.tex}{1}{S[table-format=0.7,table-column-width=15mm]}
\starnotes
\end{threeparttable}
\end{table}
\end{landscape}
\vspace{-10 mm}
\begin{landscape}
\begin{table}\centering
\begin{threeparttable}
\caption{Table A.1: Results replicated with outliers included}
\estauto{tablea1_robust_outliers_included.tex}{5}{S[table-format=0.7,table-column-width=15mm]}
\starnotes
\end{threeparttable}
\end{table}
\end{landscape}
\section*{Conclusion}
More text.
\bibliographystyle{apacite}
\bibliography{library}
\newpage
\theendnotes
\end{document}
这是文件 table2_benchmark.tex。
&\multicolumn{1}{c}{\specialcell{Public investment\\ per capita}}\\
\midrule
FDI shock & 155.671\sym{***}\\
& (30.654) \\
L.invest\_cap & 0.443\sym{***}\\
& (0.054) \\
L.invest\_cap & \\
& \\
L.invest\_eg & \\
& \\
Total federal transfers per capita& 0.060\sym{***}\\
& (0.014) \\
State taxes per capita& -0.042 \\
& (0.058) \\
Real GDP per capita & \\
& \\
Real GDP growth (percent)& 13.107\sym{**} \\
& (5.211) \\
Population density & 2.760\sym{**} \\
& (1.084) \\
PRI governor & 145.110\sym{***}\\
& (46.721) \\
PAN governor & 210.092\sym{***}\\
& (57.322) \\
Election year dummy & -155.691\sym{***}\\
& (34.424) \\
\midrule
Observations &\multicolumn{1}{c}{571} \\
\(R^{2}\) &\multicolumn{1}{S}{0.683} \\
上面这个只有一列,但我有一些更宽的 5 列表格,我想以横向格式包含它们,例如下面的这个。
Name: tablea1_robust_outliers_included.tex
&\multicolumn{1}{c}{\specialcell{Public investment\\ per capita}}&\multicolumn{1}{c}{\specialcell{Public investment\\ per capita}}&\multicolumn{1}{c}{\specialcell{Current spending\\ per capita}}&\multicolumn{1}{c}{\specialcell{Public debt\\ per capita}}&\multicolumn{1}{c}{\specialcell{Public debt\\ /real GDP}}\\
\midrule
FDI shock & 149.696\sym{***}& & -130.202\sym{**} & -237.688\sym{**} & -0.002\sym{***}\\
& (51.078) & & (59.197) & (92.431) & (0.001) \\
FDI shock (1.5 std deviations) & & 154.018\sym{**} & & & \\
& & (64.110) & & & \\
Total federal transfers per capita& 0.066\sym{***}& 0.065\sym{***}& 0.154\sym{***}& -0.116\sym{***}& -0.000\sym{**} \\
& (0.025) & (0.025) & (0.029) & (0.039) & (0.000) \\
Total public federal investment per capita& -0.000\sym{**} & -0.000\sym{**} & 0.000\sym{***}& -0.000 & -0.000 \\
& (0.000) & (0.000) & (0.000) & (0.000) & (0.000) \\
State taxes per capita& -0.047 & -0.040 & 0.167 & 2.010\sym{***}& 0.000\sym{***}\\
& (0.142) & (0.141) & (0.144) & (0.517) & (0.000) \\
Real GDP per capita & 0.000 & 0.000 & -0.000 & 0.002\sym{***}& 0.000\sym{***}\\
& (0.000) & (0.000) & (0.000) & (0.001) & (0.000) \\
Real GDP growth (percent)& 11.786 & 12.115 & 16.945\sym{**} & 2.240 & -0.000 \\
& (8.278) & (8.296) & (7.141) & (8.502) & (0.000) \\
Population density & 3.641\sym{**} & 3.890\sym{**} & 5.243\sym{***}& -11.485\sym{***}& -0.000\sym{***}\\
& (1.777) & (1.735) & (1.181) & (2.576) & (0.000) \\
PRI governor & 146.660\sym{**} & 137.884\sym{**} & -7.245 & -426.912\sym{***}& -0.002\sym{**} \\
& (60.630) & (59.728) & (75.797) & (150.507) & (0.001) \\
PAN governor & 219.231\sym{***}& 210.680\sym{***}& -59.692 & -157.941 & -0.000 \\
& (65.856) & (65.447) & (87.952) & (131.951) & (0.001) \\
Election year dummy & -153.171\sym{***}& -156.498\sym{***}& 43.552 & 43.280 & 0.000 \\
& (44.702) & (45.075) & (49.376) & (54.645) & (0.001) \\
Margin of victory for state governor& -21.669 & -41.144 & 133.284 & 792.233 & 0.011\sym{***}\\
& (183.507) & (179.794) & (215.383) & (428.729) & (0.004) \\
\midrule
Observations &\multicolumn{1}{c}{558} &\multicolumn{1}{c}{558} &\multicolumn{1}{c}{558} &\multicolumn{1}{c}{558} &\multicolumn{1}{c}{558} \\
\(R^{2}\) &\multicolumn{1}{S}{0.683} &\multicolumn{1}{S}{0.679} &\multicolumn{1}{S}{0.988} &\multicolumn{1}{S}{0.634} &\multicolumn{1}{S}{0.552} \\
答案1
- 提供的代码有误,因此没有用。
- 该
scrpage2
包已过时,最好使用scrlayer-scrpage
包(在我的 MWE 中运行良好)。 - 我从代码片段中合并相关代码片段形成了 MWE(最小工作示例),它应该可以重现您的问题。
- 从表格代码也可以看出,它比横向页面上的文本区域更大。
- 为了使表格适合页面,我建议使用较小的字体大小并缩小
\arraystertch
(请参阅下面的 MWE)。
\documentclass[oneside,12pt]{scrbook}
\pagestyle{plain}
\usepackage{pdflscape}
\usepackage{booktabs, makecell, tabularx, threeparttable}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage{scrlayer-scrpage}
\usepackage{siunitx}
\usepackage{afterpage}
\newcommand\StErr{%
\begin{tablenotes}[para,flushleft]
\item[*] $p < 0.1$,
\item[**] $p < 0.05$,
\item[***] $p < 0.01$. Standard errors in parentheses.
\end{tablenotes}
}
\usepackage{lipsum}
\begin{document}
\section*{Intro}
\lipsum[11]
\begin{table}[ht]
\centering
\begin{threeparttable}
\caption{Descriptive statistics for public state investment per capita (DV)}
\label{tab:statistic}
\begin{tabular}{lS[input-open-uncertainty= ,
input-close-uncertainty= ,
table-space-text-pre=(,
table-space-text-post={***},
table-align-text-pre=false,
table-format=-3.3]}
\toprule
& {\makecell{Public investment\\ per capita}}\\
\midrule
FDI shock & 155.671\tnote{***} \\
& (30.654) \\
L.invest\_cap & 0.443\tnote{***} \\
& (0.054) \\
L.invest\_cap & \\
& \\
L.invest\_eg & \\
& \\
Total federal transfers per capita
& 0.060\tnote{***} \\
& (0.014) \\
State taxes per capita
& -0.042 \\
& (0.058) \\
Real GDP per capita & \\
& \\
Real GDP growth (percent)
& 13.107\tnote{**} \\
& (5.211) \\
Population density & 2.760\tnote{**} \\
& (1.084) \\
PRI governor & 145.110\tnote{***} \\
& (46.721) \\
PAN governor & 210.092\tnote{***} \\
& (57.322) \\
Election year dummy & -155.691\tnote{***} \\
& (34.424) \\
\midrule
Observations & {571} \\
\(R^{2}\) & {0.683} \\
\bottomrule
\end{tabular}
\StErr
\end{threeparttable}
\end{table}
\afterpage{
\begin{landscape}
\begin{table}[ht]
\small
\renewcommand\arraystretch{0.8}
\begin{threeparttable}
\caption{Benchmark regression}
\label{tab:benchmark}
\begin{tabularx}{\linewidth}{X
*{5}{S[input-open-uncertainty= ,
input-close-uncertainty= ,
table-space-text-pre=(,
table-space-text-post={***},
table-align-text-pre=false,
table-format=-3.3]}
}
\toprule
& {\makecell[b]{PI\\ per capita}}
& {\makecell[b]{PI\\ per capita}}
& {\makecell[b]{CS\\ per capita}}
& {\makecell[b]{Public debt\\ per capita}}
& {\makecell[b]{Public debt/\\ real GDP}}\\
\midrule
FDI shock
& 149.696\tnote{***}
& & -130.202\tnote{**}
& -237.688\tnote{**}
& -0.002\tnote{***} \\
& (51.078)
& & (59.197)
& (92.431)
& (0.001) \\ \addlinespace
FDI shock (1.5 std deviations)
& & 154.018\tnote{**}
& & & \\
& & (64.110)
& & & \\ \addlinespace
Total federal transfers per capita
& 0.066\tnote{***}
& 0.065\tnote{***}
& 0.154\tnote{***}
& -0.116\tnote{***}
& -0.000\tnote{**} \\
& (0.025)
& (0.025)
& (0.029)
& (0.039)
& (0.000) \\ \addlinespace
Total public federal investment per capita
& -0.000\tnote{**}
& -0.000\tnote{**}
& 0.000\tnote{***}
& -0.000
& -0.000 \\
& (0.000)
& (0.000)
& (0.000)
& (0.000)
& (0.000) \\ \addlinespace
State taxes per capita
& -0.047
& -0.040
& 0.167
& 2.010\tnote{***}
& 0.000\tnote{***} \\
& (0.142)
& (0.141)
& (0.144)
& (0.517)
& (0.000) \\ \addlinespace
Real GDP per capita
& 0.000
& 0.000
& -0.000
& 0.002\tnote{***}
& 0.000\tnote{***} \\
& (0.000)
& (0.000)
& (0.000)
& (0.001)
& (0.000) \\ \addlinespace
Real GDP growth (percent)
& 11.786
& 12.115
& 16.945\tnote{**}
& 2.240
& -0.000 \\
& (8.278)
& (8.296)
& (7.141)
& (8.502)
& (0.000) \\ \addlinespace
Population density
& 3.641\tnote{**}
& 3.890\tnote{**}
& 5.243\tnote{***}
& -11.485\tnote{***}
& -0.000\tnote{***} \\
& (1.777)
& (1.735)
& (1.181)
& (2.576)
& (0.000) \\ \addlinespace
PRI governor
& 146.660\tnote{**}
& 137.884\tnote{**}
& -7.245
& -426.912\tnote{***}
& -0.002\tnote{**} \\
& (60.630)
& (59.728)
& (75.797)
& (150.507)
& (0.001) \\ \addlinespace
PAN governor
& 219.231\tnote{***}
& 210.680\tnote{***}
& -59.692
& -157.941
& -0.000 \\
& (65.856)
& (65.447)
& (87.952)
& (131.951)
& (0.001) \\ \addlinespace[2pt]
Election year dummy
& -153.171\tnote{***}
& -156.498\tnote{***}
& 43.552
& 43.280
& 0.000 \\
& (44.702)
& (45.075)
& (49.376)
& (54.645)
& (0.001) \\ \addlinespace[2pt]
Margin of victory for state governor
& -21.669
& -41.144
& 133.284
& 792.233
& 0.011\tnote{***} \\
& (183.507)
& (179.794)
& (215.383)
& (428.729)
& (0.004) \\
\midrule
Observations
& {558} & {558} & {558} & {558} & {558} \\
\(R^{2}\)
& 0.683 & 0.679 & & & \\
\bottomrule
\end{tabularx}
\begin{tablenotes}[para,flushleft]
PI: Public investment, \quad
CS: Current spending
\item[*] $p < 0.1$,
\item[**] $p < 0.05$,
\item[***] $p < 0.01$. Standard errors in parentheses.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{landscape}
}
\lipsum[12]
\end{document}
其生产成果为:
在 MWE 中你可以观察到,
- 在 MWE 中仅考虑与您的问题相关的包和定义
- 我没有考虑您对命令的(错误)定义。如果您喜欢将表代码放在单独的文件中,那么您可以将表主体(所有表主体和文件之间)存储
\begin{table}
在\end{table}
名为“tablea1_robust_outliers_included”的文件中,并将其包含在主文件中,如下所示:
\begin{table}[ht]
\input{tablea1_robust_outliers_included}
\end{table}
- 重命名(为
\StErr
)并重新设计插入表格注释的命令threeparttable
。其工作原理在第一个表格中得到演示 - 重新设计
S
列规范,现在它可以工作了 - 用包中定义的宏替换
\multicolumn{1}{c}{...}
和(在序言中添加的 MWE 中)\specialcell
\makecell
makecell
- 您可以观察到,我的 MWE 在使用该包时没有任何问题
scrlayer-scrpage
,并且对横向页面上的位置表也没有影响。
编辑:
在 MWE 的第一个版本中,我忘记为第一个表格添加标题,也没有更正标题文本,其中“表格 1:”和“表格 2:”是多余的(它们已经由命令生成\caption
)。
除这些变化之外,现在还添加了afterpage
能够更好地格式化文档的包。