我的列標題文字對齊方式 - “累計需要通過的課程數量”和“累計需要通過的高級課程數量”顯然是錯誤的。我確實認識到這些是異常長的列標題,但目前我想不出比這更精確的術語。
我想要的是兩個列標題來更多地“包裹”“BSc”和“EDP”,儘管不完全一樣。也許如果截斷在“課程”一詞上(將“必修”移至第二行),那就太好了。另外,是否可以將 EDP 列稍微向右移動一點,以便它與上面的“課程”一詞更緊密地對齊?
微量元素:
\documentclass{article}
\usepackage{booktabs, threeparttable}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\begin{document}
\begin{table}[H]
\begin{threeparttable}
\caption{Minimum Requirements for Automatic Readmission into the Science Faculty}
\label{table:sci}
\begin{tabular}{@{}p{0.18\textwidth}*{4}{L{\dimexpr0.1\textwidth-2\tabcolsep\relax}}@{}}
\toprule
& \multicolumn{2}{c}{\bfseries Cumulative Number of Courses Required to be Passed} &
\multicolumn{2}{c}{\bfseries Cumulative Number of Senior Courses Required to be Passed} \\
\cmidrule(l){2-3} \cmidrule(l){4-5}
& BSc & EDP & BSc & EDP \\
\midrule
First-year & 2 & 2 & --- & --- \\
Second-year & 7 & 6 & --- & --- \\
Third-year & 11 & 10 & 3 & 2 \\
Fourth-year & 15 & 14 & 6 & 5 \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
答案1
我對你的表做了三處更改:
1)我補充說\centering
2)我將右側4列的寬度更改為0.2\textwidth...
,並且
3)我將每個標題都放在自己的\Longstack
.這需要在序言中進行三項額外的調整:添加stackengine
包;告訴套件用作\#
行尾,因為tabular
已經使用了\\
(請注意,最新stackengine
版本 4.00 可以使用\\
行尾分隔符,甚至嵌套在 內tabular
);並告訴套件在堆疊行的基線之間設定 12pt,因為將tabular
的值清除\baselineskip
,否則這是預設的長堆疊間隙。請注意,您可以提供\Longstack
a[l]
或[r]
可選參數來更改預設[c]
對齊方式。
\documentclass{article}
\usepackage{booktabs, threeparttable, stackengine}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\setstackEOL{\#}
\setstackgap{L}{12pt}
\begin{document}
\begin{table}[ht]
\centering
\begin{threeparttable}
\caption{Minimum Requirements for Automatic Readmission into the Science Faculty}
\label{table:sci}
\begin{tabular}{@{}p{0.18\textwidth}*{4}{L{\dimexpr0.20\textwidth-2\tabcolsep\relax}}@{}}
\toprule
& \multicolumn{2}{c}{\bfseries \Longstack{Cumulative Number\# of Courses Required\# to be Passed}} &
\multicolumn{2}{c}{\bfseries \Longstack{Cumulative Number of\# Senior Courses Required\# to be Passed}} \\
\cmidrule(l){2-3} \cmidrule(l){4-5}
& BSc & EDP & BSc & EDP \\
\midrule
First-year & 2 & 2 & --- & --- \\
Second-year & 7 & 6 & --- & --- \\
Third-year & 11 & 10 & 3 & 2 \\
Fourth-year & 15 & 14 & 6 & 5 \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
答案2
不要用c
在\multicolumn{2}{c}{...
但是
\multicolumn{2}{L{\dimexpr0.3\linewidth-8\tabcolsep\relax}}{...
完整程式碼:
\documentclass{article}
\usepackage{booktabs, threeparttable}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\begin{document}
\begin{table}[H]
\begin{threeparttable}
\caption{Minimum Requirements for Automatic Readmission into the Science Faculty}
\label{table:sci}
\begin{tabular}{@{}p{0.18\textwidth}*{4}{L{\dimexpr0.3\linewidth-8\tabcolsep\relax}}@{}}
\toprule
& \multicolumn{2}{L{\dimexpr0.4\linewidth-4\tabcolsep\relax}}{\bfseries Cumulative Number of Courses Required to be Passed} &
\multicolumn{2}{L{\dimexpr0.4\linewidth-4\tabcolsep\relax}}{\bfseries Cumulative Number of Senior Courses Required to be Passed} \\
\cmidrule(l){2-3} \cmidrule(l){4-5}
& BSc & EDP & BSc & EDP \\
\midrule
First-year & 2 & 2 & --- & --- \\
Second-year & 7 & 6 & --- & --- \\
Third-year & 11 & 10 & 3 & 2 \\
Fourth-year & 15 & 14 & 6 & 5 \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}