groff
[Top][All Lists]
Advanced

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

Re: [Groff] Creating a table macro


From: Automation Department
Subject: Re: [Groff] Creating a table macro
Date: Wed, 18 May 2011 13:16:37 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks Ted. That answers my question.

This macro from:

http://www.port.de/cgi-bin/groff/TableInMacro

works as you describe -- ( includes .TE ):

.eo
.de ATABLE ..
.TS
allbox tab(;);
cl.
\$1;\$2
.TE
...
.ec

...with the limitation of not allowing an arbitrary number of arguments.
Is it possible to toss in a while loop -

.while ( args > 0) \{\
        ....etc
\}

 to process unknown number of arguments?

Looking through the mans and docs on while loops in groff, but will not
inquire further if this is not possible.

Thanks again.

Chad Roseburg


On 05/18/2011 12:00 PM, (Ted Harding) wrote:
> On 18-May-11 01:59:23, Automation Department wrote:
>> Would like to create a very simple table macro.
>> eg.,
>>
>> .de TABLE
>> .TS
>> box expand;
>> l s
>> l l.
>> \fI\\$1\fP
>>
>> ..
>>
>> This does not work though other similarly crafted macros do.
>> It 'starts' the macro at the macro definition. Do I need to
>> escape it?
>>
>> Also, if I just do:
>>
>> .de TABLE
>> box expand;
>> l s
>> l l.
>> \fI\\$1\fP
>>
>> ..
>>
>> Then call with
>>
>> .TS
>> .TABLE "Macro Junk"
>> column1       column2
>> .TE
>>
>> I get:
>> tbl:final_rpt.roff:369: `.' not last character on line
>> tbl:final_rpt.roff:369: giving up on this table
>>
>> Just hoping to save some typing.
>>
>> Thanks!
>> - -- 
>> Chad Roseburg
> 
> To deal first with your second example:
> 
> The problem here is that the "." at the beginning of the
> second line will be interpreted as the "." that normally
> occurs at the end of the formatting lines. Note that this
> is different from the interpretation of "." when it occurs
> in a numerical context, such as when you are defining a
> minimum column width -- e.g.
> 
>   .TS
>   box
>   lw(1.5i) l.
> 
> since that occurs inside "w()" where tbl is expecting
> to find a numerical expression. When the "." occurs at
> "top level" as in your ".TABLE ..." it will be taken at
> "face value", i.e. as the terminator for the formatting.
> 
> Now for your first example. The problem here is that
> your macro ".TABLE" will be interpreted by troff, not
> by the preprocessor tbl. Note *pre*processor -- tbl
> does its work before troff sees the results. If troff
> expands a macro (such as your .TABLE) then it is too
> late -- the processing has moved on past tbl.
> 
> Incidentally, you will get no result at all unless you
> include the ".TE" at the end of the macro definition,
> as in
> 
> .de TABLE
> .TS
> box expand;
> l s 
> l l.
> \fI\\$1\fP
> .TE
> ..
> .TABLE "Macro Junk"
> 
> but even then it will not be the result you want. This
> is because tbl has already done its work, as explained
> above, as you can verify by deleting the line
> .TABLE "Macro Junk"
> (thus not calling the macro at all) -- tbl sees the .TS
> and .TE, ignores the fact that they are inside a macro
> definition (tbl does not recognise macros), and simply
> creates troff code for what it finds between them.
> 
> Probably the simplest way to "save some typing" is to
> use the copy-&-paste functionality of your editor to
> copy down an existing instance of the table setup lines.
> Some editors will alow you to define a block of text
> and give it a name, so that when you invoke the name
> it will automatically insert the whole block.
> 
> Hoping this helps,
> Ted.
> 
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <address@hidden>
> Fax-to-email: +44 (0)870 094 0861
> Date: 18-May-11                                       Time: 20:00:01
> ------------------------------ XFMail ------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJN1CklAAoJEBi1nVMf5Zz5LocH/RG+nvqj1ui/X30HJuke5lvn
KgUSHvYEAtnGWa++wCv/Pa/kJPo9ZD8+JlJsKZUsL1UnPW5+xeEpp8kWYe/+uhF/
Df/+DGB7kXGBwEkc1dCiTjrHXhGUig9h1yUM485WiUq7hbiv/b+3P8xpt7QURBot
AUN5MrwdLglWuSlJLZ70DQH3aPDPmL4uqh49sy0nmWkMJyh1Q1HpMsRFyHKx5GqF
9MaKzL5Eub+RWIJh5Gn4oIrBwOj/yXfBlWQDzLkfNT1w/3F/U66IbcbvYj9A2LE+
v45lpMpOIVJOy5ZA5thQF+72UbhV7GIVFED+VysyCz3YXfvUL4SyTiL2L7ssGus=
=oDLD
-----END PGP SIGNATURE-----



reply via email to

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