我聲明了一個這樣的巨集:
\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}%%%%
}