TransWikia.com

Reduce size of a stargaze table in latex

TeX - LaTeX Asked by Mateus Maciel on January 24, 2021

I have a huge table, done with stargazer package in R, and I can not reduce its size, in order to fit my latex document. Everything has to be in a single page and I need all the information that is in this table:

documentclass{article}
usepackage[utf8]{inputenc}
usepackage{graphicx}
usepackage{amsmath}

title{Prova de Tópicos em Economia do Trabalho}
author{Mateus de Almeida Maciel  IE/UFRJ}

begin{document}

maketitle
begin{table}[!htbp] centering 
  caption{} 
  label{} 
begin{tabular}{@{extracolsep{5pt}}lc} 
[-1.8ex]hline 
hline [-1.8ex] 
 & multicolumn{1}{c}{textit{Dependent variable:}}  
cline{2-2} 
[-1.8ex] & Log-Salário  
hline [-1.8ex] 
 Intercepto & 0.072$^{***}$  
  & (0.0004)  
  &  
 Idade & $-$0.001$^{***}$  
  & (0.00000)  
  &  
 Idade ao quadrado & 0.072$^{***}$  
  & (0.005)  
  &  
 1 ano de estudo & 0.124$^{***}$  
  & (0.004)  
  &  
 2 anos de estudo & 0.179$^{***}$  
  & (0.004)  
  &  
 3 anos de estudo & 0.261$^{***}$  
  & (0.003)  
  &  
 4 anos de estudo & 0.312$^{***}$  
  & (0.004)  
  &  
 5 anos de estudo & 0.357$^{***}$  
  & (0.004)  
  &  
 6 anos de estudo & 0.399$^{***}$  
  & (0.004)  
  &  
 7 anos de estudo & 0.474$^{***}$  
  & (0.003)  
  &  
 8 anos de estudo & 0.491$^{***}$  
  & (0.005)  
  &  
 9 anos de estudo & 0.542$^{***}$  
  & (0.004)  
  &  
 10 anos de estudo & 0.707$^{***}$  
  & (0.003)  
  &  
 11 anos de estudo & 0.959$^{***}$  
  & (0.006)  
  &  
 12 anos de estudo & 1.034$^{***}$  
  & (0.006)  
  &  
 13 anos de estudo & 1.122$^{***}$  
  & (0.006)  
  &  
 14 anos de estudo & 1.455$^{***}$  
  & (0.004)  
  &  
 15 anos de estudo & 1.719$^{***}$  
  & (0.006)  
  &  
 16 anos de estudo & 2.131$^{***}$  
  & (0.008)  
  &  
 17 anos de estudo & 0.431$^{***}$  
  & (0.002)  
  &  
 Homem & $-$0.270$^{***}$  
  & (0.002)  
  &  
 Posição 2 & $-$0.169$^{***}$  
  & (0.002)  
  &  
 Posição 3 & $-$0.344$^{***}$  
  & (0.004)  
  &  
 Setor 1 & $-$0.030$^{***}$  
  & (0.004)  
  &  
 Setor 2 & $-$0.055$^{***}$  
  & (0.004)  
  &  
 Setor 3 & $-$0.027$^{***}$  
  & (0.004)  
  &  
 Setor 4 & $-$0.079$^{***}$  
  & (0.004)  
  &  
 Setor 5 & $-$0.232$^{***}$  
  & (0.015)  
  &  
 Alagos & 0.045$^{***}$  
  & (0.014)  
  &  
 Amazonas & 0.101$^{***}$  
  & (0.019)  
  &  
 Amapá & $-$0.198$^{***}$  
  & (0.013)  
  &  
 Bahia & $-$0.346$^{***}$  
  & (0.014)  
  &  
 Ceará & 0.303$^{***}$  
  & (0.015)  
  &  
 Distrito Federal & 0.024$^{*}$  
  & (0.014)  
  &  
 Espírito Santo & 0.077$^{***}$  
  & (0.014)  
  &  
 Goiás & $-$0.342$^{***}$  
  & (0.014)  
  &  
 Maranhão & $-$0.003  
  & (0.013)  
  &  
 Minas Gerais & 0.070$^{***}$  
  & (0.014)  
  &  
 Mato Grosso do Sul & 0.218$^{***}$  
  & (0.014)  
  &  
 Mato Grosso & $-$0.063$^{***}$  
  & (0.014)  
  &  
 Pará & $-$0.321$^{***}$  
  & (0.014)  
  &  
 Paraíba & $-$0.252$^{***}$  
  & (0.014)  
  &  
 Pernambuco & $-$0.503$^{***}$  
  & (0.015)  
  &  
 Piauí & 0.116$^{***}$  
  & (0.013)  
  &  
 Paraná & 0.118$^{***}$  
  & (0.013)  
  &  
 Rio de Janeiro & $-$0.251$^{***}$  
  & (0.014)  
  &  
 Rio Grande do Norte & 0.134$^{***}$  
  & (0.015)  
  &  
 Rondônia & 0.145$^{***}$  
  & (0.021)  
  &  
 Roraima & 0.129$^{***}$  
  & (0.013)  
  &  
 Rio Grande do Sul & 0.237$^{***}$  
  & (0.014)  
  &  
 Santa Catarina & $-$0.225$^{***}$  
  & (0.015)  
  &  
 Sergipe & 0.312$^{***}$  
  & (0.013)  
  &  
 São Paulo & $-$0.079$^{***}$  
  & (0.016)  
  &  
 Tocantins & 4.446$^{***}$  
  & (0.015)  
  &  
