format-wrap
Soft-wrap a long string by inserting a newline at word boundaries.
Usage
format-wrap(
width: 20,
)Parameters
| Parameter | Default | Description |
|---|---|---|
width |
20 |
Maximum line width in characters. |
Returns
A closure value => string.
Examples
Soft-wrap long discrete tick labels onto multiple lines at a width of eight characters.
#let d = (
(g: "alpha quadrant", y: 4),
(g: "beta sector", y: 7),
(g: "gamma frontier", y: 3),
)
#plot(
data: d,
mapping: aes(x: "g", y: "y"),
layers: (geom-col(),),
scales: (scale-x-discrete(labels: format-wrap(width: 8)),),
width: 10cm,
height: 6cm,
)