
次のようなマクロを宣言しました:
\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}%%%%
}