表のセル内でテキストを折り返す

表のセル内でテキストを折り返す

列ヘッダーのテキスト配置(「合格が必要なコースの累計数」と「合格が必要な上級コースの累計数」)が明らかに間違っています。これらが異常に長い列ヘッダーであることは認識していますが、現時点ではこれ以上に正確な用語が思いつきません。

ここに画像の説明を入力してください

私が望んでいるのは、2 つの列ヘッダーが「BSc」と「EDP」の周囲をもっと「囲む」ことですが、完全にそうである必要はありません。おそらく、カットオフが「コース」という単語にある場合 (「必須」を 2 行目に移動する)、それは良いでしょう。また、EDP 列をもう少し右に移動して、上の「コース」という単語とより密接に揃えることは可能ですか?

MWE:

\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

テーブルに 3 つの変更を加えました:

1) 追加しました\centering

2) 右側の4列の幅を に変更し0.2\textwidth...

3) ヘッダーをそれぞれ独自の に配置しました\Longstack。これにより、プリアンブルで 3 つの追加調整が必要になりました。パッケージを追加します。では既に を使用しているため、パッケージに を行末としてstackengine使用するように指示します(最新バージョン 4.00では、 内にネストされていても行末区切り文字を使用できることに注意してください)。は の値をゼロにするため、パッケージにスタック行のベースライン間に 12pt を設定するように指示します。 は、それ以外の場合はデフォルトのロングスタック ギャップです。またはオプションの引数を指定して、デフォルトの配置を変更できることに注意してください。\#tabular\\stackengine\\tabulartabular\baselineskip\Longstack[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}

ここに画像の説明を入力してください

関連情報