groff
[Top][All Lists]
Advanced

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

Re: [Groff] Creating a table macro


From: Ted Harding
Subject: Re: [Groff] Creating a table macro
Date: Thu, 19 May 2011 09:14:53 +0100 (BST)

Here is an example, using the approach I described earlier,
to achieve the sort of thing you are looking for. This does
a 1-line table. A multiline table would require a slightly
different approach, and I will work one out later!

Some details of the formatting below are there to verify
that it is working as intended (e.g. the ""ce" and le" for
equal width columns). Such things can be changed according
to taste. Similarly the use of "#" as delimiter may depend
on what content you want to put in the table.

Ted.
==========================================================

.\" One-line table with arbitrary cols
.\" Usage:
.\" .Tbleone <args>
.de Tblone
.nr nargs \\n[.$]
.ds cols ce
.ds tabline \\$1
.while (\\n[nargs] > 1) \{\
.shift
.as cols " le
.as tabline #\\$1
.nr nargs -1
.\}
.open TBL tbltemp
.write TBL .TS
.write TBL allbox tab(#);
.write TBL \\*[cols].
.write TBL \\*[tabline]
.write TBL .TE
.close TBL
.sy tbl tbltemp > tblouttemp
.so tblouttemp
..
.Tblone one two three four five twentyfive
.Tblone eight nine "ten and eleven"

==========================================================

The contents of the file tbltemp after the first call to
.Tblone are:

.TS
allbox tab(#);
ce le le le le le.
one#two#three#four#five#twentyfive
.TE

and, after the second call:

.TS
allbox tab(#);
ce le le.
eight#nine#ten and eleven
.TE




--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 19-May-11                                       Time: 09:14:49
------------------------------ XFMail ------------------------------



reply via email to

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