[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] table column widths

From: Ted Harding
Subject: Re: [Groff] table column widths
Date: Thu, 18 Dec 2003 20:39:03 -0000 (GMT)

[I sent this earlier, but it has not reached the list.
 So I am re-sending it by a different route. Apologies
 if you receive it twice.]

On 18-Dec-03 Larry Kollar wrote:
>> Is it possible to specify column widths in a table as a proportion of
>> the linewidth? I've tried using the line width register to calculate a
>> width for a column:
>> lw(\n.H/3u)lw(2*\n.H/3u)
>> but I've no experience of groff and, not surprisingly, that didn't
>> work.
> If ".H" is really the number register you're using, try w(\n[.H]/3u)
> (putting brackets around the name).
> If I could do more than code my way out of a paper bag, I'd write
> a patch for tbl that allowed it to specify a column width as a
> percentage of line width....

You need either \n[xx] as Larry suggests, or \n(xx, where "xx" is
the register name.

But the register you need is \n[.l] -- the line length.
The register you tried to use, \n[.H], is the "available horizontal
resolution in units", which typically has value 1.

So what you were doing (if in PostScript) was telling tbl that
you wanted your columns to be at least 1/(3*72000) inches wide,
or 2/(3*72000).

If you change it to 

  lw(\n[.l]/3u) lw(2*\n[.l]/3u)

then I think you will find that it works.

And, by the way: when doing arithmetic on dimensions expressed
in units, think about whether to do divisions before multiplications.
For instance, if you wanted a rather precise fractikon of line
length such as

  .nr tmp \n[.l]*6755/10000

you would find that overflow occurred because of the multiplication
of a rather large number of units, while

  .nr tmp \n[.l]/10000*6755

would be OK (the division is performed first, then the multiplication).
However, in the second form, you might lose some precision.

Best wishes,

E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 18-Dec-03                                       Time: 20:04:52
------------------------------ XFMail ------------------------------

E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 18-Dec-03                                       Time: 20:39:03
------------------------------ XFMail ------------------------------

reply via email to

[Prev in Thread] Current Thread [Next in Thread]