How to use Lablogger

Lablogger is a Stata plug-in, and can be mixed with Stata commands, for example in Do-files, or in the interactive mode.

Installation

You can install lablogger through the net command:

net install lablogger, from(http://www.elwyndavies.nl/)

Opening and closing

You start writing to Lablogger using the new command:

lablogger new using "lablogger_demo.tex", title("Lablogger demo") author("Elwyn Davies")

At the end of every document, you must use the close command to finish the document.

lablogger close

You can also run Texify straight after generating the tex file:

lablogger close, texify view

Including text, sections and lists

You can include texts, sections and lists using the following commands:

lablogger section "Section 1"

lablogger subsection "Subsection 1.1"

lablogger text "This is a paragraph of text. It will be included into LaTex as a separate paragraph."

lablogger itemize start
lablogger item "Bullet point 1"
lablogger item "Bullet point 2"
lablogger item "Bullet point 3"
lablogger itemize end

lablogger enumerate start
lablogger item "Item 1"
lablogger item "Item 2"
lablogger item "Item 3"
lablogger enumerate end

This will be added straight to the .tex file, in the order of the commands.

Including Stata output (verbatim)

This can be done in two ways, as a prefix, or by using the on and off commands:

lablogger: describe
lablogger: sum

Or:

lablogger on
describe
sum
lablogger off

This will include the literal Stata output in a preformatted format into the LaTeX file (using the verbatim environment).

Note that you will need to run the do-files using the do command in Stata, not using the run command. If you use the run command, no Stata output will be generated and it will not be included in your LaTeX document.

Including a figure

This can be done in two ways:

graph twoway scatter price mpg
graph export "scatter.pdf", replace
lablogger figure using "scatter.pdf", width(0.50\textwidth) caption("Scatter plot of price and mileage")

(Note that you first must generate the PDF file of the graph before you can include it.)

Or, using the graph export prefix notation:

lablogger graph export: graph twoway scatter price mpg

Also here you can specify options:

lablogger graph export, width(0.50\textwidth) caption("Plot"): graph twoway scatter price mpg

In this case, a PDF file with the graph will be created automatically (e.g. graph1.pdf). Lablogger will use the graph export command to achieve this.

Including a table

When you use a package that generate TeX output, you can directly embed this into your LaTeX file. This can be done in two ways:

eststo drop *
eststo: reg price mpg
eststo: reg price mpg length weight
eststo: reg price mpg length weight foreign
esttab * using "tab.tex", label booktabs replace
lablogger table using "tab.tex", caption("Table")

Or a shortcut, using the prefix notation:

eststo drop *
eststo: reg price mpg
eststo: reg price mpg length weight
eststo: reg price mpg length weight foreign
lablogger table: esttab * using "tab.tex", label booktabs replace

Also here you can specify options:

lablogger table, caption("Table caption"): esttab * using "tab.tex", label booktabs replace

When using the shortcut, it is very important that you use a command that specifies a filename for the table after using. Lablogger will read this file, and append it to your final LaTeX file. If there is no “using filename.tex” bit included in the Stata command, it will not work, as Lablogger will fail to locate the output. Also, you will need to specify the extension of the file. The following will not work:

* Will not work - No file name given:
lablogger table: esttab *, label booktabs

* Will not work - No extension given:
lablogger table: esttab * using "texfile", label booktabs

It should work with every command that includes using in its syntax:

lablogger table: outreg2 using "output.tex", replace