我的代码有点问题。TexMaker 指示它是内容部分的第一行(即从“1”开始的行),但我使用 Latex 的经验告诉我它与列的构造有关。
为了让您了解我想要制作的表格,我提供了下面的图片:
现在,我试图将这三个表格合并为一个表格 - 希望所有内容都可以放在一页中。这是我的 MWE
\documentclass{article}
\usepackage{booktabs}
\usepackage{siuntix}
\usepackage{array}
\usepackage{ragged2e}
\begin{document}
\begin{table} [H]
\centering
\small
\setlength{\tabcolsep}{4.0pt}
\caption[Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$)]{[Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$). \\[\medskipamount] Legend: Y: Academic Year of Study
HRG:~Hazard Ratio --~Graduation;
HRAE: Hazard Ratio --~Academically Excluded. \\
95\% confidence intervals given in parentheses below the point estimates.}
\label{table:SurvivalAll}
\begin{tabular*}{\textwidth}{
S[table-format=1.0]
*{10}{S[table-format=2.1]}
@{}
}
\toprule
\bfseries{Year} &
\multicolumn{5}{c}{\bfseries HRG} &
\multicolumn{5}{c}{\bfseries HRAE}
\\ {(\%)} & {(\%)} \\
\cmidrule(rl){2-6}
\cmidrule(rl){7-11}
&
{\bfseries Commerce ($N = \num(6508)$)} & {\bfseries BCom ($N = \num(2560)$)} & {\bfseries BBusSci ($N = \num(3948)$)} & {\bfseries EBE ($N = \num(2949)$)} & {\bfseries Science ($N = \num(2502)$)} & {\bfseries Commerce)} & {\bfseries BCom} & {\bfseries BBusSci} & {\bfseries EBE} & {\bfseries Science}
\midrule
1 & 0.0 & 0.0& 0.0 & 0.0& 0.0& 1.5 & 1.7 & 1.4 & 10.3 & 12.9\\
& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(1.2{\,;\,}1.8)} & {(1.2{\,;\,}2.2)} & {(1.0{\,;\,}1.7)} & {(9.2{\,;\,}11.4)} & {(11.6{\,;\,}14.2)} \\[1ex]
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&10.2 & 2.2 &3.3 &10.3 \\
& {(73.2{\,;\,}86.5)} & {(61.1{\,;\,}85.5)} & {(75.6{\,;\,}91.0)}& {(60.5{\,;\,}75.5)}& {(64.6{\,;\,}94.0)}& {(1.4{\,;\,}8.7)}& {(1.7{\,;\,}18.7)}& {($-$0.8{\,;\,}5.3)}& {(0.5{\,;\,}6.2)} & {($-$0.7{\,;\,}24.7)} \\[1ex]
7 & 75.0& 71.4 & 77.8 & 56.0 & 50.0 &18.8 &14.3 &22.2 &12.0 &50.0 \\
& {(53.8{\,;\,}96.2)} & {(38.0{\,;\,}104.9)} & {(50.6{\,;\,}104.9)}& {(36.5{\,;\,}75.5)}& {($-$19.3{\,;\,}119.3)}& {($-$0.4{\,;\,}37.9)}& {($-$11.6{\,;\,}40.2)}& {($-$4.9{\,;\,}49.4)} & {($-$0.7{\,;\,}24.7)}& {($-$19.3{\,;\,}119.3)} \\[1ex]
8 & 100.0 & 100.0 & 0.0 & 66.7 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\
& {(100.0{\,;\,}100.0)} & {(100.0{\,;\,}100.0)} & {(50.6{\,;\,}104.9)}& {(13.3{\,;\,}120.0)}& {(1.2{\,;\,}1.8)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} \\
\bottomrule
\end{tabular*}
\end{table}
答案1
错误是\num(<number>)
。应该是。注意括号。此外,标题行之前和之后\num{<number>}
也需要有。除此之外,还有一个拼写错误。\\
\midrule
\\\midrule
siunitx
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{array}
\usepackage{ragged2e}
\begin{document}
\begin{table} %[H]
\centering
\small
\setlength{\tabcolsep}{4.0pt}
\caption[Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$)]{[Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$). \\[\medskipamount] Legend: Y: Academic Year of Study
HRG:~Hazard Ratio --~Graduation;
HRAE: Hazard Ratio --~Academically Excluded. \\
95\% confidence intervals given in parentheses below the point estimates.}
\label{table:SurvivalAll}
\begin{tabular*}{\textwidth}{
S[table-format=1.0]
*{10}{S[table-format=2.1]}
@{}
}
\toprule
\bfseries{Year} &
\multicolumn{5}{c}{\bfseries HRG} &
\multicolumn{5}{c}{\bfseries HRAE}
\\ {(\%)} & {(\%)} \\
\cmidrule(rl){2-6}
\cmidrule(rl){7-11}
&
{\bfseries Commerce ($N = \num{6508}$)} & {\bfseries BCom ($N = \num{2560}$)} & {\bfseries BBusSci ($N = \num{3948}$)} & {\bfseries EBE ($N = \num{2949}$)} & {\bfseries Science ($N = \num{2502}$)} & {\bfseries Commerce)} & {\bfseries BCom} & {\bfseries BBusSci} & {\bfseries EBE} & {\bfseries Science}
\\\midrule
1 & 0.0 & 0.0& 0.0 & 0.0& 0.0& 1.5 & 1.7 & 1.4 & 10.3 & 12.9\\
& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(1.2{\,;\,}1.8)} & {(1.2{\,;\,}2.2)} & {(1.0{\,;\,}1.7)} & {(9.2{\,;\,}11.4)} & {(11.6{\,;\,}14.2)} \\[1ex]
2 & 0.0 & 0.0& 0.0 & 0.0& 0.0 & 3.0 &3.8 &2.5&7.3&7.5\\
& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(2.6{\,;\,}3.5)}& {(3.0{\,;\,}4.7)}& {(2.0{\,;\,}3.0)}& {(6.2{\,;\,}8.4)}& {(6.3{\,;\,}8.7)} \\[1ex]
3 & 14.3 & 35.1 & 1.6 & 0.0 & 43.5 & 2.9 & 4.3 &2.0 &5.2 &8.0 \\
& {(13.2{\,;\,}15.3)} & {(32.8{\,;\,}37.4)} & {(1.2{\,;\,}2.1)}& {(1.2{\,;\,}1.8)}& {(41.0{\,;\,}46.1)}& {(2.3{\,;\,}3.4)}& {(3.3{\,;\,}5.3)}& {(1.5{\,;\,}2.5)}& {(4.1{\,;\,}6.2)}& {(6.6{\,;\,}9.4)} \\[1ex]
4 & 61.0 & 55.2 & 63.0 & 42.9 & 55.4 &1.7 & 2.9 &1.3&3.2 &7.5 \\
& {(59.3{\,;\,}62.7)} & {(51.7{\,;\,}58.7)} & {(61.0{\,;\,}65.0)}& {(40.3{\,;\,}45.5)}& {(51.5{\,;\,}59.3)}& {(1.3{\,;\,}2.2)}& {(1.8{\,;\,}4.1)}& {(0.9{\,;\,}1.8)}& {(2.3{\,;\,}4.2)}& {(5.4{\,;\,}9.6)}\\[1ex]
5 & 72.5 & 63.6 & 76.0 & 57.2 &70.4 &4.4 &10.7 &2.0 &3.4 &8.3\\
& {(69.6{\,;\,}75.4)} &{(57.7{\,;\,}69.6)} & {(72.7{\,;\,}79.2)}& {(53.2{\,;\,}61.2)}& {(64.2{\,;\,}76.6)}& {(3.1{\,;\,}5.7)}& {(6.9{\,;\,}14.5)}& {(0.9{\,;\,}3.0)}& {(1.9{\,;\,}4.8)}& {(4.5{\,;\,}12.0)}\\[1ex]
6 & 79.9 & 73.5 & 83.3 & 68.0 &79.3 &5.0 &10.2 & 2.2 &3.3 &10.3 \\
& {(73.2{\,;\,}86.5)} & {(61.1{\,;\,}85.5)} & {(75.6{\,;\,}91.0)}& {(60.5{\,;\,}75.5)}& {(64.6{\,;\,}94.0)}& {(1.4{\,;\,}8.7)}& {(1.7{\,;\,}18.7)}& {($-$0.8{\,;\,}5.3)}& {(0.5{\,;\,}6.2)} & {($-$0.7{\,;\,}24.7)} \\[1ex]
7 & 75.0& 71.4 & 77.8 & 56.0 & 50.0 &18.8 &14.3 &22.2 &12.0 &50.0 \\
& {(53.8{\,;\,}96.2)} & {(38.0{\,;\,}104.9)} & {(50.6{\,;\,}104.9)}& {(36.5{\,;\,}75.5)}& {($-$19.3{\,;\,}119.3)}& {($-$0.4{\,;\,}37.9)}& {($-$11.6{\,;\,}40.2)}& {($-$4.9{\,;\,}49.4)} & {($-$0.7{\,;\,}24.7)}& {($-$19.3{\,;\,}119.3)} \\[1ex]
8 & 100.0 & 100.0 & 0.0 & 66.7 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0\\
& {(100.0{\,;\,}100.0)} & {(100.0{\,;\,}100.0)} & {(50.6{\,;\,}104.9)}& {(13.3{\,;\,}120.0)}& {(1.2{\,;\,}1.8)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
将此表放入页面内是另一个问题。
答案2
正如 Harish 已经指出的那样,这不可能出现在常规的纵向页面中。即使字体大小减小、列间距减小、标签大大缩短,如果不将页边距减小到 0.75 英寸或更小,您也无法并排显示 20 个置信区间值。
相对
即使使用默认边距,使用该包移动到横向也rotating
能使事情变得更容易。
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{rotating}
%\usepackage[margin=.75in]{geometry} % Maximum size of margins for regular table
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{table}
\centering
\small
\setlength{\tabcolsep}{4.0pt}
\caption[Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$)]{Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$). \\[\medskipamount]
95\% confidence intervals given in parentheses below the point estimates.}
\label{table:SurvivalAll}
\begin{tabular}{
S[table-format=1.0]
*{10}{S[table-format=2.1]}
}
\toprule
\bfseries{Year} &
\multicolumn{5}{c}{\bfseries Hazard Ratio --- Graduation} &
\multicolumn{5}{c}{\bfseries Hazard Ratio --- Academically Excluded}
\\
\cmidrule(rl){2-6}
\cmidrule(rl){7-11}
& {C} & {BC} & {BBS} & {EBE} & {S}
& {C} & {BC} & {BBS} & {EBE} & {S} \\
& {$N = \num{6508}$} & {$N = \num{2560}$} & {$N = \num{3948}$} & {$N = \num{2949}$} & {$N = \num{2502}$}
\\
1 & 0.0 & 0.0& 0.0 & 0.0& 0.0& 1.5 & 1.7 & 1.4 & 10.3 & 12.9\\
& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(1.2{\,;\,}1.8)} & {(1.2{\,;\,}2.2)} & {(1.0{\,;\,}1.7)} & {(9.2{\,;\,}11.4)} & {(11.6{\,;\,}14.2)} \\[1ex]
\bottomrule
\end{tabular}
\end{table}
\clearpage
\begin{sidewaystable}
\centering
\small
\setlength{\tabcolsep}{4.0pt}
\caption[Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$)]{Presentation of survival data for the Commerce, EBE and Science faculties ($N = \num{11 959}$). \\[\medskipamount]
95\% confidence intervals given in parentheses below the point estimates.\\[\medskipamount]
\lipsum[1]}
\label{table:sidewaysSurvivalAll}
\begin{tabular}{
S[table-format=1.0]
*{10}{S[table-format=2.1]}
}
\toprule
\bfseries{Year} &
\multicolumn{5}{c}{\bfseries Hazard Ratio --- Graduation} &
\multicolumn{5}{c}{\bfseries Hazard Ratio --- Academically Excluded}
\\
\cmidrule(rl){2-6}
\cmidrule(rl){7-11}
& {Commerce} & {BCom} & {BBusSci} & {EBE} & {Science}
& {Commerce} & {BCom} & {BBusSci} & {EBE} & {Science} \\
& {$N = \num{6508}$} & {$N = \num{2560}$} & {$N = \num{3948}$} & {$N = \num{2949}$} & {$N = \num{2502}$}
\\
1 & 0.0 & 0.0& 0.0 & 0.0& 0.0& 1.5 & 1.7 & 1.4 & 10.3 & 12.9\\
& {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)} & {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(0.0{\,;\,}0.0)}& {(1.2{\,;\,}1.8)} & {(1.2{\,;\,}2.2)} & {(1.0{\,;\,}1.7)} & {(9.2{\,;\,}11.4)} & {(11.6{\,;\,}14.2)} \\[1ex]
\bottomrule
\end{tabular}
\end{sidewaystable}
\end{document}
我清理了一些其他不是绝对必要的东西(表格*),可以用旋转表格(风险比缩写)使其更明确,或者不正确(--
对于一系列数字,---
对于长破折号)。