Comment adapter un large tableau sur la page?
J'ai le tableau suivant, qui est trop large pour la page. Maintenant, je veux insérer ce tableau dans cette page d'ensemble. Où dois-je modifier ici? J'ai essayé de changer {@{\extracolsep{5pt}}lcccc} en {@{\extracolsep{\fill}}ccccc}mais il fait aucun sens.
\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}
Réponses
Avec des sauts de ligne dans les colonnes d'en-tête, certaines \multicolumncommandes dans la partie d'en-tête pour supprimer les informations répétées et une nouvelle ligne pour "df", ainsi que les lignes horizontales du booktabspackage:
\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}
Avec l'utilisation des packages threeparttablex(pour les notes de table) et siunitx(pour les Scolonnes) ... et une petite modification de votre 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}
! [entrez la description de l'image ici
Voici une solution «hybride» siunitx/ tabular*basée. La largeur totale est définie sur \textwidthet la mise en forme des nombres dans les quatre colonnes de données est régie par le Stype de colonne, permettant à la plupart des nombres d'être alignés sur leurs marqueurs décimaux respectifs.
\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}