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.

Is there a way to use tabular or some other method to create a table that expands to use the entire available space? So if I created a table with 4 rows, each row would use 25% of the space. Thanks!

share|improve this question
    
Do you want the table to expand horizontally or vertically as much as possible? (Talking about rows implies vertical growth, which is unusual and makes the question interesting.) –  Christian Lindig Apr 9 '11 at 5:46
    
I was originally interested in having it expand both horizontally and vertically, but I think using tabularx will be a better solution. Still curious about the vertical expansion though. –  Shane Fulmer Apr 9 '11 at 5:59
1  
use tabularht and additional p-columns –  Herbert Apr 9 '11 at 6:43
add comment

2 Answers 2

up vote 3 down vote accepted

Possible with \usepackage{tabularx}

\begin{tabularx}{\textwidth}{ XXXX }
  \hline
  label 1 & label 2 & label 3 & label 4 \\
  \hline
  item 1  & item 2  & item 3  & item 4  \\
  \hline
\end{tabularx}

I modified the code to add space vertically

\documentclass{article}
\usepackage{tabularx}
\begin{document}
  \newcommand\myvspace [2]{  \vrule width0pt height#1 depth#2}
\begin{tabularx}{\textwidth}{ XXXX }
  \hline
\myvspace{1cm}{1cm} label 1 & label 2 & label 3 & label 4 \\
  \hline
 \myvspace{2cm}{2cm}\begin{minipage}{2cm}
 this is a long text and I need some place
 \end{minipage}
 & item 2  & item 3  & item 4  \\
  \hline
\end{tabularx}

\end{document}

enter image description here

share|improve this answer
    
Is there anything that will also space it out vertically? –  Shane Fulmer Apr 9 '11 at 5:45
    
@Shane : what you need exactly ? For just adapting the height of rows, I use cellspace.sty but something like \setlength\extrarowheight{4pt} is possible, if you want to set the height of each rows, you can use the strut method, or \renewcommand\arraystrech{1.5}. For the entire available space horizontally , I forgot the environment tablularc. Finally, If you are an adept of TikZ like me, you can use TikZ for this kind of things. –  Alain Matthes Apr 9 '11 at 6:57
add comment

I'm not sure I understood this correctly:

\vbox to\vsize{\everycr={\noalign{\vskip 2pt plus 1\vsize}}
  \halign to\hsize{&#\hfil\tabskip=1em plus 1\hsize\cr
  Sup? & These & are & going & to & space & out \cr
  Likewise & for & the & rows & which & are \cr
  Going & to & space & out & trying & to \cr
  fill & out & the & page \cr
  }
}
\bye

enter image description here

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.