# Tabular size \textwidth and exacly columns dimensions in cm?

I need make table which have /textwidth width and its columns have exactly dimensions in centimeters.

Specifically - table width: 24cm and columns (in cm): 4,2 ; 7,6 ; 6,4 ; 3,5 ; 2,3

My document starts:

\documentclass{article}
\usepackage{geometry}

\geometry{paper=a4paper, landscape, hmargin=28.5mm, vmargin=20mm}


What it means 297mm x 210mm. (but printlength is 23.99658cm x 16.99757cm wt*?)

Is that possible? I was trying create basic tabular (8x3=24):

\begin{tabular}{ @{} | p{3cm} | p{3cm} | p{3cm} | p{3cm} | p{3cm} | p{3cm} | p{3cm} | p{3cm} | @{}}
\hline
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ \hline
\end{tabular}


But table is horizontal overflowing up to right end of document...

Also i was trying (8x3=24):

\newcolumntype{L}{>{\hsize=3cm}X}
\begin{tabularx}{\textwidth}{ |L|L|L|L|L|L|L|L| }
...


And overflow was more than doncument range...

• there is 6pt padding either side of each column (\tabcolsep) and the width of the vertical rules (\arrayrulewidth) May 12, 2015 at 16:24
• Thx! \setlength{\tabcolsep}{0cm} helps but how i can calculate with \arrayrulewidth ? I want default value so is there posibility set column width somelike this: p{3cm-0.4 pt} ? (Is 0.4 pt default value?) And what are your recommendations for this case tabular or tabularx? May 12, 2015 at 16:38
• use tabular and p{\dimexpr3cm-\arrayrulewidth\relax} May 12, 2015 at 16:39
• Another thx! Last thing - can i now confirm dimension whole table? Something like printlength? May 12, 2015 at 16:43
• \sbox{0}{.......} \showthe\wd0 will show (as if an error message) the width of whatever you put in ... May 12, 2015 at 16:45

You have to take into account the column separations and the width of the rules.

With the following code, the width are as specified if measured from the middle of the rules.

\documentclass{article}
\usepackage{geometry}

\geometry{paper=a4paper, landscape, textwidth=24cm, vmargin=20mm}

\begin{document}

\noindent
\begin{tabular}{
@{\kern-.5\arrayrulewidth}
|p{\dimexpr4.2cm-2\tabcolsep-.5\arrayrulewidth}
|p{\dimexpr7.6cm-2\tabcolsep-.5\arrayrulewidth}
|p{\dimexpr6.4cm-2\tabcolsep-.5\arrayrulewidth}
|p{\dimexpr3.5cm-2\tabcolsep-.5\arrayrulewidth}
|p{\dimexpr2.3cm-2\tabcolsep-.5\arrayrulewidth}
|@{\kern-.5\arrayrulewidth}
}
\hline
aaa bbb ccc ddd eee &
aaa bbb ccc ddd eee &
aaa bbb ccc ddd eee &
aaa bbb ccc ddd eee &
aaa bbb ccc ddd eee \\
\hline
aaa bbb ccc ddd eee &
aaa bbb ccc ddd eee &
aaa bbb ccc ddd eee &
aaa bbb ccc ddd eee &
aaa bbb ccc ddd eee \\
\hline
\end{tabular}

\end{document}


If you want a text width of 24cm, it's better to specify it directly.

• Thx for anserwer! it is clean and helps. May 12, 2015 at 16:56