[Tex/LaTex] Reduce cell margins in a table

tables

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.

Best Answer

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}
Related Question