I'm kind of stuck in the middle of nowhere because I want to make this table (48 columns I know it's huge... but I need this) fit in a4paper but it seems there is a cell's table minimum width, isn't it ? For instance, there is no difference between 1pt and 0.001pt.

Thanks for helping.

\documentclass[a4paper,12pt]{article}

\usepackage{array}

\begin{document}

\begin{table}[htp]
\begin{center}
    \begin{tabular*}{\textwidth}{| *{48}{>{\centering\arraybackslash}m{0.1pt}|}}
        \hline
         & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\
        \hline
    \end{tabular*}
\end{center}    
\end{table}

\end{document}
  • 3
    You have a \tabcolsep of 6pt and and the rules have a width of 0.4pt. This already fills up the textwidth. – Ulrike Fischer Sep 12 at 7:58
  • Thank you so much ! Saves me a lot of time ;) – rhum187 Sep 12 at 8:01
up vote 3 down vote accepted

The is a minimum distance between columns which is called tabcolsep. You can set this to zero --- and then manage the thing manually:

\setlength{\tabcolsep}{0pt}

Look:

\documentclass[a4paper,12pt]{article}
\usepackage{array}
\begin{document}
\begin{table}[htp]
\begin{center}
    \setlength{\tabcolsep}{0pt}
    \begin{tabular*}{\textwidth}{| *{48}{>{\centering\arraybackslash}m{5pt}|}}
        \hline
         & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & & \\
        \hline
    \end{tabular*}
\end{center}    
\end{table}
\end{document}

enter image description here

You have to consider the vertical line width (I think it's 0.4pt by default), and in this case you'll need some stretch to "fill the space" (it's underfull now), like:

 \setlength{\tabcolsep}{0pt}
    \begin{tabular*}{\textwidth}{| *{48}{%
            @{\extracolsep{\fill}}%
            >{\centering\arraybackslash} m{7pt}|%
            @{\extracolsep{\fill}}}%
        }
        \hline
         .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .& .\\
        \hline
    \end{tabular*}

enter image description here

For more complex distribution of space, maybe tabularx is a better option.

You can make the content width of p (or m or b) columns as small as you wish (0pt for example) however columns by default have \tabcolsep space either side and that defaults to 6pt so you may want \setlength\tabcolsep{0pt} here.

Also note you should use

\begin{tabular}

not

\begin{tabular*}{\textwidth}

If you do use tabular* then you need to use @{\extracolsep{\fill}} to allow additional space between columns so tex can achieve the stated width.

  • Works like a charm ! Thanks a lot David. – rhum187 Sep 12 at 8:03

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.