0

How to automatically adjust cell height based on content? The height of the cell with the normal distribution in it appears to be pushed down and not centrally aligned. Any thoughts? Similar to Automatic adjustment of cell width

enter image description here

\documentclass{article}%%%%%\begin{article}
\usepackage{booktabs}
\usepackage{array}%%%%%{tabular}
\begin{document}

    \begin{table}[htp]
     \centering
    \begin{tabular}{{}*5{>{\hspace{0pt}\raggedright\arraybackslash}p{\dimexpr(\textwidth-10\tabcolsep)/6\relax}}@{}}
     \toprule
     %\multicolumn{6}{c}{Care Type} \\
     %\cmidrule(l{2em}r{2em}){1-6}
    \addlinespace[2ex]
     \textbf{Lead author} & \textbf{Ref.} & \textbf{$\log_{10}$ reduction} & \textbf{In-vivo (i) /-vitro (t)} & \textbf{Organism} \\
     \midrule
     Girou &\cite{girou2002} & & i & Gram -ve bacteria\\
     Weber & \cite{weber2003} & (-0.2-0.2)&t &Bacilus spores\\
     Sickbert-Bennet &\cite{sickbert2005} & $N\sim$(1.10,0.8129)& t & \\
     Widmer &\cite{widmer2000} & & i & \\
       \bottomrule
     \end{tabular}
    \smallskip
     \caption{Literature for $log_{10}$ reductions of CFU for waterless alcohol rub, displayed as a continuous distribution or as a range}
     \label{tab:alcohol_rub}
    \end{table}
\end{document}
1
  • \begin{article} ?? \usepackage{tabular} ? I assume the image wasn't generated from the posted code? Apr 10, 2013 at 13:32

1 Answer 1

3

Please always test your code and generate the image from the code you post.

Your cell is top aligned with N~... appearing on the second line. The line can break (leaving just a strut on the first line) because of the \hspace{0pt} you added in the table preamble. Either don't add that or use \leavevmode\nolinebreak\hspace{0pt} so that it does not allow a break there.

The main problem is that entry is too wide for the column width you have specified.

6
  • Thank you for the edits. As a professional publisher how would you like to see that table ideally? It seems like there are a few issues going on there such as the vertical alignment of the (----) don't you think?
    – HCAI
    Apr 10, 2013 at 13:57
  • @HCAI The table column widths are all wrong and dominated by the headings eg the data in column 4 is a single letter but it is given as much space as a whole sentence in column 5 or a wide expression in column 3 if you adjusted the table and abbreviated the headings and made the whole table wider it might look better. Apr 10, 2013 at 14:21
  • Thank you. I've made a couple of changes to the widths and it's looking much better. How do you make variable widths for columns without specifying each one individually? is it possible?
    – HCAI
    Apr 10, 2013 at 21:12
  • @HCAI c l r columns are single line natural width or p{..} columns are multi-line to a specified width Apr 10, 2013 at 21:13
  • But c l r don't allow for hyphenation is that right?
    – HCAI
    Apr 11, 2013 at 9:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .