# Wrap text in tables in rubber columns

I can use p{}, m{} or r{} but I shall pass a fixed size. Is there a way to do it with rubber columns?

-
when you say 'rubber columns', do you mean columns with variable width? If so, have you seen the tabularx package? – cmhughes Jun 14 '12 at 3:21
@cmhughes thanks – efpies Jun 14 '12 at 3:34

The answer is to use tabularx package.

% preamble
\usepackage{tabularx}

\begin{document}
\begin{table}
\begin{center}
\begin{tabularx}
{\textwidth} % table width
{| l | X |} % X is for rubber column

\end{tabularx}
\end{document}

-

An alternative to tabularx which sometimes works better (and sometimes doesn't) is to use tabulary

\documentclass{article}
\usepackage{tabularx,tabulary}
\def\a{ one two three four five six seven eight nine}
\def\b{\a. \a. }
\begin{document}

\noindent X\dotfill X

\noindent\begin{tabularx}
{\textwidth} % table width
{| l | X | X|} % X is for rubber column
abc&1 1 1 \b\b&2\b\\
def ge&22\b \b\b&red green blue
\end{tabularx}

\noindent X\dotfill X

\bigskip

\noindent X\dotfill X

\noindent\begin{tabulary}
{\textwidth} % table width
{| l | L | L|} % X is for rubber column
abc&1 1 1 \b\b&2\b\\
def ge&22\b \b\b&red green blue
\end{tabulary}

\noindent X\dotfill X

\end{document}


TX and TY distribute the width between the columns in different ways. TY takes account of the content of the cells and tries to make columns with more content wider than those with less content. TX does not look at the content of the X columns.

-
 Great Package. And woefully nonfamous too! – Stephan Lehmke Jun 14 '12 at 16:14