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.

My vertical lines are being broken up (disrupted) by horizontal booktabs lines. How can I fix this?

It's well and good to say use \hline but I also need a cmidrule that spans only the second two columns which have no \hline equivalent to my knowledge. Also \hline is ugly because it doesn't automatically leave any vertical space between the line and the preceding/following lines of text.

Table

\documentclass[a4paper,12pt]{article}
\date{}
\usepackage{a4wide}
\usepackage{booktabs} %for top, middle and bottomline
\usepackage{multirow} %multi column and row spanning
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{multicol}
\usepackage{blindtext}


    \begin{document}

    \begin{multicols}{2}

    \subsection*{Results}

 \resizebox{\columnwidth}{!}{%
\begin{tabular}{@{} l | c | c @{}}
\toprule
Characteristic & \multicolumn{2}{c}{Result}\     \cmidrule{2-3}
 & Seaweed isolate & Coral isolate \    \midrule
Cell shape & Rod & Rod\    Gram stain & $-$ & $-$\    Oxidase & $+$ & $-$\    Catalase & $+$ & $-$\    MSA & Growth & No growth\    Anaerobic & Growth (weak) & No growth\    Motility & & \    Indole production & & \    Hugh \& Leifsons & & \    \bottomrule
\end{tabular}
}

    \blindtext

    {\noindent
    \begin{tabularx}{\columnwidth}
    { | l | >{\raggedright\arraybackslash} X | >{\centering\arraybackslash} X | }
    Leave this column alone. & Left justify and adjust this column. &
    Centre and adjust this column. \\ 
    \end{tabularx}
    }

    \end{multicols}

    \end{document}
share|improve this question
2  
BTW, please consider editing your answer down to a minimal example: most of the packages you load are not needed. –  Joseph Wright May 12 '11 at 19:02
10  
(As you know about booktabs, I'm left wondering why you want vertical lines. The booktabs manual is pretty clear on why they are not a good thing in formal tables.) –  Joseph Wright May 12 '11 at 19:05
3  
@ptrcao: Please read the booktabs manual on this. As you should not have vertical rules in formal tables, they are not supported by booktabs. (I suspect the implementation would also be awkward, to say the least.) –  Joseph Wright May 12 '11 at 19:14
1  
Thanks, yeah, I know it is discouraged; rest assured, I've read the manual and I know the comment by the package author you refer to. The reason I'm using vertical rules is more because it is a publication convention. –  ptrcao May 12 '11 at 19:23
4  
I appreciate the advice and I know where it is coming from. I try to avoid it where I can. If anyone knows how to implement unbroken vertical lies with booktabs or otherwise to equivalent effect, I'd still be interested. –  ptrcao May 12 '11 at 19:31

1 Answer 1

up vote 13 down vote accepted

You can use the \extrarowheight command from the array package to stretch all the rows. Otherwise you can define your own "strut" command to enlarge a single row. The code below is based on array's strut box. If you are using vertical lines, then us it on the sides also.

EDIT: There is also the bigstrut package

I have also include an example how to do it properly with booktabs

\documentclass{article}
\usepackage{array}
    %\setlength{\extrarowheight}{1pt}
\usepackage{booktabs} %for top, middle and bottomline
\usepackage{bigstrut}
    \setlength\bigstrutjot{3pt}

\makeatletter
\newlength\mylena
\newlength\mylenb
\newcommand\mystrut[1][2]{%
    \setlength\mylena{#1\ht\@arstrutbox}%
    \setlength\mylenb{#1\dp\@arstrutbox}%
    \rule[\mylenb]{0pt}{\mylena}}
\makeatother

\begin{document}
\noindent With mystrut\par
\bigskip
\begin{tabular}{|l|c|c|}
\hline
    \mystrut   & \multicolumn{2}{c|}{Result}\\
\cline{2-3}
    \mystrut
    Characteristic    & Seaweed isolate & Coral isolate  \\
\hline
    \mystrut
    Cell shape        & Rod             & Rod\\
    Gram stain        & $-$             & $-$\\
    Oxidase           & $+$             & $-$\\
    Catalase          & $+$             & $-$\\
    MSA               & Growth          & No growth\\
    Anaerobic         & Growth (weak)   & No growth\\
    Motility          &                 & \\
    Indole production &                 & \\
    Hugh \& Leifsons  &                 & \\
\hline
\end{tabular}

\bigskip
\noindent With bigstrut\par
\bigskip
\begin{tabular}{|l|c|c|}
\hline
    \bigstrut   & \multicolumn{2}{c|}{Result}\\
\cline{2-3}
    \bigstrut
    Characteristic    & Seaweed isolate & Coral isolate  \\
\hline
    \bigstrut[t]
    Cell shape        & Rod             & Rod\\
    Gram stain        & $-$             & $-$\\
    Oxidase           & $+$             & $-$\\
    Catalase          & $+$             & $-$\\
    MSA               & Growth          & No growth\\
    Anaerobic         & Growth (weak)   & No growth\\
    Motility          &                 & \\
    Indole production &                 & \\
    \bigstrut[b]
    Hugh \& Leifsons  &                 & \\
\hline
\end{tabular}

\bigskip
\noindent With booktabs\par
\bigskip
\begin{tabular}{@{}lcc@{}}
\toprule
                      & \multicolumn{2}{c@{}}{Result}\\
\cmidrule(l){2-3}
     Characteristic   & Seaweed isolate & Coral isolate \\
\cmidrule( r){1-1}
\cmidrule(lr){2-2}
\cmidrule(l ){3-3}
    Cell shape        & Rod             & Rod\\
    Gram stain        & $-$             & $-$\\
    Oxidase           & $+$             & $-$\\
    Catalase          & $+$             & $-$\\
    MSA               & Growth          & No growth\\
    Anaerobic         & Growth (weak)   & No growth\\
    Motility          &                 & \\
    Indole production &                 & \\
    Hugh \& Leifsons  &                 & \\
\bottomrule
\end{tabular}
\end{document}

The output is

enter image description here

share|improve this answer
    
Comprehensive and to the point. Thanks Danie. :) –  ptrcao May 13 '11 at 9:56

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.