Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
1  
Leave a blank line between \end{tabular} and Note: XYZ. Also it wouldn't use \smallskip before tabular. –  Harish Kumar Mar 18 '13 at 1:12
add comment

1 Answer

up vote 4 down vote accepted

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}
share|improve this answer
    
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 '13 at 1:37
    
@CJ12 updated answer –  David Carlisle Mar 18 '13 at 1:46
    
Perfect! Answer accepted. –  Chris J Mar 18 '13 at 1:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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