hline [-1.8ex] 
Observations & 900,000  
R$^{2}$ & 0.449  
Adjusted R$^{2}$ & 0.449  
Residual Std. Error & 13.309 (df = 899946)  
F Statistic & 13,844.440$^{***}$ (df = 53; 899946)  
hline 
hline [-1.8ex] 
textit{Note:}  & multicolumn{1}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01}  
end{tabular} 
end{table}

end{document}

One Answer

If you load the geometry package to decrease the margins and by removing vertical white spaces as wee as shortening headers and allowing lienbreaks in the contents of the first column, you can squeeze the whole table onto a single page, providd your caption is not loger than 1 line:

enter image description here

documentclass{article}
usepackage[utf8]{inputenc}
usepackage{graphicx}
usepackage{amsmath}

usepackage{geometry}

usepackage{booktabs}

usepackage{longtable}
begin{document}

begin{table}[!htbp] centering 
  caption{} 
  label{} 
begin{tabular}{@{}l@{quadquadquad}l@{}}
toprule
begin{tabular}[t]{@{}lc@{}}  
 & multicolumn{1}{@{}c@{}}{textit{Dep. var.:}}  
cmidrule{2-2} 
 & Log-Salário  
midrule 
 Intercepto & 0.072$^{***}$  
  & (0.0004)  
 Idade & $-$0.001$^{***}$  
  & (0.00000)  
 Idade ao  & 0.072$^{***}$  
 quad quadrado & (0.005)  
 1 ano de  & 0.124$^{***}$  
 quad estudo & (0.004)  
 2 anos de  & 0.179$^{***}$  
 quad estudo & (0.004)  
 3 anos de  & 0.261$^{***}$  
 quad estudo & (0.003)  
 4 anos de  & 0.312$^{***}$  
 quad estudo & (0.004)  
 5 anos de  & 0.357$^{***}$  
 quad estudo & (0.004)  
 6 anos de  & 0.399$^{***}$  
 quad estudo & (0.004)  
 7 anos de  & 0.474$^{***}$  
 quad estudo & (0.003)  
 8 anos de  & 0.491$^{***}$  
 quad estudo & (0.005)  
 9 anos de  & 0.542$^{***}$  
 quad estudo & (0.004)  
 10 anos de  & 0.707$^{***}$  
 quad estudo & (0.003)  
 11 anos de  & 0.959$^{***}$  
 quad estudo & (0.006)  
 12 anos de  & 1.034$^{***}$  
 quad estudo & (0.006)  
 13 anos de  & 1.122$^{***}$  
 quad estudo & (0.006)  
 14 anos de  & 1.455$^{***}$  
 quad estudo & (0.004)  
 15 anos de  & 1.719$^{***}$  
 quad estudo & (0.006)  
   16 anos de  & 2.131$^{***}$  
 quad estudo & (0.008)  
  17 anos de  & 0.431$^{***}$  
 quad estudo & (0.002)  
  end{tabular}
  &
  begin{tabular}[t]{@{}l@{quadquadquad}l@{}}
begin{tabular}[t]{@{}lc@{}}  
 & multicolumn{1}{@{}c@{}}{textit{Dep. var.:}}  
cmidrule{2-2} 
 & Log-Salário  
