所以我有一个相当大的表格,正如您将在我的代码中看到的那样。我更希望(如果可能的话)将表格放在“正常”的纵向页面上(个人偏好,因为我认为这样更容易阅读)。主要问题是标题太长(特别是最后 3 列),所以也许换行文本会比较合适。但是,如果表格不能放在纵向页面上(并且看起来相当美观!),我想我必须走水平页面路线。最合适的包是什么,相关的代码是什么?
\documentclass{article}
\usepackage{booktabs, siunitx}
\begin{document}
\begin{table}[H]
\caption{Presentation of survival data for the whole sample (N = 13 298)}
\label{table:SurvivalAll}
\begin{tabular*}{\textwidth}{
!{\extracolsep{\fill}}
l
*{8}{S[table-format=2.2]}
}
\toprule
{\bfseries Year} & {\bfseries Risk Set} & {\bfseries Graduated} & {\bfseries Academically Excluded} & {\bfseries Transferred} & {\bfseries Censored} & {\bfseries Hazard Ratio - Graduates (\%)} & {\bfseries Hazard Ratio - Academically Excluded (\%)} & {\bfseries Hazard Ratio - Transferred (\%)} \\
\midrule
1 & 13 298 & 0 & 725 & 583 & 1915 & 0.00 & 5.45 & 4.38 \\
2 & 10 075 & 0 & 474 & 176 & 1617 & 0.00 & 4.70 & 1.75 \\
3 & 7 808 & 1266 & 334 & 38 & 1030 & 16.21 & 4.28 & 0.49 \\
4 & 5 139 & 2782 & 147 & 2 & 455 & 54.14 & 2.86 & 0.04 \\
5 & 1 754 & 1135 & 76 & 2 & 205& 64.71 & 4.33 & 0.11 \\
6 & 336 & 235 & 17 & 0 & 39 & 69.94 & 5.06 & 0.00 \\
7 & 45 & 28 & 7 & 0 & 5 & 62.22 & 15.56 & 0.00 \\
8 & 5 & 3 & 0 & 0 & 2 & 60.00 & 0.00 & 0.00 \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
答案1
为标题添加图例并缩写标题:
\documentclass{article}
\usepackage{booktabs, siunitx,caption}
\begin{document}
\begin{table}
\centering
\caption[Presentation of survival data for the whole sample ($N = \num{13 298}$)]
{Presentation of survival data for the whole sample ($N = \num{13 298}$). Legend:
Y:~Year; RS:~Risk Set; G:~Graduated; AE:~Academically Excluded;
T:~Transferred; C:~Censored; HRG:~Hazard Ratio --~Graduates;
HRA: Hazard Ratio --~Academically Excluded; HRT:~Hazard Ratio --~Transferred}
\label{table:SurvivalAll}
\begin{tabular}{
@{}
S[table-format=1.0]
S[table-format=5.0,group-four-digits=true]
S[table-format=4.0]
S[table-format=3.0]
S[table-format=3.0]
S[table-format=4.0]
S[table-format=2.2]
S[table-format=2.2]
S[table-format=1.2]
@{}
}
\toprule
{\bfseries Y} & {\bfseries RS} & {\bfseries G} &
{\bfseries AE} & {\bfseries T} & {\bfseries C} &
{\bfseries HRG} & {\bfseries HRAE} & {\bfseries HRT} \\
& & & & & & {(\%)} & {(\%)} & {(\%)} \\
\midrule
1 & 13 298 & 0 & 725 & 583 & 1915 & 0.00 & 5.45 & 4.38 \\
2 & 10 075 & 0 & 474 & 176 & 1617 & 0.00 & 4.70 & 1.75 \\
3 & 7 808 & 1266 & 334 & 38 & 1030 & 16.21 & 4.28 & 0.49 \\
4 & 5 139 & 2782 & 147 & 2 & 455 & 54.14 & 2.86 & 0.04 \\
5 & 1 754 & 1135 & 76 & 2 & 205 & 64.71 & 4.33 & 0.11 \\
6 & 336 & 235 & 17 & 0 & 39 & 69.94 & 5.06 & 0.00 \\
7 & 45 & 28 & 7 & 0 & 5 & 62.22 & 15.56 & 0.00 \\
8 & 5 & 3 & 0 & 0 & 2 & 60.00 & 0.00 & 0.00 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
拉伸表格并在图例前添加垂直空间的代码。老实说,我不会拉伸表格。
\documentclass{article}
\usepackage{booktabs, siunitx,caption}
\begin{document}
\begin{table}
\centering
\caption[Presentation of survival data for the whole sample ($N = \num{13 298}$)]
{Presentation of survival data for the whole sample ($N = \num{13 298}$).\\[\medskipamount]
Legend:
Y:~Year; RS:~Risk Set; G:~Graduated; AE:~Academically Excluded;
T:~Transferred; C:~Censored; HRG:~Hazard Ratio --~Graduates;
HRA: Hazard Ratio --~Academically Excluded; HRT:~Hazard Ratio --~Transferred}
\label{table:SurvivalAll}
\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
S[table-format=1.0]
S[table-format=5.0,group-four-digits=true]
S[table-format=4.0]
S[table-format=3.0]
S[table-format=3.0]
S[table-format=4.0]
S[table-format=2.2]
S[table-format=2.2]
S[table-format=1.2]
@{}
}
\toprule
{\bfseries Y} & {\bfseries RS} & {\bfseries G} &
{\bfseries AE} & {\bfseries T} & {\bfseries C} &
{\bfseries HRG} & {\bfseries HRAE} & {\bfseries HRT} \\
& & & & & & {(\%)} & {(\%)} & {(\%)} \\
\midrule
1 & 13 298 & 0 & 725 & 583 & 1915 & 0.00 & 5.45 & 4.38 \\
2 & 10 075 & 0 & 474 & 176 & 1617 & 0.00 & 4.70 & 1.75 \\
3 & 7 808 & 1266 & 334 & 38 & 1030 & 16.21 & 4.28 & 0.49 \\
4 & 5 139 & 2782 & 147 & 2 & 455 & 54.14 & 2.86 & 0.04 \\
5 & 1 754 & 1135 & 76 & 2 & 205 & 64.71 & 4.33 & 0.11 \\
6 & 336 & 235 & 17 & 0 & 39 & 69.94 & 5.06 & 0.00 \\
7 & 45 & 28 & 7 & 0 & 5 & 62.22 & 15.56 & 0.00 \\
8 & 5 & 3 & 0 & 0 & 2 & 60.00 & 0.00 & 0.00 \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
答案2
也许
\documentclass{article}
\usepackage{booktabs, siunitx}
\begin{document}
\begin{table}[H]
\caption{Presentation of survival data for the whole sample (N = 13 298)}
\label{table:SurvivalAll}
\newcommand\hd[1]{\textbf{\parbox[t]{10mm}{\noindent\nobreak\hspace{0pt}\centering#1}}}
\setlength\tabcolsep{4pt}
\begin{tabular*}{\textwidth}{
!{\extracolsep{\fill}}
l
*{8}{S[table-format=2.2]}
}
\toprule
&&&&&&\multicolumn{3}{c}{\textbf{Hazard Ratio (\%)}}\\
\hd{Year} & \hd{Risk Set} & \hd{Graduated} & \hd{Excluded} &
\hd{Transferred} & \hd{Censored} &
\hd{Graduates}&
\hd{Excluded}&
\hd{Transferred} \\
\midrule
1 & 13 298 & 0 & 725 & 583 & 1915 & 0.00 & 5.45 & 4.38 \\
2 & 10 075 & 0 & 474 & 176 & 1617 & 0.00 & 4.70 & 1.75 \\
3 & 7 808 & 1266 & 334 & 38 & 1030 & 16.21 & 4.28 & 0.49 \\
4 & 5 139 & 2782 & 147 & 2 & 455 & 54.14 & 2.86 & 0.04 \\
5 & 1 754 & 1135 & 76 & 2 & 205& 64.71 & 4.33 & 0.11 \\
6 & 336 & 235 & 17 & 0 & 39 & 69.94 & 5.06 & 0.00 \\
7 & 45 & 28 & 7 & 0 & 5 & 62.22 & 15.56 & 0.00 \\
8 & 5 & 3 & 0 & 0 & 2 & 60.00 & 0.00 & 0.00 \\
\bottomrule
\end{tabular*}
\noindent X\dotfill X
\end{table}
\end{document}
答案3
\documentclass{article}
\usepackage{booktabs, siunitx}
\def\RB#1{\rotatebox{90}{\bfseries#1}}
\begin{document}
\begin{table}[H]
\caption{Presentation of survival data for the whole sample (N = 13 298)}
\label{table:SurvivalAll}
\centering
\begin{tabular}{@{} l
S[table-format=5.0]
S[table-format=4.0]
S[table-format=3.0]
S[table-format=3.0]
S[table-format=4.0]
S[table-format=2.2]
S[table-format=2.2]
S[table-format=1.2] } \toprule
{\RB{Year}} &
{\RB{Risk Set}} &
{\RB{Graduated}} &
{\RB{\shortstack{Academically\\Excluded}}} &
{\RB{Transferred}} &
{\RB{Censored}} &
{\RB{\shortstack{Hazard Ratio -\\Graduates}}} &
{\RB{\shortstack{Hazard Ratio -\\Academically\\ Excluded}}} &
{\RB{\shortstack{Hazard Ratio -\\Transferred}}} \\\midrule
1 & 13 298 & 0 & 725 & 583 & 1915 & 0.00 & 5.45 & 4.38 \\
2 & 10 075 & 0 & 474 & 176 & 1617 & 0.00 & 4.70 & 1.75 \\
3 & 7 808 & 1266 & 334 & 38 & 1030 & 16.21 & 4.28 & 0.49 \\
4 & 5 139 & 2782 & 147 & 2 & 455 & 54.14 & 2.86 & 0.04 \\
5 & 1 754 & 1135 & 76 & 2 & 205& 64.71 & 4.33 & 0.11 \\
6 & 336 & 235 & 17 & 0 & 39 & 69.94 & 5.06 & 0.00 \\
7 & 45 & 28 & 7 & 0 & 5 & 62.22 & 15.56 & 0.00 \\
8 & 5 & 3 & 0 & 0 & 2 & 60.00 & 0.00 & 0.00 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}