# How to globally adjust horizontal spacing in table? @{length}

I want to adjust the horizontal spacing between vertical lines and the cell content in a tabular table.

I could do it for each column with @{length}l@{length} (e. g. with \,), but there must be a more elegant way to do it globally for the whole table on the left and right side of each cell.

Example:

\documentclass[11pt, a4paper]{scrartcl}
\usepackage[margin=2.5cm]{geometry}
\usepackage{tabularx}
\begin{document}

\begin{tabular}{|p{2cm}*{4}{|@{\,}p{1.5cm}@{\,}}|@{}l@{}|}
\hline
1 & 2 & 3 & 4 & 5 & 6\\
\hline
word & word & more words & more and more words & longtext longtext longtext & verylongword \\
\hline
\end{tabular}
\end{document}

-

You just need to adjust the parameter \tabcolsep

\setlength{\tabcolsep}{.16667em}
\begin{tabular}{|p{2cm}*{4}{|p{1.5cm}}|l@{}|}
\hline
1 & 2 & 3 & 4 & 5 & 6\\
\hline
word & word & more words & more and more words & longtext longtext longtext & verylongword \\
\hline
\end{tabular}


You can use a group in order to keep the change local.

-

define a new columntype:

\newcolumntype{P}[1]{|@{\,}p{#1}@{\,}}

\begin{document}
\begin{tabular}{|p{2cm}*{4}{P{1.5cm}}|@{}l@{}|}

-
thank you, this is also an interesting approach. However tabcolsep is what was searching for, as it affects all columns. I'm sorry, maybe my MWE was misleading, as I used it to try several different settings to compare, but I definitely want the same horizontal spacing for all columns. –  Martin Sep 23 '11 at 9:41
I tried your new column type, but I get an error message "illegal parameter number in definition of" table. Might there be a typo in the newcolumntype, or a I doing something wrong? –  Martin Sep 23 '11 at 10:24
did you used it with package tabularx, it needs package array which is loaded by tabularx. However, I have no problem, using it with your example –  Herbert Sep 23 '11 at 10:30
yes, it works with my example. In my main document, there seems to be a problem. I'll see if I can find out what's wrong. –  Martin Sep 23 '11 at 11:39