groff
[Top][All Lists]
Advanced

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

Re: [Groff] tbl: text blocks vs. centering


From: Werner LEMBERG
Subject: Re: [Groff] tbl: text blocks vs. centering
Date: Fri, 08 Sep 2006 08:12:56 +0200 (CEST)

> > 1. Put each text block into a diversion with the given width,
> >    either following the above formula or using a user-specified
> >    width.
> > 2. Set the adjust flags, sizes, etc., as specified.
> > 3. Format the diversions.
> > 4. Construct the table and use the diversions.

> That doesn't seem to make a difference.  I can force centering by
> wrapping the text:
> T{
> .ad c
> blah blah...
> .fl
> .ad l
> T}

This isn't sufficient.  The formatting of the diversion is completely
independent from the construction of the table.  The `.ad c' command
applies to the diversion, not to the table.  See the attached files
(input and output) which permutates all possible combinations, with
and without specifying widths.  I hope this makes the issue better
understandable.

> But if it's setting the adjust flags in step 2, why isn't the
> adjustment getting picked up from the column spec?

Because it is so :-)  I'm quite sure that the original AT&T tbl
preprocessor behaves the same.

> Also, that doesn't address vertical centering: the diversion
> containing the text block has a known height, so it should be
> possible to put it where it belongs.

As tbl doesn't know the contents of the diversion it can't handle
this.


    Werner
.\" tbl-textblocks.tr
.\"
.\" This document is formatted for A4 paper size.
.\" Process it with
.\"
.\"   groff -t -P-pa4 tbl-textblocks.tr > tbl-textblocks.ps
.
.
.po ((21c - 6.4i) / 2u)
.
.de parskip
.  sp (\n[.v]u * 8u / 10u)
..
.
.blm parskip
.
.
.ll 6.4i
.in 0i


.tl ''\s+[7]The handling of tbl text blocks\s[0]''


The line length is set to 6.4i in this document;
there is no indentation.
All tables use the `expand' keyword to make them as wide as the line length;
the three table rows in a table are left-justified,
right-justified,
and centered
(from top to down using table key characters).
Within a row the text blocks use left-justification,
right-justification,
and centering
(from left to right;
this is done with explicit `.ad' requests within the text blocks).

The width of the leftmost and rightmost horizontal space is fixed
(1\~`unit');
they are present if the table starts or ends with a vertical line,
respectively.
The width between columns can be configured;
it defaults to 3\~`units'.
This `unit' is 1n for unexpanded tables and scaled accordingly if the
`expand' keyword is used.
For the tables below this makes 8 such horizontal space values.
The leftmost and rightmost vertical lines do not take part in the
calculation;
close inspection shows that they are drawn in the margin.

Text blocks are formatted within diversions before the remaining parts of
the table are constructed.

The first table uses the `e' modifier to get columns of equal width.
Since no text blocks widths are specified,
the default values are computed as `LC\|/\|(N\[pl]1)',
with `L' as the text length,
`C' the number of columns spanned by the current column,
and `N' the total number of columns in the table.
Thus we have 6.4i\|/\|4\|=\|1.6i as the width of a text block \[en]
note that this value gives the line length within the diversion;
the effective line length as used in table
(after processing the diversion)
might differ considerably:
Within a diversion,
starting whitespace is retained,
but trailing whitespace gets discarded.
The largest horizontal width value is used to compute the column width;
due to the right-justified text block it is 1.6i.
This gives (6.4i\[mi]1.6i\[mi]1.6i\[mi]1.6i)\|/\|8\|=\|0.2i as the width of
the separation space.

.TS
allbox, expand;
le le le
re re re
ce ce ce.
T{
.ad l
f
.br
fo
.br
foo
T}      T{
.ad r
f
.br
fo
.br
foo
T}      T{
.ad c
f
.br
fo
.br
foo
T}
T{
.ad l
f
.br
fo
.br
foo
T}      T{
.ad r
f
.br
fo
.br
foo
T}      T{
.ad c
f
.br
fo
.br
foo
T}
T{
.ad l
f
.br
fo
.br
foo
T}      T{
.ad r
f
.br
fo
.br
foo
T}      T{
.ad c
f
.br
fo
.br
foo
T}
.TE

The next table doesn't use any modifiers.
This means that the natural widths of all entries are used
(to be more accurate,
the width of the widest entry in each column is used).
While the text block widths are the same as above
(1.6i),
the natural widths of the diversions are used.
The width of the string `foo' is 0.185i,
thus the width of the left-justified text block is 0.185i,
the width of the centered block is 1.6i\|/\|2\[pl]0.185i\|/\|2\|=\|0.893i,
and the width of the right justified block is 1.6i.
Using these values we get
(6.4i\[mi]0.185i\[mi]0.893i\[mi]1.6i)\|/\|8\|=\|0.465i as the width of the
separation space;
naturally,
the middle column is far wider than the other twos.

.TS
allbox, expand;
l l l
r r r
c c c.
T{
.ad l
f
.br
fo
.br
foo
T}      T{
.ad r
f
.br
fo
.br
foo
T}      T{
.ad c
f
.br
fo
.br
foo
T}
T{
.ad l
f
.br
fo
.br
foo
T}      T{
.ad r
f
.br
fo
.br
foo
T}      T{
.ad c
f
.br
fo
.br
foo
T}
T{
.ad l
f
.br
fo
.br
foo
T}      T{
.ad r
f
.br
fo
.br
foo
T}      T{
.ad c
f
.br
fo
.br
foo
T}
.TE

The final table sets the column widths explicitly for the text blocks
(using the `w' modifier).
We use 1.9i for each table;
this yields (6.4i\[mi]1.9i\[mi]1.9i\[mi]1.9i)\|/\|8\|=\|0.088i as the
separation `unit'.

.TS
allbox, expand;
lw(1.9i) lw(1.9i) lw(1.9i)
rw(1.9i) rw(1.9i) rw(1.9i)
cw(1.9i) cw(1.9i) cw(1.9i).
T{
.ad l
f
.br
fo
.br
foo
T}      T{
.ad r
f
.br
fo
.br
foo
T}      T{
.ad c
f
.br
fo
.br
foo
T}
T{
.ad l
f
.br
fo
.br
foo
T}      T{
.ad r
f
.br
fo
.br
foo
T}      T{
.ad c
f
.br
fo
.br
foo
T}
T{
.ad l
f
.br
fo
.br
foo
T}      T{
.ad r
f
.br
fo
.br
foo
T}      T{
.ad c
f
.br
fo
.br
foo
T}
.TE

Attachment: tbl-textblocks.pdf
Description: Adobe PDF document


reply via email to

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