Sometimes you must export using from Stata to Latex very long or very large regression tables such that it does not fit into a single page. This commonly happens in preliminary analysis is you keep a maximum of control variables and tests various models side by side. One solution is to modify fonts manually in the Latex output ResultsTable.tex file by adding \footnotesize or \tiny after \caption:
\begin{table}[htbp]\centering
\caption{Main Results} \footnotesize
\begin{tabular}{l*{3}{c}}
But this must be repeated each time a modification is made to the table.
What would be the approach to modify the Latex's font size directly into STATA using the esttab package?
esttab m1 m2 m3 m4 m5 m6 m7 m8 using "ResultsTable.tex", replace booktabs compress
Thank you for any advice on this!
Though help esttab
is always useful, most solutions to tricky esttab
-to-Latex problems rely on the fact that esttab
is a wrapper for estout
, and are easily solved with estout
's prehead
option... which is not documented under esttab
.
Here is a quick MWE that approximates the information in your question:
sysuse auto
reg price mpg
estimates store m1
reg price mpg rep78
estimates store m2
reg price mpg rep78 headroom
estimates store m3
esttab m1 m2 m3 ///
using "out1.tex", ///
replace booktabs compress ///
title("Main Results")
This produces a .tex
file containing a table with the following header:
\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Main Results}
\begin{tabular}{l*{3}{c}}
\toprule
To add \footnotesize
you'll need to pass the full header from \begin{table}
to \toprule
(since you're using booktabs
) to the prehead()
option as follows:
esttab m1 m2 m3 ///
using "out2.tex", ///
replace booktabs compress ///
prehead(`"\begin{table}[htbp]\centering"' `"\footnotesize"' ///
`"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"' ///
`"\caption{Main Results}"' ///
`"\begin{tabular}{l*{@M}{c}}"' ///
`"\toprule"' ) //
Note that each line in the .tex
output is wrapped with a back-tick and apostrophe, and that the \begin{tabular}{l*{@M}{c}}
statement references @M
rather than explicitly stating the number of columns. This produces a .tex
file containing a table with the following header:
\begin{table}[htbp]\centering
\footnotesize
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Main Results}
\begin{tabular}{l*{3}{c}}
\toprule
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.