我有一张表格,里面有很多文本,但我想把它们放在纵向页面上。我使用 tabularx 环境,并设法将所有我想要的内容放入列中,但现在单词之间的间距非常难看。我宁愿在表格的每一列中定义文本的方向,而不是让文本对齐。我该如何改变这种情况?我对 latex 还很陌生,仍然很纠结。我已经遇到过一些类似的问题,但试图解决问题只会让情况变得更糟。
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{chngcntr}
\counterwithin{figure}{section}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{tabularx}
\begin{document}
\begin{table}[htb]
\footnotesize
\begin{tabularx}{\textwidth}{>{\hsize=.4\hsize}X>{\hsize=.7\hsize}X>{\hsize=1.3\hsize}X>{\hsize=1.3\hsize}X>{\hsize=1.3\hsize}X}
\hline
\hline
\textbf{WHO grade} & \textbf{Type} & \textbf{Description} & \textbf{Treatment} & \textbf{Outcome} \\
\hline
\hline
I & Pilocytic astrocytoma & low proliferative potential, not diffusive & surgical resection & not associated with recurrence after complete resection\\
II & Diffuse glioma & infiltrative, low mitotic activity, well differentiated & surgical resection, adjuvant therapy & median survival $>$10 years, often recurrence as high-grade tumour\\
III & Anaplastic Astrocytoma & mitotically active, anaplastic histology and infiltrative capacity & surgical resection, aggressive adjuvant therapy & median survival 2-3 years, recurrence as grade IV\\
IV & GBM & mitotically active, anaplastic histology, highly infiltrative, necrisis, angiogenesis & surgical resection, aggressive adjuvant therapy & associated with rapid progression, median survival 14 month\\
\hline
\hline
\end{tabularx}
\caption{WHO Glioma Grades}
\label{table:glioma types}
\end{table}
\end{document}
答案1
您正在寻找\raggedright
,或\RaggedRight
来自该ragged2e
包。后者除了使文本右侧参差不齐外,还允许使用连字符。
要将其插入到列的每个单元格中,请使用>{... \RaggedRight}X
。您已经\hsize
在 中有了>{..}
,因此只需进行少量更改。
为了方便起见,您可以定义一个新的列类型,如下所示。
\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{chngcntr}
\counterwithin{figure}{section}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{tabularx}
% defines \RaggedRight
\usepackage{ragged2e}
% for nicer table rules
\usepackage{booktabs}
% define a new column type for convenience
\newcolumntype{L}[1]{>{\hsize=#1\hsize\RaggedRight} X}
\begin{document}
\begin{table}[htb]
\footnotesize
\begin{tabularx}{\textwidth}{L{0.4} L{0.7} *{3}{L{1.3}} }
\toprule
\textbf{WHO grade} & \textbf{Type} & \textbf{Description} & \textbf{Treatment} & \textbf{Outcome} \\
\midrule
I & Pilocytic astrocytoma & low proliferative potential, not diffusive & surgical resection & not associated with recurrence after complete resection\\
II & Diffuse glioma & infiltrative, low mitotic activity, well differentiated & surgical resection, adjuvant therapy & median survival $>$10 years, often recurrence as high-grade tumour\\
III & Anaplastic Astrocytoma & mitotically active, anaplastic histology and infiltrative capacity & surgical resection, aggressive adjuvant therapy & median survival 2-3 years, recurrence as grade IV\\
IV & GBM & mitotically active, anaplastic histology, highly infiltrative, necrisis, angiogenesis & surgical resection, aggressive adjuvant therapy & associated with rapid progression, median survival 14 month\\
\bottomrule
\end{tabularx}
\caption{WHO Glioma Grades}
\label{table:glioma types}
\end{table}
\end{document}
答案2
对于这种类型的表,您可以考虑tabulary
:
\documentclass[12pt]{article}
\usepackage{tabulary,booktabs}
\usepackage{ragged2e}
\begin{document}
\begin{table}[htbp]
\footnotesize
\setlength{\tymin}{40pt} % not so narrow columns
% use \RaggedRight instead of \raggedright
\let\raggedright\RaggedRight
\begin{tabulary}{\textwidth}{@{}LLLLL@{}}
\toprule
\textbf{WHO grade} &
\textbf{Type} &
\textbf{Description} &
\textbf{Treatment} &
\textbf{Outcome} \\
\midrule
I & Pilocytic astrocytoma &
low proliferative potential, not diffusive &
surgical resection &
not associated with recurrence after complete resection\\
II & Diffuse glioma &
infiltrative, low mitotic activity, well differentiated &
surgical resection, adjuvant therapy &
median survival $>10$ years, often recurrence as high-grade tumour\\
III & Anaplastic Astrocytoma &
mitotically active, anaplastic histology and infiltrative capacity &
surgical resection, aggressive adjuvant therapy &
median survival 2--3 years, recurrence as grade IV\\
IV & GBM &
mitotically active, anaplastic histology, highly infiltrative, necrisis, angiogenesis &
surgical resection, aggressive adjuvant therapy &
associated with rapid progression, median survival 14 month\\
\bottomrule
\end{tabulary}
\caption{WHO Glioma Grades}
\label{table:glioma types}
\end{table}
\end{document}