對齊表格條目

對齊表格條目

也許我的問題很微不足道,但如果有人可以幫助我對齊表格的列,我會很感激。問題是條目沒有在漂亮的列中對齊。這是一個工作範例:

    \documentclass[12pt]{article}
    \usepackage{graphicx}
    \usepackage{booktabs,multirow,tabularx,multicol}
    \begin{document}
    \begin{table}
        \resizebox{1\columnwidth}{!}{%
            \begin{tabular}{ccccccccccccccccccc}
                \toprule
                \multicolumn{3}{c}{Bookmaker's Odds} && \multicolumn{3}{c}{Bookmaker's Probabilities} && \multicolumn{3}{c}{Equal Weighting} && \multicolumn{3}{c}{Proportional Weighting} &&   \multicolumn{3}{c}{Logarithmic Weighting} \\
                \cmidrule(l){1-3} \cmidrule(l){5-7} \cmidrule(l){9-11} \cmidrule(l){13-15} \cmidrule(l){17-19}
                1  &  5  &  1 && 2 & 2 & 2  && 2  &  2  &  2    && 2 & 2 & 2 && 2 & 2 & 2 \\
                3  &  3  &  3 && 2 & 2 & 2  && 2  &  2  &  2    && 2 & 2 & 2 && 2 & 2 & 2 \\
                1  &  5  &  1 && 2 & 2 & 2  && 2  &  2  &  2    && 2 & 2 & 2 && 2 & 2 & 2 \\   
                \bottomrule
            \end{tabular}
        }
    \end{table}
\end{document}

答案1

這是由於柱頭太大造成的。我建議使用它tabularx來確保表格不會溢出到邊距中,makecell以允許標準列中的換行符,並且由於列頭仍然有點太寬,我將它們放在一個空寬度的框中並減少了列間距:

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{booktabs,multirow, makecell, tabularx,multicol}

\begin{document}

\begin{table}
\centering\setlength{\tabcolsep}{4pt}
\renewcommand{\theadfont}{\small}
        \begin{tabularx}{\linewidth}{*{19}{@{}>{\centering\arraybackslash}X}@{}}
            \toprule
            \multicolumn{3}{c}{\makebox[0pt]{\thead{Bookmaker's\\ Odds}}} && \multicolumn{3}{c}{\makebox[0pt]{\thead{Bookmaker's\\ Probabilities}}} && \multicolumn{3}{c}{\makebox[0pt]{\thead{Equal\\ Weighting}}} && \multicolumn{3}{c}{\makebox[0pt]{\thead{Proportional\\ Weighting}}} && \multicolumn{3}{c}{\makebox[0pt]{\thead{Logarithmic\\ Weighting}}} \\
            \cmidrule{1-3} \cmidrule{5-7} \cmidrule{9-11} \cmidrule{13-15} \cmidrule{17-19}
            1 & 5 & 1 && 2 & 2 & 2 && 2 & 2 & 2 && 2 & 2 & 2 && 2 & 2 & 2 \\
            3 & 3 & 3 && 2 & 2 & 2 && 2 & 2 & 2 && 2 & 2 & 2 && 2 & 2 & 2 \\
            1 & 5 & 1 && 2 & 2 & 2 && 2 & 2 & 2 && 2 & 2 & 2 && 2 & 2 & 2 \\
            \bottomrule
        \end{tabularx}
\end{table}

\end{document} 

在此輸入影像描述

相關內容