9

It's simple to create the tabular with columns of fix width, e.g.

\begin{tabular}{|p{95mm}|p{95mm}|} \hline
a & b \\ \hline
b & b \\ \hline
c & b \\ \hline
\end{tabular} 

However, the width of all table will not be 190mm. (the text width was set to190mm).

By other words, the width of the every column is more than wrote in table preamble.

Did you have to do with this phenomenon?

  • Welcome! I rephrased the title of your question to reflect your actual question better, hope you don’t mind. – doncherry May 30 '13 at 19:31
15

There is \tabcolsep padding on either side of the column entries, plus (if you use array package) the width of the vertical rules (\arrayrulewidth). array implements a different way of dealing with vertical rules inside tabular. The following is taken from array.dtx - a memory-saving strategy:

% \begin{macro}{\@arrayrule}
%    There is only one incompatibility with the original definition:
%    the definition of =\@arrayrule=. In the original a line without
%    width\footnote{So the space between \texttt{cc} and \texttt{c|c}
%    is equal.}  is created by multiple insertions of 
% =\hskip .5\arrayrulewidth=.  
%    We only insert a vertical line into the
%    preamble.  This is done to prevent problems with \TeX's main
%    memory when generating tables with many vertical lines in them
%    (especially in the case of \textsf{floats}).
%    \begin{macrocode}

Without array loaded, use

\begin{tabular}{|p{\dimexpr 95mm-2\tabcolsep}|%
                 p{\dimexpr 95mm-2\tabcolsep}|} \hline
  a & b \\ \hline
  b & b \\ \hline
  c & b \\ \hline
\end{tabular}

With array loaded, you can use

\begin{tabular}{|p{\dimexpr 95mm-2\tabcolsep-1.5\arrayrulewidth}|%
                 p{\dimexpr 95mm-2\tabcolsep-1.5\arrayrulewidth}|} \hline
  a & b \\ \hline
  b & b \\ \hline
  c & b \\ \hline
\end{tabular}

The should remove 2 \tabcolseps from every column (the padding on either side), as well as 1.5 the width of \arrayrulewidth (totaling to 3 across the entire tabular) for each column.

The same structure would hold for tables with more columns, except for the number of \arrayrulewidths that are removed. While each column still has 2 \tabcolseps, you'll remove the fraction rules/columns \arrayrulewidth from each. So, for 8 columns and 9 rules, remove 9/8 or 1.125\arrayrulewidth.

2

This is because some space is added by default to separate the columns from each other (through \tabcolsep). Cf. http://chenfuture.wordpress.com/2007/09/20/latex-tabular-more/

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.