Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have used \begin{tabularx} or \begin{tabular*} but neither of these two work, these two environment managed to increase the width of the table as the same as the text, while they cannot let the column contents inside the table increased associated with the table width.

share|improve this question
1  
You query is somehow confusing: the title asks for tables with a given width, but the description of the problem mentions column width. Can you please describe clearly and in more detail your intent? –  Gonzalo Medina Jun 8 '11 at 1:36
add comment

2 Answers

The tabular* environment is able only to act on the intercolumn space, while tabularx can decide the width of the columns via the column specifier X. If one uses the latter environment without X columns, no automatic enlargement will happen.

Suppose you have three columns, with the first listing the items, the second with descriptions and the third with comments; we want that the latter two enlarge proportionally to the desired table width

\usepackage{tabularx,booktabs}
...

\begin{tabularx}{\textwidth}{l X X}
\toprule
Item & Description & Comments \\
\midrule
Item 1 & 
  this is the description of item 1 &
  these are the comments on item 1 \\
Item 2 & 
  this is the description of item 2 &
  these are the comments on item 2 \\
...
\bottomrule
\end{tabularx}

(I've used the rules provided by the booktabs package). Put the environment inside a table environment with \centering and you're done. It's also possible to have X columns of different width, a method is explained in the manual of tabularx. There's also the tabu package, that should be able to manage this kind of tables.

share|improve this answer
add comment

I assume you mean the \tabskip-glue (example in plain-format):

\halign{\tabskip1em plus .2\hsize#\hfil&#\hfil&\tabskip0pt #\hfil\cr
  A testing&table&with\cr Some&content&booyah\cr}
\smallskip\hrule\smallskip
\halign to \hsize{\tabskip1em plus .2\hsize#\hfil&#\hfil&\tabskip0pt #\hfil\cr
  A testing&table&with\cr Some&content&booyah\cr}
\smallskip\hrule\smallskip
\halign to .5\hsize{\tabskip1em plus .2\hsize#\hfil&#\hfil&\tabskip0pt #\hfil\cr
  A testing&table&with\cr Some&content&booyah\cr}
\bye

tabskipglue

As you see, the only thing changing is the width of the \halign. The tabskip glues positive stretchability makes it possible for the columns to spread out to accommodate the available space.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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