[英]Stata esttab/LaTeX Error: Extra alignment tab has been changed to \cr
Combining and modifying this code ( http://www.stata.com/statalist/archive/2012-11/msg00756.html ) and this code ( http://www.stata.com/statalist/archive/2009-02/msg00023.html ), I try to use esttab
(part of estout
) in Stata to export a file that can be compiled in LaTeX. 结合并修改此代码( http://www.stata.com/statalist/archive/2012-11/msg00756.html )和此代码( http://www.stata.com/statalist/archive/2009-02/ msg00023.html ),我尝试使用
esttab
(部分estout
在Stata)导出,可以在LaTeX的编译文件。 A real application of this might involve a complicated summary statistics table where one is pulling the statistics from several different sources and thus needs to utilize matrices. 对此的实际应用可能涉及一个复杂的摘要统计表,该表从多个不同的来源提取统计信息,因此需要利用矩阵。 I am getting an error, however, in LaTeX when I compile.
我在编译时在LaTeX中遇到错误。 The error is:
错误是:
Extra alignment tab has been changed to \cr.
Stata code: Stata代码:
clear all
eststo clear
mat A = (1,2\5,6)
mat coln A = male:1979 male:2007
mat rown A = mystat
ereturn post
estadd matrix B = A'
eststo MaleLabel
mat A = (3,4\7,8)
mat coln A = female:1979 female:2007
mat rown A = mystat
ereturn post
estadd matrix B = A'
eststo FemaleLabel
esttab MaleLabel FemaleLabel using "esttab.tex", ///
cell((B["1979"]B["2007"])) booktabs ///
mgroups("Male" "Female", pattern(1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
noobs replace nomtitles nonum
LaTeX code: LaTeX代码:
\documentclass[12pt]{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[htbp]
\begin{center}
\input{esttab}
\end{center}
\end{table}
\end{document}
The file that is produced from esttab
is: esttab
生成的文件是:
{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{tabular}{l*{2}{c}}
\toprule
&\multicolumn{2}{c}{Male} &\multicolumn{2}{c}{Female}\\\cmidrule(lr){2-3}\cmidrule(lr){4-5}
& 1979& 2007& 1979& 2007\\
\midrule
mystat & 1& 2& 3& 4\\
mystat & 5& 6& 7& 8\\
\bottomrule
\end{tabular}
}
Now, I can get things to work if I tweak this line: 现在,如果我调整此行,则可以使工作正常:
\begin{tabular}{l*{2}{c}}
to be: 成为:
\begin{tabular}{l*{2}{cc}}
(I added an extra c
.) (我添加了一个额外的
c
。)
But I only know how to do this manually. 但我只知道如何手动执行此操作。 What can I change in the Stata code to make this happen automatically?
我可以更改Stata代码以使其自动发生吗?
add this simple option to your estab code 将此简单选项添加到您的estab代码中
prehead({\\begin{tabular}{l*{2}{cc}}\\toprule)
and you are all set my man! 你们都定了我的男人!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.