Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
\begin{article} ?? \usepackage{tabular} ? I assume the image wasn't generated from the posted code? –  David Carlisle Apr 10 '13 at 13:32

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
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 '13 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. –  David Carlisle Apr 10 '13 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 '13 at 21:12
    
@HCAI c l r columns are single line natural width or p{..} columns are multi-line to a specified width –  David Carlisle Apr 10 '13 at 21:13
    
But c l r don't allow for hyphenation is that right? –  HCAI Apr 11 '13 at 9:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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