[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: New -texdoc- package available from SSC

From   Ben Jann <>
To   statalist <>
Subject   st: New -texdoc- package available from SSC
Date   Mon, 23 Mar 2009 23:49:14 +0100

Thanks to Kit Baum, a new package called -texdoc- is available from
SSC. To install the package, type

 . ssc install texdoc

Stata version 9.2 and -sjlatex- from is required.

-texdoc- provides tools to create a LaTeX document from within Stata
in a weaving fashion. I wrote -texdoc- for teaching, but it might also
be useful for other purposes, e.g., when writing a Stata Journal

The procedure is to first initialize a document using -texdoc init-,
then write the contents of the file, line by line, by repeated calls
to -tex- or include Stata output using -texdoc stlog-, and finally
finish up typing -texdoc close-. Example:

texdoc init example, replace
tex \documentclass{article}
tex \usepackage{stata}
tex \begin{document}
tex The auto data:

texdoc stlog
sysuse auto
texdoc stlog close

tex A regression model:

texdoc stlog
regress price weight mpg foreign
texdoc stlog close

tex \end{document}
texdoc close

The code above will produce a main file called example.tex and several
log files that are called by example.tex. example.tex looks as


The auto data:

A regression model:


You can now compile example.tex using your favorite LaTeX compiler to
produce the desired document.

If you use an editor that features syntax highlighting it might be a
good idea to set up a shortcut to quickly toggle between LaTeX and
Stata highlighting. Furthermore, some editors can be configured in a
way such that "tex " is automatically inserted at the beginning of a
new line when LaTeX highlighting is on.

*   For searches and help try:

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