Jollywatt / typst-fletcher

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

How to set edge label font size globally? #35

Closed hooyuser closed 1 month ago

hooyuser commented 1 month ago

Hi, I'm currently trying to adjust the edge label font size globally across all diagrams. In LaTeX, using the tikzcd package, the edge label text is smaller by default, as the following image shows:

ima

I'm looking for a way to achieve a similar appearance with typst-fletcher. Could you provide guidance on how to globally set the edge label font size?

Additionally, I would like to know if there are any plans to make smaller edge labels the default appearance in future versions, considering its common use in math books. Thank you for your help!

Jollywatt commented 1 month ago

This is currently a gap in fletcher. I think it's worth adding a label-size option to diagram() (and edge() for completeness) which inserts a set rule before the label, since this is probably common.

At the moment, the thing one might do is to define a wrapper that applies the desired style:

#let ls(it) = text(0.8em, it) // [l]abel [s]ize

#diagram(
  $
  f edge("d", ->) edge(->, ls(f)) & f \
  f edge("ur", ->)
  $,
)

#diagram(
  node((0,0), [A]),
  edge(ls[hello]),
  node((1,1), [B])
)

Of course, this isn't as elegant as it could be, since it requires you to define a function and call it on every label yourself.

hooyuser commented 3 weeks ago

@Jollywatt Thanks for your awesome work on the recent commit 6e7b5f3. It's a lifesaver!

Could we consider bumping the version number for the Typst official package? This would allow users to start taking advantage of the new features right away.

Jollywatt commented 3 weeks ago

Yeah, one thing I don't have the hang of is best practices for versioning and release cycles:P

This feature has been bundled with a whole lot of other changes for version v0.5.0, which is slightly breaking. That will happen this week. Hopefully it won't be too painful to update!