3

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

1
  • 1
    when you say 'rubber columns', do you mean columns with variable width? If so, have you seen the tabularx package?
    – cmhughes
    Jun 14, 2012 at 3:21

2 Answers 2

3

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

enter image description here

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

0
1

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

            % your rows
            \end{tabularx}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .