groff
[Top][All Lists]
Advanced

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

Re: pic doesn't center when i use a macro


From: T. Kurt Bond
Subject: Re: pic doesn't center when i use a macro
Date: Mon, 1 Nov 2021 16:12:46 -0400

While I don't have any suggestions as how to fix this, I did try it with
Heirloom troff, and it seems to have the same unwanted non-centering result
as groff.

On Mon, Nov 1, 2021 at 3:52 PM Marc Chantreux <eiro@phear.org> wrote:

> hello groffers,
>
> I wrote the following code to illustrate the DOD model encapsulation.
>
> sadly: the label of the layers are not centred. it seems to be relative
> to the fact i use a function as it works fine when i replace
> label_for(layer) by a simple string
>
> like
>
>     box width w height margin \
>         with .nw at last box .nw dashed \
>         "" label_for(layer) ""
>
> by
>
>     box width w height margin \
>         with .nw at last box .nw dashed \
>         "" "eat the road, jack" ""
>
> I can do something more manual but i really would like to take advantage
> of the expressivity of pic. Any other comment is also warmly welcome.
>
> regards,
> marc
>
> # compiled with
> # scan.ps: scan.ms ${deps} ; groff -skp -ms -mfr $< > $@
>
> .PS
>
> define label_for {
>     if $1 == 0 then { "Entête Ethernet"      } else {
>     if $1 == 1 then { "Entête IP"            } else {
>     if $1 == 2 then { "Entête TCP"           } else {
>     if $1 == 3 then { "Donnees applicatives" } else {
>     } } } }
> }
>
> w = 3 ; h = 2; margin = .2 ; tr = 2 * margin
> for layer = 0 to 3 do {
>     s = layer * margin
>     box width w height h with .sw at (s,s)
>     box width w height margin with .nw at last box .nw dashed ""
> label_for(layer) ""
>     w = w - tr
>     h = h - tr
> }
> .PE
>
>

-- 
T. Kurt Bond, tkurtbond@gmail.com, https://tkurtbond.github.io


reply via email to

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