20

In the following table I get some vertical space after the rows whose content is short but not after the row having a cell with long content.

The problem is that I want to generate the report from my program and I won't know ahead of time whether each cell will be long or short and I am really hoping that I don't have to do something like examine the content and output different latex code for short and long content cells.

\documentclass{article}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{booktabs}
\usepackage{tabu}
\begin{document}

\begin{center}\small 
\extrarowsep=3pt\begin{tabu} to \columnwidth{>{\bfseries}lX}
            \everyrow{\tabucline[blue]-} 
A & a \\ 
B & b \\ 
C & c \\ 
D & Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \\ 
E & e \\ 
\end{tabu} 
\end{center} 

\end{document}

Output:

screenshot

21

For consistent spacing with tabu you should use the \tabulinesep command before your table. You can also make it so that the value stay applied throughout your document if you use it outside a block.

\documentclass{article}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{booktabs}
\usepackage{tabu}
\usepackage{lipsum}
\begin{document}
\tabulinesep=1.2mm
{\centering
\begin{tabu} to \columnwidth {>{\bfseries}lX}
\everyrow{\tabucline[blue]-} 
A & a \\ 
B & b \\ 
C & c \\ 
D & \lipsum[1] \\ 
E & e \\ 
\end{tabu}}
\end{document}
7
  • \begin{center}\small \extrarowsep=3pt\begin{tabu} to \columnwidth{>{\bfseries}lX} \everyrow{\tabucline[blue]-} A & a \\ B & b \\ C & c \\ D & \lipsum[1] \\ E & e \\ \end{tabu} \end{center} -- When I execute this (note the absence of \tabulinesep), I get some extra gap, the size a line would take, between the end of the filler text and the line. So, does the lipsum package add the relevant paragraph along with the break (I guess not!). So, what's happening?
    – kan
    Jul 23 '12 at 1:18
  • Please see here: The first is the OP's code. The second version is from the code I wrote in the previous comment -- An image. +1 BTW. :)
    – kan
    Jul 23 '12 at 1:21
  • 1
    (1) Even with \tabulinesep=1.2mm I get extra vertical space with \lipsum[1] but not if I write out the text in full as in my post. (2) The need to use \tabulinesep to get consistent results seems to be an unexpected deficiency in the tabu package and really means one should always use \tabulinesep whenever using tabu. This seems to be a bug in tabu. No one would intentionally design a package to be inconsistent by default. Jul 23 '12 at 2:22
  • 2
    @user1189687 Try the starred version of lipsum (\lipsum*[1]). See page 2 in the lipsum manual.
    – Sveinung
    Jul 23 '12 at 6:34
  • Good answer. But how did you choose the value 1.2mm? Jun 5 '17 at 20:11

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.