'Include begin{document}, end{document} in LaTeX tables code generated in Stata
While using estpost/esttab/esttab in Stata to generate LaTeX tables, latex initialization syntax such as documentclass{}, begin{document}, and end{document} are never included. This means that every LaTeX code generated needs for these to be added.
I have many many tables to create. Is it possible to include these through Stata itself?
Solution 1:[1]
There are two potential solutions, the first is to include these using the prehead and postfoot options, which allow you to do this directly, but make table formatting a bit more difficult. Or there is the option to simply use include{asdf.tex} in another file.
Solution 1 example:
sysuse auto, clear
reg price mpg
esttab using "temp.tex", ///
prehead("\documentclass{article}\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}\begin{document}\begin{tabular}{l*{1}{c}}") ///
postfoot("\end{tabular}\end{document}") ///
replace
This will make a basic table, but doing things like including a title become more difficult with this option.
Second solution, in a tex file, you can include any number of tables thusly:
\documentclass{article}
\begin{document}
\input{any_tex_file.tex}
\input{any_tex_file2.tex}
\end{document}
and in this way you can include all of your tables.
Hope this helps
Solution 2:[2]
A better solution could be including this command into your stata esttab output commands
booktabs page(column)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eric HB |
| Solution 2 |
