149

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.

  • 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
157

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.

153

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}
  • 19
    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
  • Note that this overrides the default space setting, so {l@{\hskip 0in}c} means no space between the l and the c column. – einpoklum - reinstate Monica May 23 '18 at 15:30
  • 1
    doesn't play nice with multicolumn for me, not sure what the issue is – fabian789 Apr 5 at 14:02
26

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 How can I specify a particlular tabcolsep for only one column using pgfplotstabletypeset – Nicholas Hamilton 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
24

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}
  • 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
  • 1
    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

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.