在投影机模式下,“表格”在页面内正确划定,但文本列仍然超出页面。标题由 3 个层次结构组成,每列内有 2 列,总计 9 列(包括左侧的单列)。
此外,列边距太小,几乎没有空间放置值。我真的很感激有人能帮我解决这个问题
\documentclass[table]{beamer}
\usepackage{tikz, dcolumn, booktabs}
\usetikzlibrary{arrows,shapes}
\newcolumntype{d}[1]{D{.}{.}{#1}} % "decimal" column type
\renewcommand{\ast}{{}^{\textstyle *}} % for raised "asterisks"
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\begin{document}
\begin{frame}
\begin{table}[h]
\caption{Number of turns and distance between top and bottom.}
\tiny
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} r *{8}{d{2.4}} }
\toprule
& \multicolumn{4}{c}{Clustered} & \multicolumn{4}{c}{Non-clustered}\\
\cmidrule(lr){2-5}\cmidrule(lr){6-9}\addlinespace
& \multicolumn{2}{c}{Cured} & \multicolumn{2}{c}{Non-cured}
&\multicolumn{2}{c}{Cured} & \multicolumn{2}{c}{Non-cured}\\
& \multicolumn{1}{c}{$\hat{\beta}$ (SD)} & \multicolumn{1}{c}{P-val}
&\multicolumn{1}{c}{$\hat{\beta}$ (SD)} & \multicolumn{1}{c}{P-val}&\multicolumn{1}{c}{$\hat{\beta}$ (SD)} & \multicolumn{1}{c}{P-val}&\multicolumn{1}{c}{$\hat{\beta}$ (SD)} & \multicolumn{1}{c}{P-val}\\
\midrule
$Constant$ & 8.79 (0.03) & & 8.79 (0.003) & & 1.155 & & 123 &\ast \\
$HCV Groupings$ \textsuperscript{a}\\
$D-/R+$ & 0.29 (0.01) & $<0.001$ & -0.002 & & 1.155 & & 123&\ast \\
$D+/R-$
& 0.54 (0.01) & $<0.001$ & -0.002 & & 1.155 & & 122&\ast \\
$D+/R+$
& 0.46 (0.01) & $<0.001$ & -0.002 & & 1.155 & & 122&\ast \\
Theta & 0.19 (0.02) & $<0.001$ & & & & & & \\
Cure & 1.45E-7 (3.46E-6) & 0.97 & & & & & & \\
\bottomrule
\end{tabular*}
\end{table}
\end{frame}
\end{document}
答案1
我将重新组织此表:
\documentclass[table]{beamer}
%\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{booktabs, dcolumn}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\newcolumntype{d}[1]{D{.}{.}{#1}} % "decimal" column type
\renewcommand{\ast}{{}^{\textstyle *}} % for raised "asterisks"
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\newcommand\mcn[2]{\multicolumn{#1}{c}{#2}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\begin{document}
\begin{frame}
\begin{table}
\small
\setlength\tabcolsep{0pt}
\caption{Number of turns and distance between top and bottom.}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
>{$}r<{$}
d{2.8} d{2.3}
d{2.3} d{1.0}
d{1.3} d{1.0}
d{3.0} d{1.0}
}
\toprule
& \mcn{4}{Clustered} & \mcn{4}{Non-clustered} \\
\cmidrule(lr){2-5}\cmidrule(lr){6-9}
& \mcn{2}{Cured} & \mcn{2}{Non-cured}
& \mcn{2}{Cured} & \mcn{2}{Non-cured} \\
& \mc{$\hat{\beta}$ (SD)} & \mc{P-val}
& \mc{$\hat{\beta}$ (SD)} & \mc{P-val} & \mc{$\hat{\beta}$ (SD)}
& \mc{P-val} & \mc{$\hat{\beta}$ (SD)} & \mc{P-val} \\
\midrule
\multicolumn{8}{l}{HCV Groupings \textsuperscript{a}} \\
D-/R+ & 0.29 & <0.001 & -0.002 & & 1.155 & & 123& \ast \\
& (0.01) & & & & & & & \\
D+/R- & 0.54 & <0.001 & -0.002 & & 1.155 & & 122& \ast \\
& (0.01) & & & & & & & \\
D+/R+ & 0.46 & <0.001 & -0.002 & & 1.155 & & 122& \ast \\
& (0.01) & & & & & & & \\
\text{Theta}& 0.19 & <0.001 & & & & & & \\
& (0.02) & & & & & & & \\
\text{CureN}& 1.45 \cdot10^{-6}
& 0.97 & & & & & & \\
& (3.46\cdot10^{-6})
& & & & & & & \\
\bottomrule
\end{tabular*}
\end{table}
\end{frame}
\end{document}