midrule 
 Homem & $-$0.270$^{***}$  
  & (0.002)  
 Posição 2 & $-$0.169$^{***}$  
  & (0.002)  
 Posição 3 & $-$0.344$^{***}$  
  & (0.004)  
 Setor 1 & $-$0.030$^{***}$  
  & (0.004)  
 Setor 2 & $-$0.055$^{***}$  
  & (0.004)  
 Setor 3 & $-$0.027$^{***}$  
  & (0.004)  
 Setor 4 & $-$0.079$^{***}$  
  & (0.004)  
 Setor 5 & $-$0.232$^{***}$  
  & (0.015)  
 Alagos & 0.045$^{***}$  
  & (0.014)  
 Amazonas & 0.101$^{***}$  
  & (0.019)  
 Amapá & $-$0.198$^{***}$  
  & (0.013)  
 Bahia & $-$0.346$^{***}$  
  & (0.014)  
 Ceará & 0.303$^{***}$  
  & (0.015)  
 Distrito  & 0.024$^{*}$  
 quad Federal & (0.014)  
 Espírito  & 0.077$^{***}$  
 quad Santo & (0.014)  
 Goiás & $-$0.342$^{***}$  
  & (0.014)  
   Maranhão & $-$0.003  
  & (0.013)  
  end{tabular}
  &
begin{tabular}[t]{@{}lc@{}}  
 & multicolumn{1}{@{}c@{}}{textit{Dep. var.:}}  
cmidrule{2-2} 
 & Log-Salário  
midrule 
 Minas  & 0.070$^{***}$  
 quad Gerais & (0.014)  
 Mato Grosso  & 0.218$^{***}$  
 quad do Sul & (0.014)  
 Mato Grosso & $-$0.063$^{***}$  
  & (0.014)  
 Pará & $-$0.321$^{***}$  
  & (0.014)  
 Paraíba & $-$0.252$^{***}$  
  & (0.014)  
 Pernambuco & $-$0.503$^{***}$  
  & (0.015)  
 Piauí & 0.116$^{***}$  
  & (0.013)  
 Paraná & 0.118$^{***}$  
  & (0.013)  
 Rio de Janeiro & $-$0.251$^{***}$  
  & (0.014)  
 Rio Grande  & 0.134$^{***}$  
 quad do Norte & (0.015)  
 Rondônia & 0.145$^{***}$  
  & (0.021)  
 Roraima & 0.129$^{***}$  
  & (0.013)  
 Rio Grande  & 0.237$^{***}$  
 quad do Sul & (0.014)  
 Santa Catarina & $-$0.225$^{***}$  
  & (0.015)  
 Sergipe & 0.312$^{***}$  
  & (0.013)  
 São Paulo & $-$0.079$^{***}$  
  & (0.016)  
 Tocantins & 4.446$^{***}$  
  & (0.015)  

end{tabular}
midrule
multicolumn{2}{@{}l@{}}{begin{tabular}{@{}lc@{}}
                   Observations & 900,000  
                   R$^{2}$ & 0.449   
                   Adjusted R$^{2}$ & 0.449  
                   Residual Std. Error & 13.309 (df = 899946)  
                   F Statistic & 13,844.440$^{***}$ (df = 53; 899946)  
                   end{tabular}
                   }
                   
midrule
multicolumn{2}{@{}l@{}}{textit{Note:} $^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01}  
end{tabular}
bottomrule
end{tabular} 
end{table}
newpage

end{document}

If you place value and error in the same row, you can save even more space:

enter image description here

documentclass{article}
usepackage[utf8]{inputenc}
usepackage{graphicx}
usepackage{amsmath}

usepackage{geometry}

usepackage{booktabs}

usepackage{longtable}
begin{document}
begin{table}[!htbp] centering 
caption{} 
label{} 
begin{tabular}{ll}
toprule
begin{tabular}[t]{@{}lrl@{}}  
 & multicolumn{2}{c}{textit{Dependent variable:}}  
cmidrule{2-3} 
 & multicolumn{2}{c}{Log-Salário}  
midrule 
 Intercepto & 0.072$^{***}$ & (0.0004)   
 Idade & $-$0.001$^{***}$ & (0.00000)   
 Idade ao quadrado & 0.072$^{***}$ & (0.005)  addlinespace
 1 ano de estudo & 0.124$^{***}$ & (0.004)  
 2 anos de estudo & 0.179$^{***}$ & (0.004) 
 3 anos de estudo & 0.261$^{***}$ & (0.003) addlinespace
 4 anos de estudo & 0.312$^{***}$ & (0.004) 
 5 anos de estudo & 0.357$^{***}$ & (0.004)  
 6 anos de estudo & 0.399$^{***}$ & (0.004)  addlinespace
 7 anos de estudo & 0.474$^{***}$ & (0.003)   
 8 anos de estudo & 0.491$^{***}$ & (0.005)   
 9 anos de estudo & 0.542$^{***}$ & (0.004) addlinespace
 10 anos de estudo & 0.707$^{***}$  & (0.003)  
 11 anos de estudo & 0.959$^{***}$   & (0.006)  
 12 anos de estudo & 1.034$^{***}$ & (0.006)  addlinespace
 13 anos de estudo & 1.122$^{***}$ & (0.006)  
 14 anos de estudo & 1.455$^{***}$ & (0.004)  
 15 anos de estudo & 1.719$^{***}$ & (0.006) addlinespace
 16 anos de estudo & 2.131$^{***}$ & (0.008)  
 17 anos de estudo & 0.431$^{***}$ & (0.002)    
 Homem & $-$0.270$^{***}$ & (0.002)   addlinespace
 Posição 2 & $-$0.169$^{***}$ & (0.002)   
 Posição 3 & $-$0.344$^{***}$ & (0.004)   
 Setor 1 & $-$0.030$^{***}$   & (0.004)  addlinespace 
 Setor 2 & $-$0.055$^{***}$ & (0.004)   
 Setor 3 & $-$0.027$^{***}$  & (0.004)   
 Setor 4 & $-$0.079$^{***}$ & (0.004)   addlinespace
 end{tabular}
 &
 begin{tabular}[t]{@{}lcc@{}}
  & multicolumn{2}{c}{textit{Dependent variable:}}  
cmidrule{2-3} 
 & multicolumn{2}{c}{Log-Salário}  
midrule 
 Setor 5 & $-$0.232$^{***}$& (0.015)  
 Alagos & 0.045$^{***}$ & (0.014)   
 Amazonas & 0.101$^{***}$ & (0.019)    addlinespace
 Amapá & $-$0.198$^{***}$  & (0.013)  
 Bahia & $-$0.346$^{***}$  & (0.014)   
 Ceará & 0.303$^{***}$  & (0.015)  addlinespace
 Distrito Federal & 0.024$^{*}$  & (0.014)  
 Espírito Santo & 0.077$^{***}$  & (0.014)  
 Goiás & $-$0.342$^{***}$  & (0.014)  addlinespace
 Maranhão & $-$0.003  & (0.013)  
 Minas Gerais & 0.070$^{***}$  & (0.014)  
 Mato Grosso do Sul & 0.218$^{***}$  & (0.014)  addlinespace 
 Mato Grosso & $-$0.063$^{***}$  & (0.014)  
 Pará & $-$0.321$^{***}$  & (0.014)  
 Paraíba & $-$0.252$^{***}$  & (0.014)  addlinespace
 Pernambuco & $-$0.503$^{***}$  & (0.015)  
 Piauí & 0.116$^{***}$  & (0.013)  
 Paraná & 0.118$^{***}$  & (0.013)  addlinespace
 Rio de Janeiro & $-$0.251$^{***}$  & (0.014)   
 Rio Grande do Norte & 0.134$^{***}$  & (0.015)  
 Rondônia & 0.145$^{***}$  & (0.021)  addlinespace
 Roraima & 0.129$^{***}$  & (0.013)   
 Rio Grande do Sul & 0.237$^{***}$  & (0.014)  
 Santa Catarina & $-$0.225$^{***}$  & (0.015)  addlinespace
 Sergipe & 0.312$^{***}$  & (0.013)  
 São Paulo & $-$0.079$^{***}$  & (0.016)  
 Tocantins & 4.446$^{***}$  & (0.015)  
 end{tabular}
midrule
multicolumn{2}{@{}l@{}}{begin{tabular}{@{}lc@{}}
                   Observations & 900,000  
                   R$^{2}$ & 0.449   
                   Adjusted R$^{2}$ & 0.449  
                   Residual Std. Error & 13.309 (df = 899946)  
                   F Statistic & 13,844.440$^{***}$ (df = 53; 899946)  
                   end{tabular}
                   }
                   
midrule
multicolumn{2}{@{}l@{}}{textit{Note:} $^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01}  
bottomrule
end{tabular}
end{table}

end{document}

Correct answer by leandriis on January 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP