4

I can't seem to center this table. Here's the code I have. I've tried using \centering too. There is a big indent and the table goes all the way to the right edge of the page.

\documentclass{article}
\usepackage{tabularx, booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
    \begin{document}
        \begin{center}
            \begin{tabularx}{1.55\textwidth}{c *{10}{Y}}
            \toprule\toprule

            & \multicolumn{5}{c}{Reward+Private}  
            & \multicolumn{5}{c}{No Reward+Public}\\
            & \multicolumn{5}{c}{minus No Reward+Private}  
            & \multicolumn{5}{c}{minus No Reward+Private}\\
            \cmidrule(lr){2-6} \cmidrule(l){7-11}
            &\multicolumn{5}{c}{Price}&\multicolumn{5}{c}{Price}\\
            \cmidrule(lr){2-6} \cmidrule(l){7-11}
            Endowment& 0.5  & 1    & 1.5  & 2    & Mean 
                     & 0.5  & 1    & 1.5  & 2    & Mean\\
            \midrule
            2.40     & $-.0068$ & $-.0168$  & .0157 &.0816 & .0211 
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
                     & (.0825) & (.0646) & (.0641) & (.0724) & (.0350) 
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
            3.60     & .0511 & .0516 & .0572 & .1212 & .0719 
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
                     & (.0769) & (.0599) & (.0614) & (.0672) & (.0328) 
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
            Mean     & .0228 & .0173 & .0367 & .1013 & .0467 
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
                     & (.1013) & (.0438) & (.0441) & (.0491) & (.0239) 
                     & x.xx & x.xx & x.xx & x.xx & \\

            \bottomrule
        \end{tabularx}
    \end{center}
    \end{document}
  • 2
    Welcome to TeX.SX! The table is much wider than the width of the textblock, and it therefore sticks out in the right margin. This is the default behaviour for stuff that is wider than \textwidth. You could restructure the table to make it narrower, but if you insist on having it that wide, try the suggestions in How can I center a too wide table? – Torbjørn T. Jul 17 '15 at 7:17
  • Compiling your document there is a clear warning about an overfull box... it's too wide – user31729 Jul 17 '15 at 7:18
  • You tell latex to make the table wider than textwidth: {1.55\textwidth}. – Ignasi Jul 17 '15 at 7:22
7

The table is too wide to be centered.

If you insist in a wide table, you can use a sidewaystable from rotating package.

enter image description here

\documentclass{article}
\usepackage{tabularx, booktabs, rotating}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
    \begin{document}
        \begin{center}
        \begin{sidewaystable}
            \begin{tabularx}{\textwidth}{c *{10}{Y}}
            \toprule\toprule

            & \multicolumn{5}{c}{Reward+Private}  
            & \multicolumn{5}{c}{No Reward+Public}\\
            & \multicolumn{5}{c}{minus No Reward+Private}  
            & \multicolumn{5}{c}{minus No Reward+Private}\\
            \cmidrule(lr){2-6} \cmidrule(l){7-11}
            &\multicolumn{5}{c}{Price}&\multicolumn{5}{c}{Price}\\
            \cmidrule(lr){2-6} \cmidrule(l){7-11}
            Endowment& 0.5  & 1    & 1.5  & 2    & Mean 
                     & 0.5  & 1    & 1.5  & 2    & Mean\\
            \midrule
            2.40     & $-.0068$ & $-.0168$  & .0157 &.0816 & .0211 
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
                     & (.0825) & (.0646) & (.0641) & (.0724) & (.0350) 
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
            3.60     & .0511 & .0516 & .0572 & .1212 & .0719 
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
                     & (.0769) & (.0599) & (.0614) & (.0672) & (.0328) 
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
            Mean     & .0228 & .0173 & .0367 & .1013 & .0467 
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
                     & (.1013) & (.0438) & (.0441) & (.0491) & (.0239) 
                     & x.xx & x.xx & x.xx & x.xx & \\

            \bottomrule
        \end{tabularx}
        \end{sidewaystable}
    \end{center}
    \end{document}

But I think two separated tables doesn't look so bad and it's easy to compare values from one to the other.

enter image description here

\documentclass{article}
\usepackage{tabularx, booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

    \begin{document}
        \begin{center}
            \begin{tabularx}{\textwidth}{c *{5}{Y}}
            \toprule\toprule
            & \multicolumn{5}{c}{Reward+Private}  \\
            & \multicolumn{5}{c}{minus No Reward+Private} \\ 
            \cmidrule(lr){2-6} 
            &\multicolumn{5}{c}{Price}\\
            \cmidrule(lr){2-6} 
            Endowment& 0.5  & 1    & 1.5  & 2    & Mean\\
            \midrule
            2.40     & $-.0068$ & $-.0168$  & .0157 &.0816 & .0211 \\
                     & (.0825) & (.0646) & (.0641) & (.0724) & (.0350)\\
            3.60     & .0511 & .0516 & .0572 & .1212 & .0719\\
                     & (.0769) & (.0599) & (.0614) & (.0672) & (.0328) \\
            Mean     & .0228 & .0173 & .0367 & .1013 & .0467\\
                     & (.1013) & (.0438) & (.0441) & (.0491) & (.0239) \\
            \bottomrule
        \end{tabularx}
    \end{center}

    \begin{center}
            \begin{tabularx}{\textwidth}{c *{5}{Y}}
            \toprule\toprule

            & \multicolumn{5}{c}{No Reward+Public}\\
            & \multicolumn{5}{c}{minus No Reward+Private}\\
            \cmidrule(lr){2-6}            
            &\multicolumn{5}{c}{Price}\\
            \cmidrule(lr){2-6}
            Endowment& 0.5  & 1    & 1.5  & 2    & Mean \\
            \midrule
            2.40     & x.xx & x.xx & x.xx & x.xx & x.xx\\
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
            3.60     & x.xx & x.xx & x.xx & x.xx & x.xx\\
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
            Mean     & x.xx & x.xx & x.xx & x.xx & x.xx\\
                     & x.xx & x.xx & x.xx & x.xx & x.xx\\
            \bottomrule
        \end{tabularx}
        \end{center}
    \end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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