2

I've tried searching the answer here, but I did not find it. I have a plenty of 25x25 table with long entries. The table should fit in an A4 sheet of paper. I tried using "landscape". It helped a bit, but there are some tables which still don't fit.

Can anyone tell me how can I change cellspacing of the table, that is the distance between borders of its elements?

2
  • 1
    \setlength\tabcolsep{2in} – David Carlisle Jun 5 '14 at 9:51
  • 1
    and for vertical spacing, \renewcommand\arraystretch{2} – Steven B. Segletes Jun 5 '14 at 10:10
5

I used the vertical lines on purpose here, to show their effect on spacing.

Following example shows the influence of \tabcolsep as spacing between borders,the black color box demonstrates the typing area compared to the spacing to the left and right.

Normally, \tabcolsep defaults to 6pt.

If vertical lines are also included, there is an additional \arrayrulewidth, defaulting to 0.4pt, changing this affects the thickness of the horizontal rules created by \hline.

This all holds for standard tabular environment, without adding extra table packages.

\documentclass[paper=a4,12pt]{scrbook}
\usepackage{xcolor}



\begin{document}


\begin{table}
\begin{tabular}{|l|*{24}{l|}}
\hline
\colorbox{black}{\parbox{1cm}{\hspace{1cm}}} & & & & & & & & & & & & & & & & & & & & & & & & \tabularnewline
\hline
\colorbox{black}{\parbox{1cm}{\hspace{1cm}}} & & & & & & & & & & & & & & & & & & & & & & & & \tabularnewline
\hline
\end{tabular}
\caption{Normal tabcolsep length: \the\tabcolsep, normal vertical spacing of \arraystretch}
\end{table}


\begin{table}
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|l|*{24}{l|}}
\hline
\colorbox{black}{\parbox{1cm}{\hspace{1cm}}} & & & & & & & & & & & & & & & & & & & & & &  \tabularnewline
\hline
\end{tabular}
\caption{Changed tabcolsep length: \the\tabcolsep} 
\end{table}

\begin{table}
\setlength{\tabcolsep}{0.0pt}
\begin{tabular}{|l|*{24}{l|}}
\hline
\colorbox{black}{\parbox{1cm}{\hspace{1cm}}} & & & & & & & & & & & & & & & & & & & & & &  \tabularnewline
\hline
\end{tabular}
\caption{Changed tabcolsep length: \the\tabcolsep}
\end{table}


\begin{table}
\setlength{\arrayrulewidth}{2pt}%
\begin{tabular}{|l|*{24}{l|}}
\hline
\colorbox{black}{\parbox{1cm}{\hspace{1cm}}} & & & & & & & & & & & & & & & & & & & & & &  \tabularnewline
\hline
\end{tabular}
\caption{Normal tabcolsep length: \the\tabcolsep, changed arrayrulewidth to \the\arrayrulewidth}
\end{table}


\begin{table}
\renewcommand{\arraystretch}{0.8}
\begin{tabular}{|l|*{24}{l|}}
\hline
\colorbox{black}{\parbox{1cm}{\hspace{1cm}}} & & & & & & & & & & & & & & & & & & & & & & & & \tabularnewline
\hline
\colorbox{black}{\parbox{1cm}{\hspace{1cm}}} & & & & & & & & & & & & & & & & & & & & & & & & \tabularnewline
\hline
\end{tabular}
\caption{Normal tabcolsep length: \the\tabcolsep, reduced verticalspacing to \arraystretch}
\end{table}

\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.