# Unwanted padding in tabular columns when cells contain multiple rows

Whenever I need to create a cell with multiple rows in a tabular environment, I usually create enclose the contents of the cell within a tabular environment within the cell. This has been a great fix for me since it is easy to implement and also since it takes care of vertical alignment across rows.

Unfortunately, it looks like this fix also adds additional padding to the column. I have included an example below to illustrate the issue. Here, the bottom table has a row with "2 row" cells.

In my opinion, both the top table and the bottom table should have equal column widths (determined by the length of "TITLE"), but this is not the case. I suspect the reason why is because the tabular environment adds padding to the column widths.

\documentclass[letter]{article}
\usepackage{array}
\usepackage{booktabs}
\usepackage{tabularx}

\begin{document}

%normal table
\begin{table}[ht]
\begin{tabular}{cc}
\toprule
TITLE  & TITLE \\
\midrule
10 & 10  \\
10 & 10  \\
\bottomrule
\end{tabular}
\end{table}

%when I use the tabular trick
\begin{table}[ht]
\begin{tabular}{cc}
\toprule
\begin{tabular}{c}TITLE\\A\end{tabular} & \begin{tabular}{c}TITLE\\B\end{tabular} \\
\midrule
10 & 10  \\
10 & 10  \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

• You are adding extra \tabcolsep lengths to the width of your table, since each column is surrounded by a pair of space (being \tabcolsep wide). Before manipulating the lengths now, just try @{}c@{} for each of the subtables you put into the outer table – user31729 Aug 11 '14 at 21:06

In the standard column specifier usage of c (or l or r), there is a space of \tabcolsep (defaulting to 6.0pt) to the left as well as to the right. This means, that

cc


has in fact following spacing

\tabcolsep cell_content \tabcolsep\tabcolsep cell_content \tabcolsep

Usage of @{}c@{} drops this spacing before and after. It is better than to manipulate \tabcolsep by setting it to 0pt.

If there are vertical lines for the column specifier, each line adds additional \arrayrulewidth (defaults to 0.4pt) space to the width of the table.

In the code below, I have written four tables, two original from the OP, and one with bad manipulation of \tabcolsep as well as one with @{}c@{} approach. I added the vertical lines of the outer and inner table just for demonstration and do not recommend them for production run!

It is seen from the output, that the 1st, 3rd and 4th method are identical, apart from vertical spacings, but the 2nd. method deviates.

\documentclass[letter]{article}
\usepackage{array}
\usepackage{booktabs}
\usepackage{tabularx}

\begin{document}

\begin{tabular}{|l|}%
One table method \tabularnewline
\begin{tabular}{|c|c|}
\toprule
TITLE  & TITLE \\
\midrule
10 & 10  \\
10 & 10  \\
\bottomrule
\end{tabular} \tabularnewline
%when I use the tabular trick

Two table method \tabularnewline

\begin{tabular}{|c|c|}
\toprule
\begin{tabular}{c}TITLE\\A\end{tabular} & \begin{tabular}{c}TITLE\\B\end{tabular} \\
\midrule
10 & 10  \\
10 & 10  \\
\bottomrule
\end{tabular} \tabularnewline

% Now with 'bad' manipulation of \tabcolsep length

\begin{tabular}{|c|c|}
\toprule
\setlength{\tabcolsep}{0pt}%
\begin{tabular}{c}
TITLE\\
A
\end{tabular} &
\setlength{\tabcolsep}{0pt}%
\begin{tabular}{c}
TITLE \\
B
\end{tabular} \\
\midrule
10 & 10  \\
10 & 10  \\
\bottomrule
\end{tabular} \tabularnewline

\makeatletter
Usage of @{} - method \tabularnewline
\makeatother

\begin{tabular}{|c|c|}
\toprule
\begin{tabular}{@{}c@{}}TITLE\\A\end{tabular} & \begin{tabular}{@{}c@{}}TITLE\\B\end{tabular} \\
\midrule
10 & 10  \\
10 & 10  \\
\bottomrule
\end{tabular}
\end{tabular}

\end{document}