표 셀에서 텍스트 줄 바꿈

표 셀에서 텍스트 줄 바꿈

열 헤더의 "통과에 필요한 누적 강좌 수" 및 "통과에 필요한 시니어 강좌의 누적 수" 텍스트 정렬이 분명히 잘못되었습니다. 나는 이것이 비정상적으로 긴 열 머리글이라는 것을 알고 있지만 현재로서는 그것보다 더 정확한 용어를 생각할 수 없습니다.

여기에 이미지 설명을 입력하세요

내가 원하는 것은 "BSc"와 "EDP"를 더 많이 "감싸는" 두 개의 열 헤더입니다. 비록 정확히는 아니지만요. 아마도 잘린 부분이 "Courses"('필수'를 두 번째 줄로 이동)라는 단어에 있으면 좋을 것입니다. 또한 EDP 열을 조금 더 오른쪽으로 이동하여 위의 "Courses"라는 단어와 더 밀접하게 정렬될 수 있습니까?

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

귀하의 테이블에 세 가지 변경 사항을 적용했습니다.

1) 나는 추가했다\centering

2) 오른쪽 4개 열의 너비를 ,로 변경했습니다 0.2\textwidth....

3) 헤더를 각각 자체적으로 배치했습니다 \Longstack. 이를 위해서는 서문에서 세 가지 추가 조정이 필요했습니다. stackengine패키지를 추가하고; 은 이미 사용 중이므로 패키지에 \#줄 끝으로 사용하도록 지시합니다 (최신 버전 4.00 에서는 줄 끝 구분 기호를 사용할 수 있으며, 심지어 a 안에 중첩되어도 사용할 수 있습니다 ). 의 값을 0으로 만들기 때문에 스택 라인의 기준선 사이에 12pt를 설정하도록 패키지에 지시합니다. 그렇지 않으면 기본 긴 스택 간격입니다. a 또는 선택적 인수를 제공하여 기본 정렬에서 변경할 수 있습니다 .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}

여기에 이미지 설명을 입력하세요

관련 정보