Graphics, Figures & TablesCentered Caption for multiple-columned Table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
scranney
Posts: 5
Joined: Mon Sep 03, 2012 10:08 pm

Centered Caption for multiple-columned Table

Post by scranney »

Hi all,

I'm relatively new to LaTeX and have been using an automatic LaTeX code generator that Stata has using its estout command. The actual code it's generating (with a few minor modifications) is below. The problem is, the caption appears to be skewed left because there are so many columns, even though it might be centered on the page. I've tried the flushright commands, etc., but nothing seems to work. Any help would be appreciated.

Code: Select all

\documentclass{article}

\begin{document}
\begin{table}[htbp]\centering
\setcounter{table}{2}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{M-Estimation Regression Tables\label{tab2}}
\begin{tabular}{l*{6}{c}}
\hline\hline\\
            &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}&\multicolumn{1}{c}{(5)}&\multicolumn{1}{c}{(6)}\\
            &\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}&\multicolumn{1}{c}{}\\
\hline\\
[1em]
No Belief    &      -0.135         &      -0.128\sym{*}  &      -0.213\sym{***}&      -0.138\sym{*}  &      -0.148\sym{*}  &      -0.158\sym{*}  \\
            &     (-1.51)         &     (-2.38)         &     (-4.32)         &     (-2.13)         &     (-2.29)         &     (-2.42)         \\
[1em]
Believe-Doubts&      -0.184\sym{**} &      -0.209\sym{***}&      -0.193\sym{***}&      -0.150\sym{***}&      -0.152\sym{***}&      -0.151\sym{***}\\
            &     (-3.17)         &     (-6.02)         &     (-6.09)         &     (-3.69)         &     (-3.74)         &     (-3.69)         \\
[1em]
Higher Power &      -0.178\sym{*}  &      -0.190\sym{***}&      -0.211\sym{***}&      -0.118\sym{*}  &      -0.123\sym{*}  &      -0.130\sym{*}  \\
            &     (-2.16)         &     (-3.84)         &     (-4.68)         &     (-2.12)         &     (-2.20)         &     (-2.33)         \\
[1em]
Age(/10)       &                     &     -0.0196\sym{*}  &    -0.00543         &    -0.00536         &    -0.00580         &    -0.00812         \\
            &                     &     (-2.41)         &     (-0.71)         &     (-0.57)         &     (-0.61)         &     (-0.85)         \\
[1em]
Male        &                     &     -0.0882\sym{**} &     -0.0948\sym{***}&      -0.104\sym{***}&      -0.104\sym{***}&      -0.104\sym{***}\\
            &                     &     (-3.14)         &     (-3.69)         &     (-3.37)         &     (-3.37)         &     (-3.35)         \\
[1em]
Black       &                     &      -0.107\sym{*}  &     -0.0417         &     -0.0410         &     -0.0519         &     -0.0397         \\
            &                     &     (-2.56)         &     (-1.06)         &     (-0.89)         &     (-1.11)         &     (-0.84)         \\
[1em]
Other Race   &                     &      -0.211\sym{***}&      -0.143\sym{**} &      -0.143\sym{*}  &      -0.147\sym{*}  &      -0.131\sym{*}  \\
            &                     &     (-3.67)         &     (-2.70)         &     (-2.52)         &     (-2.55)         &     (-2.27)         \\
[1em]
Income      &                     &                     &      0.0120\sym{*}  &      0.0192\sym{**} &      0.0194\sym{**} &      0.0159\sym{*}  \\
            &                     &                     &      (2.22)         &      (2.85)         &      (2.88)         &      (2.35)         \\
[1em]
Years Education     &                     &                     &      0.0389\sym{***}&      0.0407\sym{***}&      0.0400\sym{***}&      0.0375\sym{***}\\
            &                     &                     &      (8.53)         &      (7.57)         &      (7.43)         &      (6.93)         \\
[1em]
Religious Person&                     &                     &                     &      0.0716\sym{***}&      0.0730\sym{***}&      0.0633\sym{**} \\
            &                     &                     &                     &      (3.69)         &      (3.75)         &      (3.22)         \\
[1em]
 \\
[1em]
Happy       &                     &                     &                     &                     &                     &     -0.0786\sym{***}\\
            &                     &                     &                     &                     &                     &     (-3.30)         \\
[1em]
Constant      &       4.595\sym{***}&       4.806\sym{***}&       4.027\sym{***}&       3.664\sym{***}&       3.550\sym{***}&       3.804\sym{***}\\
            &    (101.90)         &    (100.32)         &     (46.18)         &     (29.15)         &     (25.54)         &     (24.42)         \\
[1em]
\hline\\
\(N\)       &        3708         &        3699         &        3339         &        2213         &        2213         &        2204         \\
\(R^{2}\)   &       0.004         &       0.020         &       0.049         &       0.066         &       0.073         &       0.076         \\
adj. \(R^{2}\)&       0.002         &       0.018         &       0.046         &       0.062         &       0.065         &       0.068         \\
F           &       2.844         &       8.460         &       15.55         &       14.24         &       9.039         &       9.016         \\
$Prob>F$      &      0.0144         &    1.29e-12         &    4.84e-30         &    6.90e-27         &    1.74e-25         &    1.46e-26         \\
\hline\hline
\multicolumn{7}{l}{\footnotesize \textit{t} statistics in parentheses}\\
\multicolumn{7}{l}{\footnotesize \sym{+} \(p<.10\), \sym{*} \(p<.05\), \sym{**} \(p<.01\), \sym{***} \(p<.001\)}\\
\end{tabular}
\end{table}
\end{document}
Last edited by localghost on Wed Sep 12, 2012 9:22 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Centered Caption for multiple-columned Table

Post by localghost »

From time to time you should listen to the compiler and listen to what it tells you in the log file. There is a message and an additional warning.

Code: Select all

Overfull \hbox (55.68127pt too wide) in paragraph at lines 7--61
 [][] 

LaTeX Warning: Float too large for page by 59.48907pt on input line 61.
The caption is very well centered. But the table is too wide to fit the text body. Some possible solutions.
  • Decrease the table width
    • Modify the length \tabcolsep (default value 6pt)
    • Decrease the font size of the table
  • Alter the page geometry (thinner margins) i.e. by the geometry package.
  • Turn the table to landscape
There is more to improve (but this is another story).


Thorsten
scranney
Posts: 5
Joined: Mon Sep 03, 2012 10:08 pm

Centered Caption for multiple-columned Table

Post by scranney »

Thank you! The \usepackage[margin=2cm,nohead]{geometry} command finally centered the caption.
Post Reply