2

I am trying to adjust the column parameters but I cannot find a good combination (l/X/p{.1\linewidth}). Adding there X makes the column extremely small in the example code of Fig. 1, which I do not understand. Therefore, I have no X there at the moment. Code which output fails with the last columns, in Fig. 2 without X

\documentclass{beamer}

%http://tex.stackexchange.com/a/309253/13173
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathpazo}
\usepackage[warn]{textcomp}

\usepackage{adjustbox}
\usepackage{tabularx}

\begin{document}

\begin{table}
\centering
\resizebox{.5\textheight}{!}{
\begin{tabularx}{\textwidth}{| l |  p{.27\linewidth} |  p{.27\linewidth} |  p{.27\linewidth} | p{.2\linewidth} |} %
\hline 
\textbf{Feature} & \textbf{Cytotoxic edema} 
         & \textbf{Vasogenic edema} 
         & \textbf{Interstitial edema} 
         & \textbf{Osmotic edema} \\ \hline 
Composition & i/c, acc. of water and Na+
        & e/c, ultrafiltrate of plasma
        & CSF
        & V(e/c) $>$ V(i/c) \\ \hline
Location of edema & Gray-white matter 
          & White - -
          & Periventricular white - - 
          & White - - \\ \hline
V(E/c fluid) & \textdownarrow 
         & \textuparrow 
         & \textuparrow 
         & \textuparrow \\ \hline
Etiology       & DM, hypothermia, ... 
           & Tumors, trauma, ...
           & Hydrocephalus 
           & Hemodialysis, hypertensive crisis, ...\\ \hline
Response to therapy & Yes/No (diuretics transiently eff.)
            & Yes (corticosteroids)
            & Yes (diuretics transiently eff.)
            & Yes/No \\ \hline
\end{tabularx}
}
\caption{Types of brain edema.}
\end{table}

\end{document}

Fig. 1 Output without X, Fig. 2 Output with one X

enter image description here enter image description here

3
  • In order for tabularx to work, you need at least one X-column. Your example code shows you're not using any.
    – Werner
    Mar 1, 2017 at 19:17
  • @Werner Adding there X makes the column extremely small, which I do not understand. Therefore, I have no X there at the moment. - - I added an output with one X. Mar 1, 2017 at 19:31
  • That's because there's no available room for an X-column once the other columns take up \textwidth...
    – Werner
    Mar 1, 2017 at 20:11

2 Answers 2

2

I would get rid of all vertical lines and most horizontal lines. I would also set the column types ragged-right rather than fully justified. Finally, don't use a table environment -- just place the "caption" in the argument of \frametitle. Observe that the code below by design does not employ \resizebox.

enter image description here

\documentclass{beamer}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usefonttheme{professionalfonts}
\usepackage{mathpazo}
\usepackage[warn]{textcomp}

\usepackage{ragged2e,tabularx,booktabs}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}

\hyphenation{cortico-steroids diu-ret-ics}
\begin{document}

\begin{frame}
\frametitle{Types of brain edema}

\footnotesize
\setlength\tabcolsep{2pt} % default: 6pt
\begin{tabularx}{\textwidth}{@{}
    >{\hsize=0.86\hsize}Y 
    *{4}{>{\hsize=1.035\hsize}Y} @{}}
\toprule
\textbf{Feature} & \textbf{Cytotoxic edema} 
         & \textbf{Vasogenic edema} 
         & \textbf{Interstitial edema} 
         & \textbf{Osmotic edema} \\ 
\midrule 
Composition & i/c, acc. of water and Na+
        & e/c, ultrafiltrate of plasma
        & CSF
        & V(e/c) > V(i/c) \\ 
\addlinespace
Location of edema & Gray-white matter 
          & White - -
          & Periventricular white - - 
          & White - - \\ 
\addlinespace
V(E/c fluid) & \textdownarrow 
         & \textuparrow 
         & \textuparrow 
         & \textuparrow \\ 
\addlinespace
Etiology       & DM, hypothermia, \dots 
           & Tumors, trauma, \dots
           & Hydrocephalus 
           & Hemodialysis, hypertensive crisis, \dots\\ \addlinespace
Response to therapy & Yes/No (diuretics transiently eff.)
            & Yes (corticosteroids)
            & Yes (diuretics transiently eff.)
            & Yes/No \\
\bottomrule
\end{tabularx}

\end{frame}
\end{document}
4
  • I am scared about using manually fontsize adjustment directly. I like the resizebox much more. Mar 1, 2017 at 19:50
  • 2
    @LéoLéopoldHertz준영, I have opposite scare ... resize box is desperate action of last resort without control on result which usually/many time gives ugly result as from aesthetic point of view as from aspect of readability ...
    – Zarko
    Mar 1, 2017 at 20:05
  • 3
    @LéoLéopoldHertz준영 never apply \resizebox to tables! Mar 1, 2017 at 20:18
  • You are both so correct! - - This output is so much superior. Mar 1, 2017 at 20:39
1
\begin{table}
\resizebox{\textwidth}{!}{%
  \begin{tabularx}{1.5\textwidth}{| l | X | X | X | X |} %
   ....

enter image description here

2
  • Confirmed, works! Thank you! The main thing is to change the first field to 1.5 and then you can use Xs freely. Why? Mar 1, 2017 at 19:44
  • 1
    The columns will be too small if you use only \textwidth.
    – user2478
    Mar 1, 2017 at 19:45

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.