2

When creating a tabu with two rows, I get more vertical spacing after the environment than when I create a tabu with only one row.

In the document below, the first tabu has two lines, and there is a small space between the end of the table and the rule below it. In the second tabu, I only have one line, and there is a larger space below it.

\documentclass{article}
\usepackage{geometry}
\usepackage{tabu}

\geometry{a4paper} 

\begin{document}
\begin{tabu} to \textwidth {X X}%
    These are words & in the first line \\%
    These are more words & in the second line%
\end{tabu}\par%
\rule{\textwidth}{0.4pt}\par%
%
%
\vspace{2em}\par%
%
%
\begin{tabu} to \textwidth {X X}%
    These are words & in the first line%
\end{tabu}\par%
\rule{\textwidth}{0.4pt}\par%
%
\end{document}

typeset output of above document, displaying inconsistency in spacing after a tabu environment

I've been quite careful (I think) with whitespace around the tabu, and I see no difference in the two tables aside from the different number of lines.

I know that I could fix this by adding a \vspace{0.5em} or similar right after the tabu with the small spacing, but I am using the tables in a custom command and I would like to avoid a hard-coded solution like this if possible.

This problem also comes up if I substitute a tabular for the tabu. Adding \tabulinesep=Xem fixes (or appears to fix) the problem for large X (>1em), but I need small spacings (ideally, ~0em).

Any ideas?

4

1 Answer 1

3

This has nothing to do with tabu, nor with tabular or similar environments.

We can replicate the “issue” with \parbox. In the code below, the red lines produced by \test show where TeX thinks the base line is.

\documentclass{article}
\usepackage{xcolor}

\newcommand{\test}{\textcolor{red}{\llap{\smash{\rule{12pt}{0.4pt}}}}}

\setlength{\parindent}{0pt}

\begin{document}

\test \parbox{4cm}{One liner xyz}\par
\test \rule{4cm}{0.4pt}

\bigskip

\test \parbox{4cm}{First line \\ second line xyz}\par
\test \rule{4cm}{0.4pt}

\bigskip

\test \parbox{4cm}{First line \\ second line \\ third line xyz}\par
\test \rule{4cm}{0.4pt}

\bigskip

\test \parbox[b]{4cm}{First line \\ second line xyz}\par
\test \rule{4cm}{0.4pt}

\end{document}

enter image description here

As you see, when we have two or more lines the \parbox is (almost) centered with respect to the base line (actually, shifted up a bit). The next paragraph only has a rule, which has very small height, so when TeX does its usual calculations, it finds that in the “two line” case the normal distance between base lines can be preserved; in the “three line” case, the depth of the \parbox is very large, so \lineskip glue is inserted.

If you instead choose the [b] option (which is available also for the tabular-like environments), the distance between the base lines is the standard.

So it's not the “space below tabu” that changes.

You must log in to answer this question.

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