也许我的问题很简单,但如果有人能帮我对齐表格的列,我将不胜感激。问题是条目没有按整齐的列对齐。这是一个有效示例:
\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}