stroke
Defines how to draw a line.
A stroke has a paint (typically a solid color), a thickness, a line cap, a line join, a miter-limit, and a dash pattern. All of these values are optional and have sensible defaults.
Example
#set line(length: 100%)
#stack(
spacing: 1em,
line(stroke: 2pt + red),
line(stroke: (paint: blue, thickness: 4pt, cap: "round")),
line(stroke: (paint: blue, thickness: 1pt, dash: "dashed")),
)

Simple strokes
You can create a simple solid stroke from a color, a thickness, or a combination of the two. Specifically, wherever a stroke is expected you can pass any of the following values:
- A length specifying the stroke's thickness. The color is inherited, defaulting to black.
- A color to use for the stroke. The thickness is inherited, defaulting to
1pt
. - A stroke combined from color and thickness using the
+
operator as in2pt + red
.
Complex strokes
For full control, you can also pass a dictionary to any function that expects a stroke. This dictionary has the following keys:
-
paint
: The color to use for the stroke. -
thickness
: The stroke's thickness as a length. -
cap
: How the line terminates. One of"butt"
,"round"
, or"square"
. -
join
: How sharp turns of a contour are rendered. One of"miter"
,"round"
, or"bevel"
. Not applicable to lines but to polygons or paths. -
miter-limit
: Number at which protruding sharp angles are rendered with a bevel instead. The higher the number, the sharper an angle can be before it is bevelled. Only applicable ifjoin
is"miter"
. Defaults to4.0
. -
dash
: The dash pattern to use. Can be any of the following:- One of the predefined patterns
"solid"
,"dotted"
,"densely-dotted"
,"loosely-dotted"
,"dashed"
,"densely-dashed"
,"loosely-dashed"
,"dash-dotted"
,"densely-dash-dotted"
or"loosely-dash-dotted"
- An array with alternating lengths for dashes and gaps. You can also use the string
"dot"
for a length equal to the line thickness. - A dictionary with the keys
array
(same as the array above), andphase
(of type length), which defines where in the pattern to start drawing.
- One of the predefined patterns
Fields
On a stroke
object, you can access any of the fields mentioned in the dictionary format above. For example, (2pt + blue).thickness
is 2pt
. Meanwhile, (2pt + blue).cap
is auto
because it's unspecified.