Jollywatt / typst-fletcher

Typst package for drawing diagrams with arrows, built on top of CeTZ.
MIT License
270 stars 6 forks source link

Place node label above the node #18

Closed augustebaum closed 3 months ago

augustebaum commented 3 months ago

Hi,

I'm trying out fletcher and struggling to place a node's label above it. I don't see any example of this in the docs; can this be done somehow?

Thanks in advance, fletcher seems really powerful apart from that. I really appreciate the integration with touying!

Jollywatt commented 3 months ago

Hmm. You could do this by manually moving the label, like this:

#diagram(
  node-stroke: 1pt,
  node((0,0), $A$, radius: 5mm),
  edge("-|>"),
  node((1,0), move(dy: -8mm, $B$), radius: 5mm)
)

Alternatively, you could make the node label its own node, and position it separately:

#diagram(
  node-stroke: 1pt,
  node((0,0), $A$, radius: 5mm),
  edge("-|>"),
  node((1,0), radius: 5mm),
  node((1,-.5), $B$, stroke: none)
)

Is that what you mean? If so, I don’t think this should be added as a built-in feature, since it would make things too complicated without needing to.

augustebaum commented 3 months ago

Thanks for the quick response! I'm happy with these two solutions, I just wanted to make sure I wasn't missing some idiomatic way of doing it. Thanks again :)