*! version 1.0 30jan2023
help fragtextab https://github.com/gaksaray/stata-gautils/

Title

fragtextab -- Fragmentize LaTeX tables exported by collect suite of commands

Syntax

fragtextab [using filename[.tex], saving(filename[.tex] [, replace]) noisily]

Description

Stata 17 introduced collect suite of commands
(collect, table, and etable),
all of which can export as LaTeX files.
TeX options include tableonly
for exporting only the table to the specified file,
which is useful for including the table in a LaTeX document
via \input{} command.
However, the output includes a table environment
in addition to the tabular environment,
which prevents using more advanced LaTeX packages
such as threeparttable.
There is no option to "fragmentize",
i.e., to suppress the table's opening and closing specifications.

fragtextab does just that!
It essentially takes a .tex file,
and throws everything out except the tabular section:

\begin

...

\end

It is usually run right after collect commands,
although not necessarily.
fragtextab can edit any .tex file specified by using option
and save to any .tex file specified by saving option.
File suffixes are optional (.tex is assumed).
If using option is omitted,
fragtextab assumes that you want to convert the most recent LaTeX table exported.
If saving option is omitted,
fragtextab assumes that you want to overwrite.
Finally, noisily option is there
if you want to print out the resulting LaTeX code to Stata console.

Examples

. sysuse auto, clear

. regress price mpg

. estimates store m1

. etable, est(m1) export(table1.tex, replace) // full compilable document

. fragtextab // only tabular environment

Author

Gorkem Aksaray, Trinity College Dublin.

Email: aksarayg@tcd.ie

Personal Website: sites.google.com/site/gorkemak

GitHub: github.com/gaksaray