benjann / estout

Stata module to make regression tables
http://repec.sowi.unibe.ch/stata/estout/index.html
MIT License
71 stars 18 forks source link

Standalone option for TeX #47

Closed NilsEnevoldsen closed 2 years ago

NilsEnevoldsen commented 2 years ago

Sometimes I want to create a PDF of a table on its own, apart from any document. esttab, tex page is good for these cases, but I prefer to replace \documentclass{article} with \documentclass{standalone}. When a table is the entire document, I have no need for the page number nor for a largely arbitrary paper size, and if the table is wide I like not having to rotate or resize the paper or the table to make it fit. Standalone is great for these cases.

In fact, I'm curious if there is a use case for esttab, tex page where standalone is not preferable to article. If not, and if backward compatibility were not a concern, it would make sense for page to always imply standalone.

Regardless I would like a standalone option. I don't know whether this would be in addition to page, or as a substitute for page, or as a suboption for page, etc.

benjann commented 2 years ago

Hi Nils, great idea. My preference would probably be to add an extra option. In the meantime substitute({article} {standalone}) would do the trick.

. sysuse auto, clear
. reg price weight foreign mpg
. esttab using test.tex, replace label page substitute({article} {standalone})

Note that using the title() option will probably lead to problems as \documentclass{standalone} does not support floats, I believe.

NilsEnevoldsen commented 2 years ago

Yes, substitute() is a good workaround. Perhaps the 80/20 solution is to simply add that suggestion to the documentation under page.

Good catch on title() creating floats. But standalone does now support floats with [preview], and it seems that [varwidth] is also necessary to prevent extra whitespace. So \documentclass[preview,varwidth]{standalone} works nicely with title() from what I can tell.

benjann commented 2 years ago

I now added option standalone() to esttab. standalone() implies page. Example:

sysuse auto, clear
reg price weight foreign mpg
esttab using test.tex, replace label title("my table") standalone

By default, \documentclass[varwidth]{standalone} is used (this seems to work well in most cases, it seems to me). If you want to change this to \documentclass[preview,varwidth]{standalone}, type standalone(preview,varwidth).

NilsEnevoldsen commented 2 years ago

Thanks!

By default, \documentclass[varwidth]{standalone} is used (this seems to work well in most cases, it seems to me).

Oh, so it does.