Labels & ordinals
pic gives you two ways to refer back to something you drew: give it a name, or point at it by order.
Labels
A capitalized name followed by a colon labels the next object (or a bare position). Labels are how larger pictures stay readable.
.PS
In: circle "in" rad 0.22
Sum: circle rad 0.1 at In + (0.9, 0)
Out: box "out" wid 0.6 ht 0.45 at Sum + (1.0, 0)
arrow from In.e to Sum.w
arrow from Sum.e to Out.w
line -> from Out.s down 0.35 then left Out.x - Sum.x then to Sum.s
.PEA label can also name a plain point (P: (0.9, -0.5)) — handy for wiring.
Ordinals
last, 2nd, 3rd last … select objects by their order of appearance,
optionally filtered by kind:
.PS
box "1"; move; box "2"; move; circle "c" rad 0.3
arrow from last box.s down 0.3
arrow from 1st box.s down 0.3
line dashed from last circle.n up 0.25
.PElast on its own matches the most recent object of any kind; last box
filters by kind. This is exactly dpic’s behavior.
Here
Here (capitalized, as in classic pic) is the current position. The classic
use: stash a junction point while walking a wire, then branch from it later —
.PS
box "in" wid 0.55 ht 0.4
line right 0.4
H: Here # stash the junction
arrow right 0.4
box "out" wid 0.55 ht 0.4
dot at H
line -> from H down 0.5 then right 0.4
box "log" wid 0.55 ht 0.4
.PEThe dot marks exactly the point H remembered.
Anchors on references
Every reference — label or ordinal — exposes the same compass anchors:
.PS
A: box "A"
box "B" with .w at A.e + (0.5, 0)
line dotted from A.ne to last box.nw
line dotted from A.se to last box.sw
.PEWhere to go next
- Variables & macros — parameterize with
define, loop withfor