
我希望表格中的文字自動換行,我使用'p'類型的列來實現。
\documentclass{article}
\begin{document}
\begin{tabular}{p{2.5cm}|p{2.5cm}|p{2.7cm}|p{2.7cm}|p{2.5cm}}
\hline
\cline{1-6}
Genitourinary & Grade 1 & Grade 2 & Grade 3 & Grade 4 \\
\hline
Dysurie & Not therapy & Oral treatment (no narcotic analgesics) & Narcotic analgesics & Not \defined \\
Frequency & once/2h, twice pretherapy & once/1h &once/0.5h (more frequent than hourly) & Not defined \\
\hline
\end{tabular}
\hfill \break
\end{document}
答案1
如果您希望允許連字符,同時單字之間具有正常間距,則可以\RaggedRight
在每列的開頭使用該指令。
另外,由於您的表格幾乎是 textwidth 大,為什麼不使用tabularx
?您不必計算每列必須有多寬才能適合text width
。
最後備註:由於\hline\cline
只製作較粗的規則,因此您也可以載入makecell
並使用其\Xhline
命令來處理可變寬度的線條。然後,您也可以使用該\makecell
命令使列標題居中。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage{ragged2e}
\usepackage{tabularx, makecell}
\setlength{\extrarowheight}{2pt}
\setlength{\tabcolsep}{3pt}%
\begin{document}
\centering \begin{tabular}{p{2.5cm}|>{\RaggedRight}p{2.5cm}|>{\RaggedRight}p{2.7cm}|>{\RaggedRight}p{2.7cm}|p{2.5cm}}
\hline
\cline{1-5}
Genitourinary & Grade 1 & Grade 2 & Grade 3 & Grade 4 \\
\hline
Dysurie & Not therapy & Oral treatment (no narcotic analgesics) & Narcotic analgesics & Not defined \\
Frequency & once/2h, twice pretherapy & once/1h &once/0.5h (more frequent than hourly) & Not defined \\
\hline
\end{tabular}
\vspace{1cm}
\begin{tabularx}{\linewidth}{>{\RaggedRight\arraybackslash}X*{4}{|>{\RaggedRight\arraybackslash}X}}
\Xhline{0.8pt}
Genitourinary & \makecell{Grade 1} & \makecell{Grade 2} & \makecell{Grade 3} & \makecell{Grade 4} \\
\hline
Dysurie & Not therapy & Oral treatment (no narcotic analgesics) & Narcotic analge\-sics & Not defined \\
Frequency & once/2h, twice pretherapy & once/1h &once/0.5h (more frequent than hourly) & Not defined \\
\hline
\end{tabularx}
\hfill \break
\end{document}