Wrapping text in a table cell
I made three changes to your table:
1) I added \centering
2) I changed the width of the 4 right-side columns to 0.2\textwidth...
, and
3) I placed the headers each in its own \Longstack
. This required three additional tweaks in the preamble: add the stackengine
package; tell the package to use \#
as the end-of-line, since tabular
is already using \\
(note that the latest stackengine
version 4.00 can use \\
end-of-line delimiters, even nested inside a tabular
); and tell the package to set 12pt between baselines of the stack lines, since tabular
zeroes out the value of \baselineskip
, which is otherwise the default long-stack gap. Note that you can give the \Longstack
a [l]
or [r]
optional argument to change it from the default [c]
alignment.
\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}
Don't use c
in \multicolumn{2}{c}{...
but
\multicolumn{2}{L{\dimexpr0.3\linewidth-8\tabcolsep\relax}}{...
Full code:
\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}