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:

- Ben Jann: Creating LaTeX and HTML documents from within Stata using texdoc and webdoc, Swiss Stata Users Group meeting, Bern, November 2016, 2016 (slides, example 1, example 2, example 3).
- Ben Jann: Creating LaTeX and HTML documents from within Stata using texdoc and webdoc, Nordic and Baltic Stata Users Group meeting, Oslo, September 13, 2016 (slides, example 1, example 2).
- Ben Jann: texdoc 2.0: An update on creating LaTeX documents from within Stata, UK Stata Users Group meeting, London, September 8–9, 2016 (slides and examples).
- Ben Jann: texdoc 2.0: An update on creating LaTeX documents from within Stata, Belgian Stata Users Group meeting, Brussels, September 6, 2016 (slides).
- Ben Jann: texdoc 2.0: An update on creating LaTeX documents from within Stata, German Stata Users Group meeting, Cologne, June 10, 2016 (slides, example 1, example 2).
- Ben Jann: Creating LaTeX documents from within Stata, German Stata Users Group meeting, Bonn, June 26, 2009. (slides).

texdoc has been written by Ben Jann.

Thanks for citing texdoc in your work in one of the following ways:

- Jann, Ben (2016). Creating LaTeX documents from within Stata using texdoc. The Stata Journal 16(2): 245-263.
- Jann, Ben (2015). Creating LaTeX documents from within Stata using texdoc. University of Bern Social Sciences Working Papers No. 14. Available from http://ideas.repec.org/p/bss/wpaper/14.html.
- Jann, Ben (2009). TEXDOC: Stata module to create a LaTeX document including Stata output. Available from http://ideas.repec.org/c/boc/bocode/s457021.html.