5

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

Please can anybody help?

  • 1
    there is 6pt padding either side of each column (\tabcolsep) and the width of the vertical rules (\arrayrulewidth) – David Carlisle May 12 '15 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? – Lajdák Marek May 12 '15 at 16:38
  • 1
    use tabular and p{\dimexpr3cm-\arrayrulewidth\relax} – David Carlisle May 12 '15 at 16:39
  • Another thx! Last thing - can i now confirm dimension whole table? Something like printlength? – Lajdák Marek May 12 '15 at 16:43
  • 1
    \sbox{0}{.......} \showthe\wd0 will show (as if an error message) the width of whatever you put in ... – David Carlisle May 12 '15 at 16:45
2

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.

enter image description here

|improve this answer|||||
  • Thx for anserwer! it is clean and helps. – Lajdák Marek May 12 '15 at 16:56

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.