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 can use p{}, m{} or r{} but I shall pass a fixed size. Is there a way to do it with rubber columns?

share|improve this question
1  
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
add comment

2 Answers

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.

share|improve this answer
    
Great Package. And woefully nonfamous too! –  Stephan Lehmke Jun 14 '12 at 16:14
add comment

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