
Quizás mi pregunta sea trivial, pero agradezco si alguien me puede ayudar a alinear las columnas de mi tabla. El problema es que las entradas no están alineadas en columnas bonitas. Aquí hay un ejemplo práctico:
\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}
Respuesta1
Esto se debe a que los encabezados de las columnas son demasiado grandes. Propongo usar tabularx
para garantizar que la tabla no se desborde en el margen, makecell
para permitir saltos de línea en las columnas estándar y, como los encabezados de las columnas todavía son demasiado anchos, los puse en un cuadro con ancho nulo y reduje el espacio entre columnas. :
\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}