[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] Tips & Tricks: Tables with abutting rules
From: |
Ted Harding |
Subject: |
[Groff] Tips & Tricks: Tables with abutting rules |
Date: |
Tue, 05 Jul 2011 16:56:49 +0100 (BST) |
Greetings all!
Continuing to share little tips & tricks. here is one for 'tbl'.
Normnally, if you want a table with vertical rules on either
side, you will enter a format line like
|l c r|.
This will have the effect that between the left-hand vertical
rule "|" and the first character of the first field there will
be a space (of width 1n), and similarly between the last character
of the last field and the right-hand vertical rule "|".
However, you may (for good reasons ... that's a matter for
your taste in such things) wish to have no such spaces, either
at both side, or just at one side.
This could arise, for instance, if a graphical object has
been defined as a ".char" and you wish this to abut on the
vertical rule.
There is no 'tbl' option which allows a "no space" to be set
in this context. However, there is a trick. This is to use
dummy columns at the left and/or right, with associated sero
column spacings. Here is a simple example.
First, some text with abutting vertical rules left & right
is set using only troff commands, to provide a reference
object for the performance of 'tbl' in the subsequent lines.
Then a 2-line table which shows the desired effect is set.
.br
\Z'\D'l 0 0.45i''\v'1m'and three words\v'-1m'\D'l 0 0.45i'
.sp 2
.TS
tab(#);
r0|c0|l.
#two words#
#and three words#
.TE
.\"## and compare with
.sp
.TS
tab(#);
|c|.
two words
and three words
.TE
Thus the equivalent troff-generated and tbl-generated outputs
are exactly aligned. This works because 'tbl' only pads with
extra space on either side if the "| ... |" are present;
otherwise, the left-hand extent of the table contents is flush
left, and similarly for the right-hand extent. Since the dummy
columns are associated with zero-space separation from their
neighbours, and have no content, they will have width 0, and
thwe vertical rules will be flush left/right.
Comments welcome!
Best wishes to all,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 05-Jul-11 Time: 16:56:44
------------------------------ XFMail ------------------------------
- [Groff] Tips & Tricks: Tables with abutting rules,
Ted Harding <=
Re: [Groff] Tips & Tricks: Tables with abutting rules, Ted Harding, 2011/07/07