# Tweaking table size with column separation

I have a large table which is very slightly wider (around 1cm) than my text width and I want to squash it up slightly so that it fits. Rotating it or resizing the text was undesirable in this context. So far I have managed to get the following to produce the desired behaviour:

\begin{table}[t]
\setlength{\tabcolsep}{4pt}
\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} c c c c c c c}
% content
\end{tabular*}
\end{table}


A brief explanation: line 2 slightly reduces the space between all the columns to get my table slightly less than the text width; the {\textwidth} of line 3 expands the table to be exactly the width of the text; then the @{\extracolsep{\fill}} adds in a tiny extra space to shift the columns over slightly so they correctly line up with the right edge of the table.

Firstly, does line 2 enclosed in the table environment change the column separation for just this table, or will it affect other tables in my document? I only want this table to be affected.

Second, is there a better way to go about this? Ideally I'd have something which automatically expanded or contracted the column separations/widths to achieve a specified table width.

• Answer to the first question is Yes, ie \setlength{\tabcolsep}{4pt} enclosed in the table environment change the column separation for just this table. – Sunilkumar KS Nov 26 '15 at 6:54
• Does that help? – vaettchen Nov 26 '15 at 7:33
• @vaettchen Not quite. The code \resizebox{\textwidth}{!}{object} resizes the object, including the text. For small tweaks I could probably get away with it, depending on how picky I was being about the text size. Ideally I'd like this to be unchanged though. – Ulysses Nov 26 '15 at 8:12

\begin{table}[t]
\setlength{\tabcolsep}{4pt}
\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} c c c c c c c}
% content
\end{tabular*}
\end{table}


\setlength is a local setting so it is scoped by the surrounding table environment so only affects this one table. Note however that @ removes the tabcolsep where it is used, so if the table is tight there is no separation at all between columns one and two. You could use the ! type from the array package which is similar to@ but does not remove the default space, or the normal idiom is

 \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}l c c c c c c c@{}}


So that the column padding is moved from both outer edges not between columns of the table.