229

I notice that the space between each column of a table in LaTeX is not quite wide (at least for me). Is there any way to set this? I found the \hspace, but I don't get how to use this in the table.

zfm
  • 8,987
  • 9
  • 30
  • 21
  • 1
    @Stefan: exactly the same as yours, sorry for not posting it :) Well I found something bit more general. If we want that this \tabcolsep changed everywhere, we can do \renewcommand{\tabcolsep}{0.15cm} – zfm Apr 24 '11 at 22:40
  • 7
    @zfm: No, \renewcommand{\tabcolsep}{...} is definitely wrong; the correct way is with \setlength. – egreg Apr 24 '11 at 22:55
  • @egreg: that's wrong? why? when I try it, I see that the space between column is added – zfm Apr 25 '11 at 08:23
  • @zfm: just because it works in one instance, it doesn't mean it will work forever. Trust me and change the value of \tabcolsep with \setlength. – egreg Apr 25 '11 at 09:38
  • @egreg: you meant, change \renewcommand with, \setlength, right? so in the beginning of the command, I should write \setlength{\tabcolsep}{...}, is that ok? – zfm Apr 25 '11 at 10:18
  • 1
    @zfm: Yes. \tabcolsep is not a command like \section: it's a parameter which has a value and changing its meaning with \renewcommand might break a package trying to set its value with the correct method. – egreg Apr 25 '11 at 10:52
  • 1
    Duplicate (more comprehensive): Column and row padding in tables – Werner Feb 02 '15 at 19:22

5 Answers5

235

The parameter to act on is \tabcolsep, whose value is usually 6pt. So

\setlength{\tabcolsep}{12pt}

will double the intercolumn space. The parameter stores half the space between columns: in LaTeX each column is preceded and followed by a horizontal space \tabcolsep wide.

egreg
  • 1,121,712
220

You can add space by inserting @{\hskip whatever} between the column specifiers, as in

\begin{tabular}{l@{\hskip 1in}c@{\hskip 0.5in}c}
  One&Two& Three\\
  Four& Five& Six
\end{tabular}

Actually, you can add whatever you like between the columns in place of the usual intercolumn space, e.g.,

\begin{tabular}{l@{ or }c@{\hskip 0.5in}c}
  One&Two& Three\\
  Four& Five& Six
\end{tabular}
David Carlisle
  • 757,742
  • 26
    Really interesting, thanks. For anyone else, if discovered: \hskip defines the horizontal space, it is not additional to any other measure. E.g. @{\hskip -0.1cm} produces a bad output (just test it). – henry Aug 05 '13 at 13:13
  • 1
    doesn't play well with \rowcolor... – PatrickT May 05 '18 at 09:52
  • 5
    Note that this overrides the default space setting, so {l@{\hskip 0in}c} means no space between the l and the c column. – einpoklum May 23 '18 at 15:30
  • 4
    doesn't play nice with multicolumn for me, not sure what the issue is – fabian789 Apr 05 '19 at 14:02
  • Re: multicolumns: It seems like the multicolumn span includes the space, rather than having the space be outside the column. So it might look right if the multicolumn is left-aligned, but if center- or right-aligned then it won't be correctly aligned with the non-multi-columns. Would be nice to have a solution for this because I'm not sure of another way to control spacing between each column separately. – Neil Traft Mar 06 '23 at 15:35
58

If you need to adjust the spacing for just one table you could also add/remove some space before the table and restore previous value after it:

\addtolength{\tabcolsep}{-1pt}    
\begin{tabular}{cc}    
text & text    
\end{tabular}    
\addtolength{\tabcolsep}{1pt}
Torbjørn T.
  • 206,688
Pietro C
  • 1,424
  • In my opinion, this seems better-suited as a comment. – Werner May 24 '15 at 12:14
  • 8
    this was pretty helpful for me just now actually, nice one – baxx Oct 17 '15 at 15:34
  • 8
    If you need to adjust the spacing for just one table you could put your code into curly braces and the change will affect just the table that is inside { \setlength{\tabcolsep}{12pt} \begin{tabular}{cc} ..... } – Pietro C May 17 '18 at 11:59
38

You can adjust the length \tabcolsep, for example:

\documentclass{article}
\begin{document}  
\centering
\begin{tabular}{cc}
text & text
\end{tabular}
\setlength{\tabcolsep}{3em}

\begin{tabular}{cc}
text & text
\end{tabular}
\end{document}

\tabcolsep is the space which is inserted before and after a column. Note, this means that the space between two columns is 2\tabcolsep.

Stefan Kottwitz
  • 231,401
6

If you need a more natural and flexible way to adjust space between rows or columns in tables, you may try tabularray package. You can use colsep (also leftsep and rightsep) and rowsep (also abovesep and belowsep) options with tblr environment.

\documentclass{article}

\usepackage{tabularray}

\begin{document}

\begin{tblr}{ hlines, vlines, rows = {rowsep=8pt}, columns = {colsep=8pt}, } Alpha & Beta & Gamma & Delta \ Epsilon & Zeta & Eta & Theta \ Iota & Kappa & Lambda & Mu \ \end{tblr}

\bigskip

\begin{tblr}{ hlines, vlines, row{1} = {abovesep=1pt,belowsep=10pt}, column{2} = {leftsep=1pt,rightsep=10pt}, } Alpha & Beta & Gamma & Delta \ Epsilon & Zeta & Eta & Theta \ Iota & Kappa & Lambda & Mu \ \end{tblr}

\end{document}

enter image description here

L.J.R.
  • 10,932