3

When using embedded tabu environments I have difficulties having different vertical space in the outer and inner tables. Consider these simple embedded tabu tables:

\documentclass[a4paper]{article}
\usepackage{tabu}

\begin{document}
  \begin{tabu}{|c|}
    \hline
    \begin{tabu}{l|c|r}
      left & {\LARGE \textbf{MIDDLE}} & right
    \end{tabu} \\
    \hline
    \begin{tabu}{l|c|r}
      left & {\LARGE \textbf{MIDDLE}} & right
    \end{tabu} \\
    \hline
  \end{tabu}
\end{document}

The table renders like this:

Large text too close to hline

As you can see, the large text is too close to the upper \hline. To fix this I try to use the \tabulinesep command before the first/outer table:

(I use a large 5pt spacing to make it obvious what happens.)

\documentclass[a4paper]{article}
\usepackage{tabu}

\begin{document}
  \tabulinesep=^5pt % <==== At least 5pt above text.
  \begin{tabu}{|c|}
    \hline
    \begin{tabu}{l|c|r}
      left & {\LARGE \textbf{MIDDLE}} & right
    \end{tabu} \\
    \hline
    \begin{tabu}{l|c|r}
      left & {\LARGE \textbf{MIDDLE}} & right
    \end{tabu} \\
    \hline
  \end{tabu}
\end{document}

However, it leaves gaps above the vertical rules (lines) as the \tabulinesep also applies to the outer table:

Gaps above vertical rules

To fix it, I can use a \tabulinesep command right above the two innner tables where it should apply like this:

\documentclass[a4paper]{article}
\usepackage{tabu}

\begin{document}
  \begin{tabu}{|c|}
    \hline
    \tabulinesep=^5pt % <==== At least 5pt above text in inner table.
    \begin{tabu}{l|c|r}
      left & {\LARGE \textbf{MIDDLE}} & right
    \end{tabu} \\
    \hline
    \tabulinesep=^5pt % <==== At least 5pt above text in inner table.
    \begin{tabu}{l|c|r}
      left & {\LARGE \textbf{MIDDLE}} & right
    \end{tabu} \\
    \hline
  \end{tabu}
\end{document}

Which renders the correct result:

Correct spacing in innner tables

However, I do not want to repeat myself for each inner table. So what I really want is to set a global default, and then make an exception for the outer table. My guess would be this but it does not work:

\documentclass[a4paper]{article}
\usepackage{tabu}

\global\tabulinesep=^5pt % <=== Global setting

\begin{document}
  \tabulinesep=^0pt % <==== Cannot override for outer table only... :-(
  \begin{tabu}{|c|}
    \hline
    \begin{tabu}{l|c|r}
      left & {\LARGE \textbf{MIDDLE}} & right
    \end{tabu} \\
    \hline
    \begin{tabu}{l|c|r}
      left & {\LARGE \textbf{MIDDLE}} & right
    \end{tabu} \\
    \hline
  \end{tabu}
\end{document}

The result is the first image (where I started out).

Any suggestions for setting a global \tabusep and then override it for the outer table?

2

You can insert a strut, just for its height part in case only uppercase is used. I show both examples.

\documentclass[a4paper]{article}
\usepackage{amsmath} % for a better \smash
\usepackage{tabu}

\begin{document}
  \begin{tabu}{|c|}
    \hline
    \begin{tabu}{l|c|r}
      left & \LARGE\smash[b]{\strut}\textbf{MIDDLE} & right
    \end{tabu} \\
    \hline
    \begin{tabu}{l|c|r}
      left & \LARGE\strut\textbf{MIDDLEg} & right
    \end{tabu} \\
    \hline
  \end{tabu}
\end{document}

enter image description here

  • Elegant solution (I did not know of neither \smash nor the amsmath version of \smash) even though it does not really answer my question (maybe because what I ask is not possible?) – mgd Oct 18 '14 at 14:00
  • Ok, I ended up using your solution since it also gives nice font size dependent spacing from the top rule. However, I ran into another problem which I will post as a separate question. – mgd Oct 18 '14 at 17:02
  • I posted the additional question here: tex.stackexchange.com/q/207850/16761 – mgd Oct 18 '14 at 19:15

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.