27

I have a table as shown below.

\documentclass{article}
\usepackage{graphicx}
\newcommand*\rot{\rotatebox{90}}

\begin{document}

\begin{table}[!ht]
  \centering
    \begin{tabular}{| c | c | c |}
        \hline
        1 & 2  &  3\\ \hline
        \rot{\textbf{1st column}} & \rot{\textbf{2nd column}} & \rot{\textbf{3rd column}} \\ \hline
    \end{tabular}
\end{table}

\end{document}

I would like the width of columns by reducing the padding. I have tried

\begin{tabular}{| p{0.1cm} | c | c |}

However, it only removes the white space in the right-hand side of the first column and leave the white space intact in the left-hand side of it.

  • 3
    \setlength\tabcolsep{x pt}. The default value is 6 pt (which makes a total of 12pt between two consecutive cells). – Bernard Sep 14 '14 at 11:12
41

To change the amount of vertical whitespace that LaTeX inserts to the left and right of every column, change the length parameter \tabcolsep. Its default value is 6pt; change it via either \setlength or \addtolength. In the example below, the second table features a value of 1.5pt for \tabcolsep.

enter image description here

\documentclass{article}
\usepackage{graphicx}
\newcommand*\rot[1]{\rotatebox{90}{#1}}
\begin{document}
\begin{table}[!ht]
  \centering
    \begin{tabular}{| c | c | c |}
        \hline
        1 & 2  &  3\\ \hline
        \rot{\textbf{1st column}} & \rot{\textbf{2nd column\ }} & \rot{\textbf{3rd column}} \\ \hline
    \end{tabular}
\qquad  % get some separation between the two tabulars
\setlength\tabcolsep{1.5pt} % default value: 6pt
    \begin{tabular}{| c | c | c |}
        \hline
        1 & 2  &  3\\ \hline
        \rot{\textbf{1st column}} & \rot{\textbf{2nd column\ }} & \rot{\textbf{3rd column}} \\ \hline
    \end{tabular}
\end{table}
\end{document}
  • How can I adjust the separation of just some columns? – Veridian Apr 13 '16 at 23:44
  • @Veridian - Insert @{\hspace{<desired separation>} in the desired location. E.g., write \begin{tabular}{c@{\hspace{3em}c} instead of just \begin{tabular}{cc}. – Mico Apr 14 '16 at 5:14
  • 2
    I think @MIco has a typo in that comment: It should be \begin{tabular}{c@{\hspace{3em}}c}, with one addition }. – Karalga Dec 14 '17 at 11:05
10

Is this what you looking for?

\documentclass{article}
\usepackage{graphicx}
\newcommand*\rot{\rotatebox{90}}

\begin{document}
    \begin{table}[!ht]
      \centering
        \begin{tabular}{|@{\hskip3pt}c@{\hskip3pt}| c |@{\hskip3pt}c@{\hskip3pt}|}
            \hline
            1 & 2  &  3\\ \hline
            \rot{\textbf{1st column}} & \rot{\textbf{2nd column}} & \rot{\textbf{3rd column}} \\ \hline
        \end{tabular}
    \end{table}
\end{document}

The @{} in place of insertion set \tabcolsep distance to zero. If you like to have in this place different space between adjacent columns, than you can locally determine it with @{<distance>} where you select <width> according to your wish.

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.