
我的表格中有一個句子太長,導致我的表格超出了頁面範圍。如何將句子分成幾行,以免破壞表格的佈局?
\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
包,並使用\toprule
,midrule
和bottomrule
代替\hline
。
p{}
-列預設為兩端對齊,因此您也可以考慮將寬列設定為右側不齊整。標準 LaTeX\raggedright
不會對單字進行連字符,因此如果您的文字非常參差不齊,則需要在參差不齊的列中進行連字符。載入包襤褸2e在序言中並使用命令\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}