Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Centering column headers using estpost tabulate (twoway) in LaTeX table
From
annoporci <[email protected]>
To
[email protected]
Subject
Re: st: Centering column headers using estpost tabulate (twoway) in LaTeX table
Date
Sun, 20 Jan 2013 04:53:20 +0800
I think you want to override the automatic alignment. I think you may be
able to achieve that by adding: layout("\multicolumn{1{c}{@}")
That and much more is discussed here:
http://tex.stackexchange.com/questions/48966/esttab-overriding-decimal-alignment
See also this:
http://www.jwe.cc/2012/03/stata-latex-tables-estout/
---
Patrick Toche.
On Sun, 20 Jan 2013 01:11:28 +0800, Bert Lloyd <[email protected]>
wrote:
Dear Statalist,
I am trying to create a simple twoway tabulation table in LaTeX using
the excellent user-written esttab command (version 2.0.5, part of the
estout package).
I am reporting both observation counts and row percentages, with the
value labels as column headers. Everything looks great using the code
below, but I would like to make one minor modification: center the
column headers between the observation count and row percent columns.
That is, currently the column header ("Domestic", "Foreign", "Total")
appears directly above the observation count column, I would like to
shift these slightly to the right so that the span both the
observation count and row percent columns. An example of what I would
like to do is found in Table 1 of the tabout tutorial, page 13 of
http://www.ianwatson.com.au/stata/tabout_tutorial.pdf.
Any advice?
Best,
BL
Stata code:
set more off
estimates clear
sysuse auto
local rowvar_label : variable label rep78
local colvar_label : variable label foreign
estpost tabulate rep78 foreign
esttab using esttab-example.tex, booktabs replace ///
cell("b rowpct(fmt(2))") collabels("N" "Row Pct") ///
unstack nonote noobs nonumber ///
eqlabels(, lhs("`rowvar_label'")) ///
nomtitles ///
mgroups("`colvar_label'", pattern(1 0 0) ///
prefix(\multicolumn{@span}{c}{) suffix(}) ///
span erepeat(\cmidrule(lr){@span}))
Generated TeX code:
{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{tabular}{l*{3}{cc}}
\toprule
&\multicolumn{6}{c}{Car type}
\\\cmidrule(lr){2-7}
Repair Record 1978& Domestic& & Foreign&
& Total& \\
& N& Row Pct& N& Row Pct&
N& Row Pct\\
\midrule
1 & 2& 100.00& 0& 0.00&
2& 100.00\\
2 & 8& 100.00& 0& 0.00&
8& 100.00\\
3 & 27& 90.00& 3& 10.00&
30& 100.00\\
4 & 9& 50.00& 9& 50.00&
18& 100.00\\
5 & 2& 18.18& 9& 81.82&
11& 100.00\\
Total & 48& 69.57& 21& 30.43&
69& 100.00\\
\bottomrule
\end{tabular}
}
pdf table:
https://dl.dropbox.com/u/2937392/esttab-twoway-tabulate-example.pdf
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/
--
Patrick Toche.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/