{"id":878,"date":"2015-02-17T08:09:30","date_gmt":"2015-02-17T13:09:30","guid":{"rendered":"http:\/\/www.hargaden.com\/enda\/?p=705"},"modified":"2015-02-17T08:09:30","modified_gmt":"2015-02-17T13:09:30","slug":"fitting-tables-to-the-width-of-a-page","status":"publish","type":"post","link":"https:\/\/hargaden.com\/enda\/fitting-tables-to-the-width-of-a-page\/","title":{"rendered":"Fitting tables to the width of a page"},"content":{"rendered":"<p>Ever have the problem of Stata regression output being a little too wide? Worry no more.<\/p>\n<p>I use Ben Jann&#8217;s excellent <a href=\"http:\/\/repec.org\/bocode\/e\/estout\/hlp_esttab.html\">esttab<\/a> to export Stata regressions into LaTeX documents.<\/p>\n<p>My only problem with esttab is that the tables can be too wide, i.e. wider than the width of the text in the PDF. So I made a few edits to esttab that automatically scale the tables to the text-width.<\/p>\n<p>I have called this program <tt><b>estwide<\/b><\/tt>. You can <a href=\"\/enda\/wp-content\/estwide.ado\">download it here<\/a>. As it is based on estout, Ben Jann should be considered a co-author. <a href=\"\/enda\/wp-content\/estwide_example.pdf\">Click here<\/a> to see an example of its effect. (If you wish to replicate the above example, you can download the associated <a href=\"\/enda\/wp-content\/cars.do\">do-file here<\/a> and the <a href=\"\/enda\/wp-content\/estwide_example.tex\">TeX file here<\/a>.)<\/p>\n<p><b>To use estwide:<\/b><br \/>\n1. Make sure estout is installed. To do this, in Stata type <tt>ssc inst estout, replace<\/tt><br \/>\n2. Save <a href=\"\/enda\/wp-content\/estwide.ado\">estwide.ado<\/a> to the same folder that estout is now installed in. You can check the folder by typing <tt>which estout<\/tt><br \/>\n3. Restart Stata.<br \/>\n4. Rather than exporting your tables using the esttab command, simply replace esttab with estwide, e.g. <tt>estwide using hello.tex, style(tex) replace<\/tt><br \/>\n5. Make sure you have both the <a href=\"https:\/\/www.ctan.org\/pkg\/adjustbox\">adjustbox<\/a> and <a href=\"https:\/\/www.ctan.org\/tex-archive\/macros\/latex\/contrib\/booktabs\/\">booktabs<\/a> LaTeX packages installed.<br \/>\n6. Make sure you have called both of these packages up by including <tt>\\usepackage{booktabs}<\/tt> and <tt>\\usepackage{adjustbox}<\/tt> in the header of your LaTeX file.<br \/>\n7. Include your tables as normal. You can copy and paste the output into your TeX file, or have the tables update automatically when you make changes by using <tt>\\input{myfilename}<\/tt>.<\/p>\n<p><b>Update, September 2017<\/b>: after some emails from people, I have two things to add. Firstly, estwide seems to work much better if you include a caption to the table.<\/p>\n<p>Secondly, if you have a problem with the caption appearing on one page and the table itself on another, wrap the input in a LaTeX table. For example, this code works well for me:<br \/>\n\\begin{table}[ht]<br \/>\n\\input{myfilename}<br \/>\n\\end{table}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever have the problem of Stata regression output being a little too wide? Worry no more. I use Ben Jann&#8217;s excellent esttab to export Stata regressions into LaTeX documents. My only problem with esttab is&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,8,10],"tags":[],"class_list":["post-878","post","type-post","status-publish","format-standard","hentry","category-economics","category-latex","category-stata"],"_links":{"self":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/posts\/878","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/comments?post=878"}],"version-history":[{"count":0,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/posts\/878\/revisions"}],"wp:attachment":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/media?parent=878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/categories?post=878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/tags?post=878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}