Creating LaTeX documents from within Stata
texdoc is a Stata command for creating LaTeX documents from within Stata. The command provides a way to embed LaTeX code directly in a do-file and to automate the integration of results from Stata in the final document.
The texdoc command can be used, for example, to assemble automatic reports, write a Stata Journal article or a Stata Press book, prepare slides for classes, or put together solutions for homework assignments.
To install texdoc on your system, run command
ssc install texdoc, replace
in Stata. Thereafter, type
help texdoc
to view the help file. To check for updates, type
adoupdate texdoc
Alternatively, you can download texdoc from the SSC Archive and add the files to your system manually (see file readme.txt within texdoc.zip for installation instructions). Note that texdoc requires Stata 10.1 or newer.
To be able to compile a LaTeX document containing Stata output you need to
install the Stata LaTeX files on your system and include \usepackage{stata}
in the preamble of your LaTeX
document. To obtain the Stata LaTeX files, first type
net from http://www.stata-journal.com/production
net install sjlatex
to install the sjlatex
package. After that, use command
sjlatex install
to download the Stata LaTeX files; see
help sjlatex
. You may copy the files to the working directory
of your LaTeX document or, alternatively, copy the files to the search tree
of your LaTeX installation (consult the documentation of your LaTeX
installation for information on the search tree).
This website is based on the Bootstrap framework (version 3.3.7) and has been generated by webdoc. The Stata do-files of this website can be downloaded from here.
A Stata Journal article on texdoc is available from here. A working paper is available from here. For general information on Stata, see www.stata.com. For information on LaTeX see www.latex-project.org.
Presentations on texdoc:
texdoc has been written by Ben Jann.
Thanks for citing texdoc in your work in one of the following ways: