4

I have the following table, which is too wide for the page. Now I want to fit this table into this set page. Where shall I modify here? I tried to change {@{\extracolsep{5pt}}lcccc} into {@{\extracolsep{\fill}}ccccc} but it made no sense.

\documentclass[12pt, a4paper, leqno]{article}
\usepackage{a4wide}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{float, afterpage, rotating, graphicx}
\usepackage{epstopdf}
\usepackage{longtable, booktabs, tabularx}
\usepackage{fancyvrb, moreverb, relsize}
\usepackage{eurosym, calc}
\usepackage{amsmath, amssymb, amsfonts, amsthm, bm}
\usepackage{newtxtext,newtxmath}
\usepackage{caption}
\usepackage{mdwlist}
\usepackage{xfrac}
\usepackage{setspace}
\usepackage{xcolor}
\usepackage{subcaption}
\usepackage{minibox}
\usepackage{geometry}
\geometry{
 left=3cm,
 right=2cm,
 top=2cm,
 bottom=2cm,
}
\usepackage{setspace}
\onehalfspacing
\usepackage[unicode=true]{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    anchorcolor=black,
    citecolor=black,
    filecolor=black,
    menucolor=black,
    runcolor=black,
    urlcolor=black
}

\widowpenalty=10000
\clubpenalty=10000

\setlength{\parskip}{2ex}
\setlength{\parindent}{0ex}
\setstretch{1.5}

\begin{document}
\begin{table}[!htbp] \centering 
  \caption{} 
  \label{} 
\begin{tabular}{@{\extracolsep{5pt}}lcccc} 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
 & \multicolumn{4}{c}{\textit{Dependent variable:}} \\ 
\cline{2-5} 
\\[-1.8ex] & \multicolumn{4}{c}{democracy} \\ 
\\[-1.8ex] & (1)Unbalanced Fixed Effect & (2)Balanced Fixed Effect & (3)Unbalanced Fixed Effect & (4)Balanced Fixed Effect\\
\\[-1.8ex] & for Non-colonial Countries & for Non-colonial Countries & for Colonial Countries & for Colonial Countries\\
\hline \\[-1.8ex] 
 lag(d) & 0.123$^{***}$ & 0.456$^{***}$ & 0.789$^{***}$ & 0.567$^{***}$ \\ 
  & (0.010) & (0.020) & (0.030) & (0.040) \\ 
  & & & & \\ 
 lag(y) & 0.012 & 0.123 & $-$0.234$^{*}$ & $-$0.456$^{*}$ \\ 
  & (0.012) & (0.089) & (0.045) & (0.078) \\ 
  & & & & \\
\hline \\[-1.8ex] 
Observations & 901 & 574 & 1,297 & 826 \\ 
R$^{2}$ & 0.692 & 0.407 & 0.641 & 0.402 \\ 
Adjusted R$^{2}$ & 0.656 & 0.298 & 0.602 & 0.296 \\ 
F Statistic & 150.795$^{***}$ (df = 12; 807) & 41.478$^{***}$ (df = 8; 484) & 173.803$^{***}$ (df = 12; 1167) & 58.898$^{***}$ (df = 8; 700) \\ 
\hline 
\hline \\[-1.8ex] 
\textit{Note:}  & \multicolumn{4}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{table}
  • Welcome to TeX.SX! You will not be able to fit this particular table into the available space while keeping the text size readable unless you are willing to add some linebreaks, for example in the header rows as well as in the "F Statistic" row. – leandriis Sep 5 at 14:09
  • Changing @{\extracolsep{5pt}} to @{\extracolsep{\fill}} only makes sense when used with a tabular* environment. – Mico Sep 5 at 20:22
4

With linebreaks in the header columns, some \multicolumn commands in the header part to remove repeated information and a new row for "df", as well as horizontal lines from the booktabs package:

enter image description here

\documentclass[12pt, a4paper, leqno]{article}
\usepackage{a4wide}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{float, afterpage, rotating, graphicx}
\usepackage{epstopdf}
\usepackage{longtable, booktabs, tabularx}
\usepackage{fancyvrb, moreverb, relsize}
\usepackage{eurosym, calc}
\usepackage{amsmath, amssymb, amsfonts, amsthm, bm}
\usepackage{newtxtext,newtxmath}
\usepackage{caption}
\usepackage{mdwlist}
\usepackage{xfrac}
\usepackage{setspace}
\usepackage{xcolor}
\usepackage{subcaption}
\usepackage{minibox}
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize}
\usepackage{geometry}
\geometry{
 left=3cm,
 right=2cm,
 top=2cm,
 bottom=2cm,
}
\usepackage{setspace}
\onehalfspacing
\usepackage[unicode=true]{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    anchorcolor=black,
    citecolor=black,
    filecolor=black,
    menucolor=black,
    runcolor=black,
    urlcolor=black
}

\widowpenalty=10000
\clubpenalty=10000

\setlength{\parskip}{2ex}
\setlength{\parindent}{0ex}
\setstretch{1.5}

\begin{document}
\begin{table}[!htbp] \centering 
  \caption{} 
  \label{} 
\begin{tabular}{lcccc} 
\toprule
 & \multicolumn{4}{c}{\textit{Dependent variable:}} \\ 
\cmidrule{2-5} 
 & \multicolumn{4}{c}{democracy} \\ 
\cmidrule{2-5}
 & \multicolumn{2}{c}{Non-colonial Countries} & \multicolumn{2}{c}{Colonial Countries}\\
 \cmidrule(r){2-3} \cmidrule(l){4-5}
  & \thead{(1)\\ Unbalanced\\ Fixed Effect} 
    & \thead{(2)\\Balanced\\ Fixed Effect}
      & \thead{(3)\\Unbalanced\\ Fixed Effect} 
        & \thead{(4)\\Balanced\\ Fixed Effect}\\
\midrule
 lag(d) & 0.123$^{***}$ & 0.456$^{***}$ & 0.789$^{***}$ & 0.567$^{***}$ \\ 
  & (0.010) & (0.020) & (0.030) & (0.040) \\ 
\addlinespace
 lag(y) & 0.012 & 0.123 & $-$0.234$^{*}$ & $-$0.456$^{*}$ \\ 
  & (0.012) & (0.089) & (0.045) & (0.078) \\ 
\midrule
Observations & 901 & 574 & 1,297 & 826 \\ 
R$^{2}$ & 0.692 & 0.407 & 0.641 & 0.402 \\ 
Adjusted R$^{2}$ & 0.656 & 0.298 & 0.602 & 0.296 \\ 
F Statistic & 150.795$^{***}$  & 41.478$^{***}$  & 173.803$^{***}$  & 58.898$^{***}$ \\
df  & 12; 807 &  8; 484 &  12; 1167 &  8; 700  \\ 
\bottomrule
\textit{Note:}  & \multicolumn{4}{r}{$^{*}$p$<$0.1; $^{**}$p$<$0.05; $^{***}$p$<$0.01} \\ 
\end{tabular} 
\end{table}
\end{document}
| improve this answer | |
  • It works!!! Thank you!!! – w12345678 Sep 5 at 16:48
4

With use of the threeparttablex (for table notes) and siunitx (for S columns) packages ... and small modification of your table:

\documentclass[12pt, leqno]{article}
\usepackage[left=3cm,right=2cm,
          vmargin=2cm]{geometry}

\usepackage{booktabs, makecell}
\usepackage[referable]{threeparttablex}
\renewcommand{\theadfont}{\normalsize}

\usepackage{siunitx}


\begin{document}
    \begin{table}[!htbp] 
    \centering
\begin{threeparttable}
\caption{My table}
\label{tab:mytable}
\begin{tabular}{l *{4}{S[table-format=3.3,
                         table-space-text-post=$^{***}$,
                         table-align-text-post=false,
                         input-symbols={( - ) }
                         ]
                      }
                }
    \toprule
%    & \multicolumn{4}{c}{\textit{Dependent variable:}} \\
%\cmidrule{2-5}
    & \multicolumn{4}{c}{Fixed Effect of $d$ and $y$ at type of Democracy}     \\
    \cmidrule{2-5}
    &   \multicolumn{2}{c}{Non-colonial Countries} 
        &   \multicolumn{2}{c}{Colonial Countries}      \\           
    \cmidrule(l){2-3}\cmidrule(l){4-5}
    &   {\thead{(1)\\Unbalanced}}
        &  {\thead{(2)\\Balanced}}                 
            &   {\thead{(3)\\Unbalanced}}
                &   {\thead{(4)\\Balanced}}             \\
    \midrule
lag(d)  &   0.123\tnote{***} 
            &   0.456\tnote{***} 
                &   0.789\tnote{***} 
                    &   0.567\tnote{***}               \\
        & (0.010)       & (0.020)       & (0.030)   & (0.040)           \\
    \addlinespace
lag(y)  & 0.012     & 0.123     & -0.234\tnote{*}   & -0.456\tnote{*}   \\
        & (0.012)   & (0.089)   & (0.045)           & (0.078)           \\
    \midrule
Observations 
         & {901}    & {574}     & {1297}            & {826}             \\
R$^{2}$  & 0.692    & 0.407     & 0.641             & 0.402             \\
Adjusted R$^{2}$ 
        & 0.656     & 0.298     & 0.602             & 0.296             \\
F Statistic 
        & 150.795\tnote{***}  
                    & 41.478\tnote{***}  
                                & 173.803\tnote{***} & 58.898\tnote{***} \\
df      & 12; 807       &  8; 484   &  12; 1167 &  8; 700   \\
    \bottomrule
\end{tabular}
\begin{tablenotes}[flushleft, para]
\note{  \item[*]    $p<0.1$;
        \item[**]   $p<0.05$;
        \item[***]  $p<0.01$.
      }
\end{tablenotes}
\end{threeparttable}
    \end{table}
\end{document}

![enter image description here

| improve this answer | |
3

Here's a "hybrid" siunitx/tabular*-based solution. The overall width is set to \textwidth, and the formatting of the numbers in the four data columns is governed by the S column type, allowing most numbers to be aligned on their respective decimal markers.

enter image description here

\documentclass[12pt, a4paper, leqno]{article}
%% (trimmed the preamble to the bare mininum)
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{newtxtext,newtxmath,booktabs}
\usepackage[skip=0.333\baselineskip]{caption}
\usepackage[left=3cm,right=2cm,vmargin=2cm]{geometry}
\usepackage{siunitx} % for 'S' column type
\newcolumntype{T}{S[table-format=3.3, input-symbols={()},
                    table-space-text-post={$^{***}$},
                    table-align-text-post=false]}
\usepackage[colorlinks=true, allcolors=black]{hyperref}

\widowpenalty=10000
\clubpenalty=10000
\setlength{\parskip}{2ex}
\setlength{\parindent}{0ex}

\begin{document}

\begin{table}[!htbp] 
\setlength\tabcolsep{0pt}
  \caption{Fixed-effect panel regressions: Influence of $d$ and $y$ on \dots} 
  \label{tab:xx} 
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l TTTT } 
\toprule 
& \multicolumn{2}{c}{Non-colonial Countries} & \multicolumn{2}{c}{Colonial Countries}\\
\cmidrule{2-3} \cmidrule{4-5}
& {Unbalanced Panel} & {Balanced Panel} & {Unbalanced Panel} & {Balanced Panel} \\
& {(1)} & {(2)} & {(3)} & {(4)} \\
\midrule
lag($d$) & 0.123$^{***}$ & 0.456$^{***}$ & 0.789$^{***}$ & 0.567$^{***}$ \\ 
  & (0.010) & (0.020) & (0.030) & (0.040) \\ 
\addlinespace 
 lag($y$) & 0.012 & 0.123 & -0.234$^{*}$ & -0.456$^{*}$ \\ 
  & (0.012) & (0.089) & (0.045) & (0.078) \\ 
\midrule
Obs.         & {901} & {574} & {1,297} & {826} \\ 
R$^{2}$      & 0.692 & 0.407 & 0.641 & 0.402 \\ 
Adj.\ R$^{2}$& 0.656 & 0.298 & 0.602 & 0.296 \\ 
F-Stat.      & 150.795$^{***}$  & 41.478$^{***}$  & 173.803$^{***}$  & 58.898$^{***}$  \\
\quad df     & {(12; 807)} & {(8; 484)} 
             & {(12; 1167)} & {(8; 700)} \\
\bottomrule
\addlinespace
\multicolumn{5}{l}{\textit{Note:}  $^{*}\ p<0.1$;\quad $^{**}\ p<0.05$;\quad $^{***}\ p<0.01$} 
\end{tabular*} 
\end{table}
\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.