3

I have quite a big table that runs into the right margin but is aligned on the left side. Instead, I would like it to be centered on the page ignoring the text margins I specified for the document.

I know this is a common problem and I have tried several solutions for hours but neither the \makebox workaround nor trying to temporarily adjust the margins through \adjustmargins works for me.

I know there must be something I am missing here but I simply cannot seem to find what.

Below is a minimum reproducible sample of my code:

\documentclass[a4paper,12pt]{article}
\usepackage{lipsum}
\usepackage{geometry}
 \geometry{a4paper, left=3cm, top=3cm, bottom=3cm, right=3cm}
\usepackage{booktabs}
\usepackage{pdfpages}
\usepackage[labelfont = sc]{caption}
\DeclareCaptionFormat{mycaptionfont}{\fontsize{12}{13}\selectfont#1#2#3}
\captionsetup{format=mycaptionfont}
\usepackage{threeparttable}
\usepackage{graphicx}

\begin{document}

\begin{table}
\begin{threeparttable}
\captionsetup{font=large}
\caption{\textsc{Caption here}}
\label{table:1}
\scriptsize
\begin{tabular}{lcccccccccc}
\toprule
\addlinespace[0.7em]
& \multicolumn{2}{c}{log [var1111122222} & \multicolumn{2}{c}{var21111111} & \multicolumn{2}{c}{var3} & \multicolumn{2}{c}{var422222222} & \multicolumn{2}{c}{var566666666} \\
\cmidrule(lr){2-3}
\cmidrule(lr){4-5}
\cmidrule(lr){6-7}
\cmidrule(lr){8-9}
\cmidrule(lr){10-11}
 & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) & (10) \\
\midrule
 &  &  &  &  &  &  &  &  &  &  \\
\addlinespace[0.5em]
Patient & 8.48*** & 4.86*** & 12.84*** & 9.84** & 5.11*** & 2.78 & -0.99*** & -0.50*** & 7.98 & -3.24 \\
 & (1.97) & (1.48) & (3.63) & (3.78) & (1.71) & (1.76) & (0.21) & (0.18) & (7.83) & (7.14) \\
\addlinespace[0.5em]
Retaliative & 1.71 & -0.53 & 2.50 & 5.31 & 7.12** & 7.29** & -0.27 & -0.19 & -7.29 & -7.48 \\
 & (3.80) & (2.85) & (6.66) & (6.40) & (3.48) & (3.40) & (0.46) & (0.34) & (16.67) & (12.86) \\
\addlinespace[0.5em]
Pro-Social & 2.43 & -0.07 & 7.05* & 6.71 & 2.55 & 2.01 & -0.28 & -0.06 & -13.14 & -17.54** \\
 & (2.37) & (1.98) & (4.02) & (4.47) & (2.07) & (2.08) & (0.27) & (0.19) & (9.75) & (7.97) \\
\addlinespace[0.5em]
Constant & 5.42*** & 7.28*** & 1.04 & 0.52 & -1.11 & -1.40 & 0.69*** & 0.47** & 7.85 & 16.20** \\
 & (1.58) & (1.88) & (2.76) & (3.30) & (1.36) & (2.07) & (0.17) & (0.20) & (6.15) & (7.38) \\
\addlinespace[0.5em]
Controls & No & Yes & No & Yes & No & Yes & No & Yes & No & Yes \\
&  &  &  &  &  &  &  &  &  &  \\
Observations & 76 & 73 & 64 & 61 & 76 & 73 & 75 & 72 & 75 & 73 \\
Adjusted R\textsuperscript{2} & 0.45 & 0.67 & 0.30 & 0.37 & 0.11 & 0.21 & 0.41 & 0.65 & 0.15 & 0.43 \\
  \bottomrule
\end{tabular}
\begin{tablenotes}
      \tiny
      \item\textit{Notes:} OLS estimates, robust standard errors in parentheses.*** p$<$0.01, ** p$<$0.05, * p$<$0.1
    \end{tablenotes}
\end{threeparttable}
\end{table}

\lipsum[1]
\end{document}
1

2 Answers 2

5

First method: if there are many columns, you may reduce the value of \tabcolsep(6pt by default). Here, with 11 columns, setting it to $4pt is enough, as it saves 22×2pt=44pt (nearly 8mm) and the table is not so much wider than \textwidth. You also can play with the fontsize to save some more space.

Second method: you can use the adjustwidth environment, from changepage to have locally a smaller margin:

\documentclass[a4paper,12pt]{article}
\usepackage{lipsum}
\usepackage{geometry}
 \geometry{a4paper, left=3cm, top=3cm, bottom=3cm, right=3cm}
\usepackage{booktabs}
\usepackage{changepage}
\usepackage{pdfpages}
\usepackage[labelfont = sc]{caption}
\DeclareCaptionFormat{mycaptionfont}{\fontsize{12}{13}\selectfont#1#2#3}
\captionsetup{format=mycaptionfont}
\usepackage{threeparttable}
\usepackage{graphicx}

\begin{document}

\begin{table}
\begin{adjustwidth}{-1cm}{-1cm}
\centering
\begin{threeparttable}
\captionsetup{font=large}
\caption{\textsc{Caption here}}
\label{table:1}
\scriptsize
\begin{tabular}{l*{10}{c}}
\toprule
\addlinespace[0.7em]
& \multicolumn{2}{c}{log [var1111122222} & \multicolumn{2}{c}{var21111111} & \multicolumn{2}{c}{var3} & \multicolumn{2}{c}{var422222222} & \multicolumn{2}{c}{var566666666} \\
\cmidrule(lr){2-3}
\cmidrule(lr){4-5}
\cmidrule(lr){6-7}
\cmidrule(lr){8-9}
\cmidrule(lr){10-11}
 & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) & (10) \\
\midrule
 & & & & & & & & & & \\
\addlinespace[0.5em]
Patient & 8.48*** & 4.86*** & 12.84*** & 9.84** & 5.11*** & 2.78 & -0.99*** & -0.50*** & 7.98 & -3.24 \\
 & (1.97) & (1.48) & (3.63) & (3.78) & (1.71) & (1.76) & (0.21) & (0.18) & (7.83) & (7.14) \\
\addlinespace[0.5em]
Retaliative & 1.71 & -0.53 & 2.50 & 5.31 & 7.12** & 7.29** & -0.27 & -0.19 & -7.29 & -7.48 \\
 & (3.80) & (2.85) & (6.66) & (6.40) & (3.48) & (3.40) & (0.46) & (0.34) & (16.67) & (12.86) \\
\addlinespace[0.5em]
Pro-Social & 2.43 & -0.07 & 7.05* & 6.71 & 2.55 & 2.01 & -0.28 & -0.06 & -13.14 & -17.54** \\
 & (2.37) & (1.98) & (4.02) & (4.47) & (2.07) & (2.08) & (0.27) & (0.19) & (9.75) & (7.97) \\
\addlinespace[0.5em]
Constant & 5.42*** & 7.28*** & 1.04 & 0.52 & -1.11 & -1.40 & 0.69*** & 0.47** & 7.85 & 16.20** \\
 & (1.58) & (1.88) & (2.76) & (3.30) & (1.36) & (2.07) & (0.17) & (0.20) & (6.15) & (7.38) \\
\addlinespace[0.5em]
Controls & No & Yes & No & Yes & No & Yes & No & Yes & No & Yes \\
& & & & & & & & & & \\
Observations & 76 & 73 & 64 & 61 & 76 & 73 & 75 & 72 & 75 & 73 \\
Adjusted R\textsuperscript{2} & 0.45 & 0.67 & 0.30 & 0.37 & 0.11 & 0.21 & 0.41 & 0.65 & 0.15 & 0.43 \\
  \bottomrule
\end{tabular}
\begin{tablenotes}
      \tiny
      \item\textit{Notes:} OLS estimates, robust standard errors in parentheses.*** p$<$0.01, ** p$<$0.05, * p$<$0.1
    \end{tablenotes}
\end{threeparttable}
\end{adjustwidth}
\end{table}

\lipsum[1]

\end{document} 

enter code here

1

with \small font size, \adjustwidth, use of the @{\extracolsep{\fill}}˙ macro and use of the S column type i got:

Render result

(red lines indicate page layout)

\documentclass[a4paper,12pt]{article}
\usepackage{geometry}
\geometry{a4paper, margin=3cm}
\usepackage{graphicx}
\usepackage[labelfont=sc]{caption}
\DeclareCaptionFormat{mycaptionfont}{\fontsize{12}{13}\selectfont#1#2#3}
\captionsetup{format=mycaptionfont}
\usepackage{booktabs}
\usepackage[referable]{threeparttablex}
\newcommand\mcc[1]{\multicolumn{2}{c}{#1}}
\usepackage{siunitx}
\usepackage{changepage}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

\begin{document}
    \begin{table}
    \begin{adjustwidth}{-3em}{-3em}
    \centering
\begin{threeparttable}
\captionsetup{font=large}
\caption{\textsc{Caption here}}
\label{table:1}
\small
\setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
        l *{10}{S[ table-format=2.2,
                   input-symbols={( )},
                   table-space-text-post={***}
                   ]} }
    \toprule
    & \mcc{log[var1111122222]}
            & \mcc{var21111111}
                    & \mcc{var3}
                            & \mcc{var422222222}
                                    & \mcc{var566666666}    \\
    \cmidrule(lr){2-3}
    \cmidrule(lr){4-5}
    \cmidrule(lr){6-7}
    \cmidrule(lr){8-9}
    \cmidrule(lr){10-11}
 & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} & {(6)} & {(7)} & {(8)} & {(9)} & {(10)} \\
    \midrule
 &  &  &  &  &  &  &  &  &  &  \\
    \addlinespace
Patient & 8.48*** & 4.86*** & 12.84*** & 9.84** & 5.11*** & 2.78 & -0.99*** & -0.50*** & 7.98 & -3.24 \\
 & (1.97) & (1.48) & (3.63) & (3.78) & (1.71) & (1.76) & (0.21) & (0.18) & (7.83) & (7.14) \\
    \addlinespace
Retaliative & 1.71 & -0.53 & 2.50 & 5.31 & 7.12** & 7.29** & -0.27 & -0.19 & -7.29 & -7.48 \\
 & (3.80) & (2.85) & (6.66) & (6.40) & (3.48) & (3.40) & (0.46) & (0.34) & (16.67) & (12.86) \\
    \addlinespace
Pro-Social & 2.43 & -0.07 & 7.05* & 6.71 & 2.55 & 2.01 & -0.28 & -0.06 & -13.14 & -17.54** \\
 & (2.37) & (1.98) & (4.02) & (4.47) & (2.07) & (2.08) & (0.27) & (0.19) & (9.75) & (7.97) \\
    \addlinespace
Constant & 5.42*** & 7.28*** & 1.04 & 0.52 & -1.11 & -1.40 & 0.69*** & 0.47** & 7.85 & 16.20** \\
 & (1.58) & (1.88) & (2.76) & (3.30) & (1.36) & (2.07) & (0.17) & (0.20) & (6.15) & (7.38) \\
    \addlinespace
Controls & {No} & {Yes} & {No} & {Yes} & {No} & {Yes} & {No} & {Yes} & {No} & {Yes} \\
&  &  &  &  &  &  &  &  &  &  \\
Observations & 76 & 73 & 64 & 61 & 76 & 73 & 75 & 72 & 75 & 73 \\
Adjusted R\textsuperscript{2} & 0.45 & 0.67 & 0.30 & 0.37 & 0.11 & 0.21 & 0.41 & 0.65 & 0.15 & 0.43 \\
  \bottomrule
\end{tabular*}
\begin{tablenotes}[para, flushleft]\footnotesize
\note{OLS estimates, robust standard errors in parentheses.}

\item[***] p$<$0.01,
\item[** ] p$<$0.05,
\item[*  ] p$<$0.1
    \end{tablenotes}
\end{threeparttable}
    \end{adjustwidth}
    \end{table}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .