3

I have a table which has quite a lot of text but want to keep it on a portrait page. I am using the tabularx environment and managed to get all I want into the columns, but now the spacing between the words is super ugly. I'd rater define the orientation of my text in the table in each column, than having it justified. How can I change that? I am pretty new to latex and I still struggle a lot. I went through some similar questions already, but I only make it worse trying to fix my problem.

 \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}

Looks like this: enter image description here

6

You're after \raggedright, or \RaggedRight from the ragged2e package. The latter allows for hyphenation, in addition to making the text ragged right.

To insert it in each cell of a column, use >{... \RaggedRight}X. You already have the \hsize in >{..}, so only a small change is needed.

For convenience you could define a new column type, as shown below.

enter image description here

\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}
1

For this type of tables you might consider 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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.