자동 줄 바꿈을 유지하면서 테이블 형식 내부의 브레이크라인

자동 줄 바꿈을 유지하면서 테이블 형식 내부의 브레이크라인

저는 다음과 같은 매크로를 선언했습니다.

\newcommand{\itemcell}[1]{%
    \begin{tabular}[t]{@{}l@{}}#1\end{tabular}
} 

하지만 지금은 이 문제로 어려움을 겪고 있습니다. 더 이상 자동 줄 바꿈을 허용하지 않기 때문입니다. 아래 예를 참조하세요.

\begin{longtable}{p{4cm}p{1.5cm}p{1.2cm}p{1.2cm}p{1.2cm}p{\dimexpr\columnwidth-9.1cm-12\tabcolsep\relax}}
\toprule
Title 1 & Title 2 & Title 3 & Title 4 & Title 5 & Title 6 \\
\midrule
a       & b       & c       & d       & e       & \itemcell{This is a very long description which won't fit in 1 line, it should break, but it won't\\And this is a second line} \\
\bottomrule
\end{longtable}

내용이 \itemcell{}열 끝에서 줄바꿈되지 않아 과도하게 hbox들어옵니다.

기본 동작을 다시 가져오려면 이 매크로를 어떻게 배열해야 합니까?

답변1

p열은 줄 바꿈을 허용하므로 매크로가 전혀 필요하지 않습니다.

\begin{longtable}{p{4cm}p{1.5cm}p{1.2cm}p{1.2cm}p{1.2cm}p{\dimexpr\columnwidth-9.1cm-12\tabcolsep\relax}}
\toprule
Title 1 & Title 2 & Title 3 & Title 4 & Title 5 & Title 6 \\
\midrule
a       & b       & c       & d       & e       &
This is a very long description which won't fit in 1 line, it should break, but it won't

And this is a second line\\
\bottomrule
\end{longtable}

열 에서 c로컬로 중첩된 표 형식을 사용하여 수동으로 줄 바꿈을 사용하여 여러 줄을 허용할 수 있지만 정의에 누락된 공백이 추가됩니다.%

\newcommand{\itemcell}[1]{%
    \begin{tabular}[t]{@{}l@{}}#1\end{tabular}%%%%
}

관련 정보