我的表格不适合页面。我试图让它适合我的页面宽度。我是这方面的新手,所以任何帮助都会很感激。我尝试使用旋转头单元格和 tabularx,但第一行和第一列重叠了。我该如何避免这种情况?有没有办法让我的表格适合整个列宽,而不是只在右侧?
我的代码:
\documentclass[a4paper, 10pt, conference]{ieeeconf}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{graphicx}
\begin{document}
[![\begin{table}
\caption{Small font size, rotated table head cells.}
\small
\advance\tabcolsep-3.5pt
\begin{tabularx}{\hsize}{@{}X l D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1}}\toprule
\rotatebox{90}{Syndrome} & \rotatebox{90}{22q11} & \rotatebox{90}{Angelman} & \rotatebox{90}{Apert} & \rotatebox{90}{CDL} & \rotatebox{90}{Down} & \rotatebox{90}{FragileX} & \rotatebox{90}{Marfan} & \rotatebox{90}{Progeria} & \rotatebox{90}{Sotos} & \rotatebox{90}{Treacher Collins} & \rotatebox{90}{Turner} & \rotatebox{90}{Williams} \\ \midrule
22q11 & 0 & 0 & 0 & 0 & 0.5 & 0 & 0 & 0 & 0 & 0 & 0 & 0.5 \\
Angelman & 0 & 85.7 & 0 & 4.7 & 0 & 0 & 4.7 & 0 & 0 & 0 & 0 & 4.7 \\
Apert & 0 & 0 & 100 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
CDL & 0 & 0 & 0 & 96 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 4.7 \\
Down & 0 & 0 & 0 & 0 & 94.7 & 0 & 5.2 & 0 & 0 & 0 & 0 & 0 \\
FragileX & 0 & 17.6 & 0 & 0 & 76.4 & 0 & 0 & 0 & 0 & 0 & 0 & 5.8 \\
Marfan & 0 & 0 & 0 & 0 & 0 & 0 & 100 & 0 & 0 & 0 & 0 & 0 \\
Progeria & 0 & 0 & 0 & 0 & 0 & 0.5 & 0 & 0.25 & 0.25 & 0 & 0 & 0 \\
Sotos & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 100 & 0 & 0 & 0 \\
Treacher Collins & 0 & 0 & 0 & 0 & 0 & 0.5 & 0 & 0 & 0 & 0 & 0.5 & 0 \\
Turner & 0 & 8.6 & 0 & 4.3 & 0 & 4.3 & 0 & 0 & 0 & 0 & 0 & 82.6 \\
Williams & & & & & & & & & & & & \\ \bottomrule
\end{tabularx}
\end{table}][1]][1]
\end{document}
答案1
您需要减小字体大小,进一步减少列间空白,并放弃将第 2 至第 13 列中的数字与小数点对齐的想法——文本列的宽度根本无法实现这种奢侈。
\documentclass[a4paper, 10pt, conference]{IEEEconf}
\usepackage{booktabs,tabularx,graphicx}
\begin{document}
\begin{table}
\caption{Small font size, rotated table head cells.}
\footnotesize % not "\small"
\setlength\tabcolsep{2pt} % default value: 6pt
\begin{tabularx}{\hsize}{@{} X *{12}{c} @{}}
\toprule
\rotatebox{90}{Syndrome} & \rotatebox{90}{22q11}
& \rotatebox{90}{Angelman} & \rotatebox{90}{Apert}
& \rotatebox{90}{CDL} & \rotatebox{90}{Down}
& \rotatebox{90}{FragileX} & \rotatebox{90}{Marfan}
& \rotatebox{90}{Progeria} & \rotatebox{90}{Sotos}
& \rotatebox{90}{Treacher Collins}
& \rotatebox{90}{Turner} & \rotatebox{90}{Williams} \\
\midrule
22q11 & 0 & 0 & 0 & 0 & 0.5 & 0 & 0 & 0 & 0 & 0 & 0 & 0.5 \\
Angelman & 0 & 85.7 & 0 & 4.7 & 0 & 0 & 4.7 & 0 & 0 & 0 & 0 & 4.7 \\
Apert & 0 & 0 & 100 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
CDL & 0 & 0 & 0 & 96 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 4.7 \\
Down & 0 & 0 & 0 & 0 & 94.7 & 0 & 5.2 & 0 & 0 & 0 & 0 & 0 \\
FragileX & 0 & 17.6 & 0 & 0 & 76.4 & 0 & 0 & 0 & 0 & 0 & 0 & 5.8 \\
Marfan & 0 & 0 & 0 & 0 & 0 & 0 & 100 & 0 & 0 & 0 & 0 & 0 \\
Progeria & 0 & 0 & 0 & 0 & 0 & 0.5 & 0 & 0.25 & 0.25 & 0 & 0 & 0 \\
Sotos & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 100 & 0 & 0 & 0 \\
Treacher Collins & 0 & 0 & 0 & 0 & 0 & 0.5 & 0 & 0 & 0 & 0 & 0.5 & 0 \\
Turner & 0 & 8.6 & 0 & 4.3 & 0 & 4.3 & 0 & 0 & 0 & 0 & 0 & 82.6 \\
Williams & x & x & x & x & x & x & x & x & x & x & x & x \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}