[comp.text.tex] How wide are the columns?

blu@millipore.com (Brian Utterback) (10/23/90)

Okay, all you LaTeX gurus, I have what I hope is a simple question.  I need
to produce a series of small tables such that each table has one line of 
column headings and then several rows.  Each row has two columns.  Like this

    ---------------
    head1  |head2
    ---------------
    data11 |data12
    data21 |data22
    ---------------

Real simple, huh?  The only thing is that the data in this case is an english 
sentence which will often be long enough to case a very overfull hbox.  I could
specify the p parameter to the tabular to give the widths, but what I really 
want is a maximum width. And what's more, the tables appear in a enumerate 
environment, so I would like the maximum width to scale with the available
width.  That is to say, the maximum width of the table should be smaller the
greater the depth.  The two columns probably should be equal widths, but I 
am not a degigner and I may be wrong.




-- 
Brian Utterback, Millipore Corporation, 75G Wiggins Ave., Bedford Ma. 01730
Work:617-275-9200x8245, Home:603-891-2536
INTERNET:: blu@millipore.millipore.com
UUCP:: {samsung,cg-atla,merk,wang,bu-tyng}!millipore!blu

duchier@cs.yale.edu (Denys Duchier) (10/24/90)

Read p185 of the LaTeX manual.  The following code should then become
clear:

\newlength{\length}
\setlength{\length}{0.5\linewidth}
\addtolength{\length}{-2\tabcolsep}
\begin{center}
\begin{tabular*}{\linewidth}{|p{\length}|p{\length}|}
...
\end{tabular*}
\end{center}

If you are using Mittelbach's implementation of tabular, you may have
to add the following line:

\addtolength{\length}{-1.5\arrayrulewidth}

--Denys

rcbatg@rwc.urc.tue.nl (Tonnie Geraets) (10/25/90)

duchier@cs.yale.edu (Denys Duchier) writes:
>Read p185 of the LaTeX manual.  The following code should then become
>clear:

>\newlength{\length}
>\setlength{\length}{0.5\linewidth}
.
>\begin{tabular*}{\linewidth}{|p{\length}|p{\length}|}

>--Denys

But what to do I have some more columns (whith different widths) and I want
a column which fills the rest of the line. Something like this:

| This is column one | two | anonother | And finaly, this column fills up to |
|                    |     |           | the end of the line.                |
| another entry      | two | column    | I don't want to specify the width   |
|                    |     |           | myself, simply because I don't know |

or

| Column one | Now this column is much wider than in the previous example    |
|            | but fills up the whole width also                             |


Tonnie Geraets,
	rcbatg@urc.tue.nl

duchier@cs.yale.edu (Denys Duchier) (10/26/90)

In article <rcbatg.656867719@rwc.urc.tue.nl> rcbatg@rwc.urc.tue.nl (Tonnie Geraets) writes:
 >   duchier@cs.yale.edu (Denys Duchier) writes:
 >   >Read p185 of the LaTeX manual.  The following code should then become
 >   >clear:
 >
 >   >\newlength{\length}
 >   >\setlength{\length}{0.5\linewidth}
 >   .
 >   >\begin{tabular*}{\linewidth}{|p{\length}|p{\length}|}
 >
 >   >--Denys
 >
 >   But what to do I have some more columns (whith different widths) and I want
 >   a column which fills the rest of the line. Something like this:
 >
 >   | This is column one | two | anonother | And finaly, this column fills up to |
 >   |                    |     |           | the end of the line.                |
 >   | another entry      | two | column    | I don't want to specify the width   |
 >   |                    |     |           | myself, simply because I don't know |

How about this:

\newlength{\length}
\newlength{\width}
\setlength{\length}{\linewidth}
\addtolength{\length}{-8\tabcolsep}
\settowidth{\width}{This is column one}
\addtolength{\length}{-\width}
\settowidth{\width}{two}
\addtolength{\length}{-\width}
\settowidth{\width}{anonother}% sic!
\addtolength{\length}{-\width}
\begin{center}
\begin{tabular*}{\linewidth}{|l|l|l|p{\length}|}
...
\end{tabular*}
\end{center}

If you are using Mittelbach's implementation of tabular, you may have
to add the following line:

\addtolength{\length}{-5\arrayrulewidth}

--Denys

Douglas.Miller@viccol.edu.au (Douglas Miller) (10/30/90)

In article <rcbatg.656867719@rwc.urc.tue.nl>, rcbatg@rwc.urc.tue.nl (Tonnie
Geraets) writes:

> duchier@cs.yale.edu (Denys Duchier) writes:
>>Read p185 of the LaTeX manual.  The following code should then become
>>clear:
> 
>>\newlength{\length}
>>\setlength{\length}{0.5\linewidth}
> .
>>\begin{tabular*}{\linewidth}{|p{\length}|p{\length}|}
> 
>>--Denys
> 
> But what to do I have some more columns (whith different widths) and I want
> a column which fills the rest of the line. Something like this:
> 
> | This is column one | two | anonother | And finaly, this column fills up to |
> |                    |     |           | the end of the line.                |
> | another entry      | two | column    | I don't want to specify the width   |
> |                    |     |           | myself, simply because I don't know |
> 
> or
> 
> | Column one | Now this column is much wider than in the previous example    |
> |            | but fills up the whole width also                             |

Easy (:-), just produce the table twice.  The first time, guess a width for
the paragraph column, and put the resulting table into a box.  Use the
width of the box to calculate the true paragrpah width, and produce the
table again.

There are two ways I know of to access the text of your table multiple
times:

  1.  Write an pseudo environment that is really a macro (like the verbatim
      environment).  Having all your text as a macro can have nasty side
      effects though.

  2.  Write an environment to first write the text to a temorary file
     (warning --- this is harder than it sounds) and then read in the text
     two or more times as it experiments with paragraph widths.