TransWikia.com

Get rid of Extra space Table

TeX - LaTeX Asked on August 28, 2021

Any suggestions to get rid of the EXTRA space table latex?

here the code and my output :

    documentclass[a4paper, 12pt]{article} 
    usepackage[margin=2cm,a4paper]{geometry}
   usepackage{natbib}
   usepackage{amsmath}
   usepackage{amsthm} 
    usepackage[protrusion=true,expansion=true]{microtype} 
   usepackage{mathpazo}
   usepackage[mathcal]{eucal}
  usepackage[mathscr]{eucal}
  usepackage{mathrsfs}
  usepackage{lmodern}
 usepackage{textcomp}
usepackage{mathtools, cuted}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage[english]{babel}
 usepackage{booktabs,dcolumn,caption}
  usepackage[font=small,labelfont={bf,sf},tableposition=top]{caption}
 usepackage{booktabs,tabularx}
 usepackage[bottom]{footmisc}
usepackage{empheq}
usepackage{graphicx}
usepackage{amssymb}
usepackage{mathtools}
usepackage{multirow}
usepackage{mathtools}
usepackage{array}
usepackage{booktabs}
usepackage{enumerate}
usepackage[english]{babel}
usepackage[latin1]{inputenc}       
usepackage{tabulary}
usepackage{tabularx}
usepackage{varioref}
usepackage{multirow}
usepackage[skip=0.5baselineskip,font=bf]{caption}
usepackage[onehalfspacing]{setspace}
usepackage{rotating}
usepackage{siunitx}
usepackage{booktabs, makecell, multirow, threeparttable}
usepackage{caption}
usepackage{xparse}    
usepackage{hyperref}
 usepackage[nameinlink,noabbrev]{cleveref} 
 usepackage{xstring}
 usepackage[title]{appendix}



begin{document}
begin{table}[ht]
centering
 caption{Contribution to volatility and levels of endogenous variables}
  begin{tabular}{l*{4}{c}r}
  hline
  Variable  & Horizon &Decomposition of volatility shocks & Decomposition of level shocks 
 hline
 hline
GNP growth (y) & 2 Q& 34.819 & 22.206  
 && textit{(23.5,28.40)}&textit{(23.2,24.2)}
 cline{2-4} &  4 Q&23.901& 18.167
 && textit{(15.52,18.65)}&textit{(11.37,12.51)}
 cline{2-4} &  8 Q& 17.684&14.316 
 && textit{(10.48,12.58)}&textit{(8.57,9.52)}
 cline{2-4} &  12 Q& 9.654& 6.18
 && textit{(2.08,2.48)}&textit{(1.07,2.42)}
 hline
 Unemployment (U) &2 Q & 8.874 & 6.245  
 && textit{(9.52,12.44)}&textit{(8.32,9.62)}
 cline{2-4} &  4 Q& 10.658 & 9.265  
 && textit{(7.08,8.46)}&textit{(6.82,7.22)}
 cline{2-4} &  8 Q& 8.840 & 6.235  
 && textit{(6.32,7.02)}&textit{(5.72,6.02)}
cline{2-4} &  12 Q& 4.902 & 3.245  
&& textit{(2.74,4.40)}&textit{(1.40,3.10)}
hline
Inflation (P) &2 Q & 34.736& 29.425  
&& textit{(13.64,14.20)}&textit{(12.12,13.14)}
cline{2-4} &  4 Q& 27.405 & 26.278  
&& textit{(13.02,12.65)}&textit{(11.02,11.40)}
cline{2-4} &  8 Q& 22.632 & 20.279  
&& textit{(1.79,11.89)}&textit{(1.62,11.72)}
cline{2-4} &  12 Q& 17.893 & 15.719  
  && textit{(10.24,0.40)}&textit{(10.12,0.19)}
 hline
 end{tabular}
  label{tab4}
   begin{tablenotes}{textwidth}
   small
   item Note:This table reports the changes in forecast error variances by level shocks and 
   volatility shock
    using the VAR model with time-varying stochastic volatility.
   end{tablenotes}  
   end{table}

 end{document}

enter image description here

2 Answers

Some suggestions and comments:

  • Do please clean up the preamble thoroughly. Absolutely nothing good can come from such a conflicted mess. Sorry to have to use such harsh words, but there's simply no adequate euphemism that might cover up the situation.

  • To make the table take up less horizontal space, you must allow line breaks in the long header cells of columns 3 and 4. You can do this either manually or with the help of the tabularx environment and the X column type. In the code below, I've chosen the tabularx route, setting the overall width to 0.8textwidth.

  • I'd use mathit rather than textit. That way, the parentheses will get rendered in upright shape and TeX will insert a bit of whitespace after the commas.

  • You're not using the machinery of the threeparttable package correctly. Indeed, your use of a tablenotes environment accomplishes nothing at all except to create code clutter. I suggest doing away with the tablenotes wrapper and using a threeparttable environment to encase the caption, the tabularx environment, and the subsequent notes. That way, width of the notes will be constrained to the width of the tabularx environment.

  • I would do away with the hline and cline instructions and, in their stead, employ the line-drawing macros of the booktabs package: toprule, midrule, addlinespace, and bottomrule.

enter image description here

documentclass[a4paper, 12pt]{article} 
usepackage[margin=2cm]{geometry}
usepackage{natbib}
usepackage{mathtools,amssymb,amsthm} 
usepackage[protrusion=true,expansion=true]{microtype} 
usepackage{mathrsfs}
usepackage{mathpazo} % or: usepackage{lmodern}
usepackage{textcomp} % are you sure you need this package?
usepackage{cuted}    % ditto
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage[english]{babel}
usepackage{dcolumn}  % ditto
usepackage[font={small,bf},
            labelfont={bf,sf},
            tableposition=top,
            justification=centering,
            figurename=Fig.,
            skip=0.333baselineskip]{caption}
usepackage{booktabs}
usepackage[bottom]{footmisc}
usepackage{empheq}         % ditto
usepackage{graphicx}
usepackage{enumerate}      % ditto   
usepackage{tabularx,tabulary}
% centered version of 'X' column type:
newcolumntype{C}{>{centeringarraybackslash}X}
usepackage[onehalfspacing]{setspace}
usepackage{rotating}
usepackage{siunitx}
usepackage{makecell, threeparttable}
usepackage{xparse,xstring} % ditto
usepackage[title]{appendix}

usepackage{varioref}  
usepackage[colorlinks,allcolors=blue]{hyperref}
usepackage[nameinlink,noabbrev]{cleveref} 

begin{document}
begin{table}[ht]
centering
begin{threeparttable}
caption{Contribution to volatility and levels of endogenous variables}
label{tab4}
 
begin{tabularx}{0.8textwidth}{@{} l c C C @{}}
toprule
Variable 
   & Horizon 
   & Decomposition of volatility shocks 
   & Decomposition of level shocks 
midrule
GNP growth (,$y$) 
   &  2 Q& 34.819 & 22.206  
   && $mathit{(23.5,28.40)}$ & $mathit{(23.2,24.2)}$
   &  4 Q& 23.901& 18.167
   && $mathit{(15.52,18.65)}$ & $mathit{(11.37,12.51)}$
   &  8 Q& 17.684&14.316 
   && $mathit{(10.48,12.58)}$ & $mathit{(8.57,9.52)}$
   &  12 Q& 9.654& 6.18
   && $mathit{(2.08,2.48)}$ & $mathit{(1.07,2.42)}$
addlinespace
Unemployment ($U$)  
   &  2 Q& 8.874 & 6.245  
   && $mathit{(9.52,12.44)}$ & $mathit{(8.32,9.62)}$
   &  4 Q& 10.658 & 9.265  
   && $mathit{(7.08,8.46)}$ & $mathit{(6.82,7.22)}$
   &  8 Q& 8.840 & 6.235  
   && $mathit{(6.32,7.02)}$ & $mathit{(5.72,6.02)}$
   &  12 Q& 4.902 & 3.245  
   && $mathit{(2.74,4.40)}$ & $mathit{(1.40,3.10)}$
addlinespace
Inflation ($P$) 
   &  2 Q& 34.736& 29.425  
   && $mathit{(13.64,14.20)}$ & $mathit{(12.12,13.14)}$
   &  4 Q& 27.405 & 26.278  
   && $mathit{(13.02,12.65)}$ & $mathit{(11.02,11.40)}$
   &  8 Q& 22.632 & 20.279  
   && $mathit{(1.79,11.89)}$ & $mathit{(1.62,11.72)}$
   &  12 Q& 17.893 & 15.719  
   && $mathit{(10.24,0.40)}$ & $mathit{(10.12,0.19)}$
bottomrule
end{tabularx}
  
medskip
Note: This table reports the changes in forecast error 
variances by level and volatility shocks, using 
the VAR model with time-varying stochastic volatility.

end{threeparttable}
end{table}
end{document}

Correct answer by Mico on August 28, 2021

I will not comment on the packages issues, review the comments by other people above. For the extra width of columns, you can use makecell{} to split the cell into two rows.

begin{table}[ht]
centering
 caption{Contribution to volatility and levels of endogenous variables}
  begin{tabular}{l*{3}{c}}
  hline
  Variable  & Horizon & makecell{Decomposition ofvolatility shocks} & makecell{Decomposition oflevel shocks} 
 hline
 hline
GNP growth (y) & 2 Q& 34.819 & 22.206  
 && textit{(23.5,28.40)}&textit{(23.2,24.2)}
 cline{2-4} &  4 Q&23.901& 18.167
 && textit{(15.52,18.65)}&textit{(11.37,12.51)}
 cline{2-4} &  8 Q& 17.684&14.316 
 && textit{(10.48,12.58)}&textit{(8.57,9.52)}
 cline{2-4} &  12 Q& 9.654& 6.18
 && textit{(2.08,2.48)}&textit{(1.07,2.42)}
 hline
 Unemployment (U) &2 Q & 8.874 & 6.245  
 && textit{(9.52,12.44)}&textit{(8.32,9.62)}
 cline{2-4} &  4 Q& 10.658 & 9.265  
 && textit{(7.08,8.46)}&textit{(6.82,7.22)}
 cline{2-4} &  8 Q& 8.840 & 6.235  
 && textit{(6.32,7.02)}&textit{(5.72,6.02)}
cline{2-4} &  12 Q& 4.902 & 3.245  
&& textit{(2.74,4.40)}&textit{(1.40,3.10)}
hline
Inflation (P) &2 Q & 34.736& 29.425  
&& textit{(13.64,14.20)}&textit{(12.12,13.14)}
cline{2-4} &  4 Q& 27.405 & 26.278  
&& textit{(13.02,12.65)}&textit{(11.02,11.40)}
cline{2-4} &  8 Q& 22.632 & 20.279  
&& textit{(1.79,11.89)}&textit{(1.62,11.72)}
cline{2-4} &  12 Q& 17.893 & 15.719  
  && textit{(10.24,0.40)}&textit{(10.12,0.19)}
 hline
 end{tabular}
  label{tab4}
   begin{tablenotes}{textwidth}
   small
   item Note:This table reports the changes in forecast error variances by level shocks and 
   volatility shock
    using the VAR model with time-varying stochastic volatility.
   end{tablenotes}  
   end{table}

enter image description here

Answered by AboAmmar on August 28, 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