4

For some reason the caption is aligned in the center of the page but the table is too far to the right. How can I have both centered?

\documentclass{article}
\usepackage{booktabs}
\usepackage[justification=centering]{caption}
\begin{document}

\begin{table}[htbp]
\centering
\caption{X \\ Y}
\smallskip

\begin{tabular}{l rlrlrl }

\midrule[\heavyrulewidth]
& \multicolumn{2}{c}{Model 1}
& \multicolumn{2}{c@{}}{Model 2}
& \multicolumn{2}{c@{}}{Model 3} \\

\midrule
\midrule

Variable Variable Variable 1 (Variable) Variable & 17.122 & * &   3.481 &* & 0.138 &* \\

\end{tabular}
Note: XYZ
\end{table}
\end{document}
1
  • 1
    Leave a blank line between \end{tabular} and Note: XYZ. Also it wouldn't use \smallskip before tabular.
    – user11232
    Mar 18, 2013 at 1:12

1 Answer 1

5

The table and Note: XYZ are on the same line and so are centred together. If you do not want that, put a blank line between them and they will each be centred individually.enter image description here

If your text is too wide (as shown in the edited question) then you need to limit the widths of the columns, for example you can use a p column of a fixed width:

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage{array}
\usepackage[justification=centering]{caption}
\begin{document}

\begin{table}[htbp]
\centering
\caption{X \\ Y}
\smallskip

\begin{tabular}{>{\raggedright}p{5cm} rlrlrl }

\midrule[\heavyrulewidth]
& \multicolumn{2}{c}{Model 1}
& \multicolumn{2}{c@{}}{Model 2}
& \multicolumn{2}{c@{}}{Model 3} \\

\midrule
\midrule

Variable Variable Variable 1 (Variable) Variable &
 17.122 & * &   3.481 &* & 0.138 &* \\    
\end{tabular}

Note: XYZ

X\dotfill X
\end{table}
\end{document}
2
  • My edit did not load in time. The problem is the variable names I have are long, and for some reason, even after the fix above the table is still off to the right.
    – Chris J
    Mar 18, 2013 at 1:37
  • @CJ12 updated answer Mar 18, 2013 at 1:46

You must log in to answer this question.

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