203

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.

7
  • 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 8:23
  • 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 2 '15 at 19:22
207

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.

2
  • 1
    In my case \tabcolsep is by default 2pt but this may be the \documentclass{revtex}.
    – Qbyte
    Oct 21 '20 at 19:30
  • +1 so it's 200 :) Aug 23 at 1:47
196

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}
4
  • 22
    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 5 '13 at 13:13
  • doesn't play well with \rowcolor...
    – PatrickT
    May 5 '18 at 9:52
  • 3
    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
  • 1
    doesn't play nice with multicolumn for me, not sure what the issue is
    – fabian789
    Apr 5 '19 at 14:02
44

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}
4
  • In my opinion, this seems better-suited as a comment.
    – Werner
    May 24 '15 at 12:14
  • 7
    this was pretty helpful for me just now actually, nice one
    – baxx
    Oct 17 '15 at 15:34
  • 2
    This is a better answer...
    – PatrickT
    May 5 '18 at 9:48
  • 5
    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
34

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.

2
  • @stefan How can I specify a particlular tabcolsep for only one column using pgfplotstabletypeset Aug 26 '13 at 0:54
  • @ADP It seems like this could be posted as a new question, since this question is not about one column only and not related to pgfplots.
    – Stefan Kottwitz
    Aug 26 '13 at 7:09
1

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

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.