groff
[Top][All Lists]
Advanced

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

pic doesn't center when i use a macro


From: Marc Chantreux
Subject: pic doesn't center when i use a macro
Date: Mon, 1 Nov 2021 19:57:15 +0100

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



reply via email to

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