Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Tabout tutorial: Learning Latex, using Stata 9.2 in Leopard


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: Tabout tutorial: Learning Latex, using Stata 9.2 in Leopard
Date   Mon, 1 Sep 2008 09:31:05 +0200

Hi Michael,

I have been at the point where you are now, but was extremely familiar with
Latex before I learned Stata in earnest. Top.tex and bot.tex go into the
directory that you use for your output from -tabout-, most of the time that
would be your working directory. To run Latex successfully, you need three
thing in a .tex file:

*************
\documentclass{article}

\begin{document}

\end{document}
*************

The docu-class statement gives you the kind of document you want to create.
Begin and end tell Latex where to expect the content of your document. Put
"Hello World!" between those lines and it will work. To compile, you need
all the Latex packages, which I tend to get from www.miktex.org. 

The -tabout- tutorial tells you that you should create top.tex and bot.tex.
Put the following into top.tex:

\documentclass{article}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{booktabs}
% ----------------------------------------------------------------
\begin{document}

\begin{center}
\footnotesize
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{tabularx} {#} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}} \\
\toprule


And put the following into bot.tex:


\bottomrule
\addlinespace[.75ex]
\scriptsize{\emph{Source: }#}
\end{tabularx}
\normalsize
\end{center}

\end{document}
% ----------------------------------------------------------------


Then issue the command you quoted in your post, modified as seen here and
with bot.tex and top.tex present in the same directory:


tabout foreign rep78 using table11latex.tex,  replace ///
c(mean mpg mean weight mean length median price median headroom) ///
f(1c 1c 1c 2cm 1c) ///
clab(MPG Weight_(lbs) Length_(in) Price Headroom_(in)) ///
sum npos(tufte) style(tex) bt cl2(2-4 5-6) cltr2(.75em 1.5em) ///
topstr(10cm) botstr(auto.dta) topf(top.tex) botf(bot.tex)


You get the following screen output:


\documentclass{article}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{booktabs}
% ----------------------------------------------------------------
\begin{document}

\begin{center}
\footnotesize
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\begin{tabularx} {10cm} {@{} l Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y@{}} \\
\toprule


 & \multicolumn{3}{c}{Mean} & \multicolumn{2}{c}{Median} \\
\cmidrule(l{.75em}){2-4} \cmidrule(l{.75em}){5-6}
&MPG&Weight (lbs)&Length (in)&Price&Headroom (in) \\
\midrule
Car type&&&&& \\
Domestic (70\%)&19.8&3,317.1&196.1&\$4,782.50&3.5 \\
Foreign (29\%)&24.8&2,315.9&168.5&\$5,759.00&2.5 \\
Total (100\%)&21.3&3,019.5&187.9&\$5,006.50&3.0 \\
\midrule
Repair Record 1978&&&&& \\
1 (2\%)&21.0&3,100.0&189.0&\$4,564.50&1.8 \\
2 (11\%)&19.1&3,353.8&199.4&\$4,638.00&3.8 \\
3 (43\%)&19.4&3,299.0&194.0&\$4,741.00&3.5 \\
4 (26\%)&21.7&2,870.0&184.8&\$5,751.50&3.0 \\
5 (15\%)&27.4&2,322.7&170.2&\$5,397.00&2.5 \\
Total (100\%)&21.3&3,032.0&188.3&\$5,079.00&3.0 \\


\bottomrule
\addlinespace[.75ex]
\scriptsize{\emph{Source: }auto.dta}
\end{tabularx}
\normalsize
\end{center}

\end{document}
% ----------------------------------------------------------------

Now compile this into a pdf or dvi. I use the miktex binaries for that
purpose. As they are present in the Windows environment variables, I can
call them directly from within Stata...

!texify -p -c -b --run-viewer table11latex.tex

gives you a pdf which should open in your default pdf viewer.

Omit the -p, and you get a dvi file:

!texify  -c -b --run-viewer table11latex.tex


HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Michael McCulloch
Sent: Monday, September 01, 2008 12:08 AM
To: Statalist
Subject: st: Tabout tutorial: Learning Latex, using Stata 9.2 in Leopard

Hello,
I am working on  reproducing the sample tables in the excellent 
tutorial file tabout_tutorial.pdf. My questions are:

1. Where should the files called top.tex and bottom.tex be saved?
2. The tutorial file says that " to reproduce the LATEX tables in 
this tutorial you will also need the following lines in your document 
preamble:
	\usepackage{booktabs}
	\usepackage{tabularx} "
What document does that instruction refer to?

3. Could anyone recommend a good tutorial filed in learning Latex?

4. Is Latex run within Stata,  or as a stand-alone program?

5.  After issuing a Stata command such as this below (copied from the 
-tabout- tutorial), a series of lines of Latex code are created. What 
do I do with those?

tabout foreign rep78 using table11latex.txt,  replace ///
c(mean mpg mean weight mean length median price median headroom) ///
f(1c 1c 1c 2cm 1c) ///
clab(MPG Weight_(lbs) Length_(in) Price Headroom_(in)) ///
sum npos(tufte) style(tex) bt cl2(2-4 5-6) cltr2(.75em 1.5em) ///
topstr(10cm) botstr(auto.dta)


Thank you.
-- 

Best wishes,
Michael McCulloch



Pine Street Foundation
124 Pine St., San Anselmo, CA 94960-2674
Tel:	(415) 407-1357
Fax:	(415) 485-1065
[email protected]
www.pinestreetfoundation.org
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index