Thanks to Kit Baum, a new user-written module styletextab is up on SSC.
Stata 17 introduced the collect suite of commands (collect, table, etable, and, as of version 18, dtable), all of which can export tables as LaTeX files. By default, the output is a standalone compilable document, which is useful for quickly inspecting the look of the tables. styletextab improves the appearance and formatting of default LaTeX tables exported by these commands. By default, it replaces \cline with the \cmidrule of the booktabs package for aesthetically pleasing vertical spacing. It also wraps footnotes within the tablenotes environment of the threeparttable package for proper formatting (e.g., notes with the same width as the table). Additionally, styletextab offers an option to rotate tables (i.e., switch to landscape layout) by wrapping tables within the landscape environment of pdflscape package. styletextab also retains the ability to "fragmentize" ex post, i.e., to keep only the table or tabular environments for inclusion in a document via \input macro.
Typically, styletextab is executed immediately after collect exports. For example, let's say we want to export a table comparing two regression models.

We can execute styletextab immediately after exporting:

The table is restyled with booktabs and threeparttable.
We can also switch to landscape mode and back to portrait mode:

We can add a label marker, and some text before and after the table:

Finally, we can retain the table or tabular environments as follows:
Hope this is useful for quickly inspecting LaTeX table exports. Please feel free to report any issues or suggestions for improvement on my GitHub.
Stata 17 introduced the collect suite of commands (collect, table, etable, and, as of version 18, dtable), all of which can export tables as LaTeX files. By default, the output is a standalone compilable document, which is useful for quickly inspecting the look of the tables. styletextab improves the appearance and formatting of default LaTeX tables exported by these commands. By default, it replaces \cline with the \cmidrule of the booktabs package for aesthetically pleasing vertical spacing. It also wraps footnotes within the tablenotes environment of the threeparttable package for proper formatting (e.g., notes with the same width as the table). Additionally, styletextab offers an option to rotate tables (i.e., switch to landscape layout) by wrapping tables within the landscape environment of pdflscape package. styletextab also retains the ability to "fragmentize" ex post, i.e., to keep only the table or tabular environments for inclusion in a document via \input macro.
Typically, styletextab is executed immediately after collect exports. For example, let's say we want to export a table comparing two regression models.
Code:
sysuse auto, clear regress price mpg estimates store m1 regress price mpg i.foreign estimates store m2 etable, estimates(m1 m2) mstat(N) column(index) /// showstars showstarsnote /// title("Table title") /// note("Note: Table notes go here.") /// export(mytable.tex, replace)
We can execute styletextab immediately after exporting:
Code:
styletextab
The table is restyled with booktabs and threeparttable.
We can also switch to landscape mode and back to portrait mode:
Code:
styletextab, lscape styletextab
We can add a label marker, and some text before and after the table:
Code:
styletextab, /// label(fig:reg1) /// before(Table~\ref{fig:reg1} presents regressions.) /// after(This text comes after Table~\ref{fig:reg1}.)
Finally, we can retain the table or tabular environments as follows:
Code:
styletextab, tableonly styletextab, fragment
Comment