In my most recent experiment, the right-most border was, for some reason, placed far away from the rest of the table. What happened?
Code: Select all
\begin{tabular*}{11cm}{|p{4cm}|p{7cm}|} \hline
4cm & 7cm \\ \hline
\end{tabular*}
Code: Select all
\begin{tabular*}{11cm}{|p{4cm}|p{7cm}|} \hline
4cm & 7cm \\ \hline
\end{tabular*}
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
I see.Johannes_B wrote:I am tired, guess you read it in the previous question.
I am not sure, but i think your current setup will give you an overfull box. 7 and 4 add up to 11 perfectly, but the lines have a width as well, and every column gets a bit of white space at both sides. That will make the contents a bit wider than 11 cm.
By the way, do you know package tabularx? There are a few similar ones, but ... tired.
Code: Select all
\documentclass{article}
\usepackage{calc}
\begin{document}
\begin{tabular*}{11cm}{|p{4cm-2\tabcolsep}|p{7cm-2\tabcolsep}|} \hline
4cm & 7cm \\ \hline
\end{tabular*}
\end{document}
Code: Select all
\begin{tabular*}{11cm}{|p{4cm-2\tabcolsep}|p{7cm-2\tabcolsep}|} \hline
tabular*
environment takes an extra argument, the width the tabular should take; in your case 11cm. A relative width might be better tough, for example .8\linewidth
.\the
, in our example it would be \the\tabcolsep
.Code: Select all
\documentclass{article}
\usepackage{calc}
\usepackage{blindtext}
\begin{document}
\the\tabcolsep
\begin{tabular*}{11cm}{|p{4cm-2\tabcolsep}|p{7cm-2\tabcolsep}|} \hline
4cm minus 6 pt on each side & 7cm minus 12 pt \blindtext \\ \hline
\end{tabular*}
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{11cm}{|p{4cm-2\tabcolsep}|p{7cm-2\tabcolsep}|} \hline
4cm of printable text \blindtext & 7cm \blindtext \\ \hline
\end{tabular*}
\end{document}
tabular*
environment here at all.\tabcolsep
per column exceeds the specified width, the tabular's body will stick out to the right or each \hline
will be too short;\tabcolsep
per column is shorter than the specified width, each \hline
will be too long.@{\extracolsep{\fill}}
within the column specification, and have some space to fill (that is, the sum of all column widths plus two \tabcolsep
per column is indeed shorter than the specified width), the usage of tabular*
does not bring any advantage compared to {tabular}
; even then it looks a bit awkward with vertical rules inside.Code: Select all
\begin{tabular}{<column specification>}
<table body>
\end{tabular}
rais wrote:Strange, what happened to [env]tabular*[/env]? Does it not work with starred variants?
env
and cmd
tags link to our own reference manual. There is a dedicated entry for tabular
in which the starred variant is mentioned as well. Thank you, I see.Johannes_B wrote:rais wrote:Strange, what happened to [env]tabular*[/env]? Does it not work with starred variants?
Theenv
andcmd
tags link to our own reference manual. There is a dedicated entry fortabular
in which the starred variant is mentioned as well.
{...}
---but I'm getting off topic (happens sometimes when I don't heed your excellent advice about calming down, breathing... Full ACK.Johannes_B wrote: Package tabularx might be better here. But since the question arose what the starred variant is/does, usual tabular might be best. But the discussion was very theoretical and it is hard to suggest anything more suited.
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p