表内の長い文を複数行に分割する

表内の長い文を複数行に分割する

表の中に長すぎる文があり、表がページからはみ出てしまいます。表のレイアウトを崩さないように文を複数の行に分割するにはどうすればよいでしょうか。

\begin{table}[!htb]
\caption{}
\centering
\begin{tabular}{llll}
\hline
Material & Production & Description & Reference \\
\hline
 & a bene placito a bene placito a bene placito a bene placito &  & \\
\hline
\end{tabular}
\end{table}

前もって感謝します。

答え1

p{<width>}長い文がある列に使用します。幅は cm、pt、または LaTeX に有効な他の幅で指定できます。

\documentclass{article}

\begin{document}
\begin{table}[!htb]
\caption{}
\centering
\begin{tabular}{lp{4cm}ll}
\hline
Material & Production & Description & Reference \\
\hline
 & a bene placito a bene placito a bene placito a bene placito &  & \\
\hline
\end{tabular}
\end{table}
\end{document}

より見やすい表形式にするには、arrayおよびbooktabsパッケージをロードし、の代わりに\toprulemidrule、を使用することをお勧めします。bottomrule\hline

p{}-列はデフォルトで両端揃えに設定されているので、幅の広い列を右揃えに設定することも検討してください。標準の LaTeX では\raggedright単語をハイフンで区切らないため、テキストが非常に不揃いな場合は、不揃いな列でハイフンで区切る必要があります。パッケージをロードします。ぼろぼろ\RaggedRightプリアンブルに を追加し、の代わりにコマンドを使用します\raggedright。この例では違いは見られませんが、長い単語を含む狭い列を試してみてください。以下は変更された MWE です。

\documentclass{article}
\usepackage{ragged2e,array,booktabs}

\begin{document}
\begin{table}[!htb]
\caption{}
\centering
\begin{tabular}{l>{\RaggedRight}p{4cm}ll}
\toprule
Material & Production & Description & Reference \\
\midrule
 & a bene placito a bene placito a bene placito a bene placito &  & \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

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

関連情報