fletcher.node()
Place a node in a diagram or CeTZ canvas.
Nodes are content which edge()s can snap to. Nodes can have various shapes (rect, circle), styles (fill, stroke).
fletcher.node( ..args, body: content, shape: auto none string, fill, stroke, inset: length array dictionary, outset: length, extrude: array, layer: number, name: label str, align: alignment, weight: number, enclose: array, snap: bool, colspan: number none, rowspan: number, in-math: bool, debug, )
body
noneContent to draw in the node.
This content is measured to automatically determine the size of the node. The "node.body" debug option shows the body’s bounding box after inset is applied.
shape
autoThe shape of the node’s body enclosing its label.
Built-in shapes are "none", "rect", "circle", "ellipse", "pill", "parallelogram", "keystone", "diamond", "triangle", "house", "chevron", "hexagon", "octagon" and "cylinder".
Some node shapes accept other styling options which can be passed as arguments to node().
See also the Node shapes section of the manual.
fill
autoFill style of the node.
The fill is drawn within the outline defined by the first extrude value. For example:
#diagram(
node-fill: yellow,
node-stroke: 1pt,
node((0,0), [A], extrude: (0, 3)),
node((1,0), [B], extrude: (3, 0)),
)This option is a node style.
inset
autoPadding applied to the content in a node’s body.
The "node.inset" debug option draws a box around the body content before inset is applied.
The inset can be a length like 5pt, or a CeTZ-style array or dictionary: for example, (0, 5pt) for only horizontal padding; (left: 5pt, rest: 10pt) for per-edge padding.
This option is a node style.
outset
autoSeparation between the node’s visible outline and the snapping target for edges.
This does not affect the node’s appearance or layout, only how closely edges connect to it.
When "node.outset" debug option is on, the node outset drawn as a green dotted line.
#diagram(
debug: "node.outset",
node-stroke: 1pt,
node((0,0), [Hello]),
edge("<->"),
node((1,0), [World], outset: 5pt, shape: "ellipse"),
)This option is a node style.
See also edge.outset, which controls how closely individual edges connect to nodes.
extrude
autoDraw strokes around the node at the given offsets to obtain a multi-stroke effect. Offsets can be numbers specifying multiples of the stroke’s thickness or lengths.
The node’s fill is drawn within the boundary defined by the first offset in the array.
This option is a node style.
layer
autoCanvas layer to draw node on.
The default layer for nodes is 0, which is above edges (on layer -1 by default; see edge.layer). Enclose nodes are drawn on layer -2 by default, under nodes and edges. Nodes with equal layer are drawn in the order they are inserted.
This option is a node style.
name
noneName of the node for use with coordinate anchors.
This can also be passed as a positional argument (but then the name must be a label, not a string).
align
center + horizonAlign a node within its associated flexigrid cell.
This only has effect when used inside a diagram() or flexigrid().
The node’s associated cell is visible when the "node.cell" debug option is enabled.
weight
1How much the node influences the size of flexigrid rows/columns.
If 0, the node does not affect the flexigrid or other node positions. If 1, rows and columns grow to fully accommodate the node.
enclose
nonePositions or names of nodes to be enclosed by this node.
When set, the node’s position must be unset (or auto). The node is automatically positioned and enlarged so that it encloses the specified nodes.
#diagram(
node-stroke: 1pt,
node((0,0), [ABC], name: <A>),
node((1,1), [XYZ], name: <Z>),
node(
enclose: (<A>, <Z>),
text(teal)[Enclose node], stroke: teal,
name: <group>),
edge(<group>, (3,0.5), stroke: teal),
)snap
trueWhether this node can have edges automatically snap to it.
colspan
noneThe number of columns spanned by the node’s flexigrid cell.
The column span can be positive (meaning the cell grows rightwards) or negative (leftwards), or even fractional. The cell must span at least one column, so the range of this parameter is .
If the column span is not none, then node’s width defaults to the full size of its enclosing cell.
#diagram(
spacing: 5pt,
debug: "node.cell",
node((0,0), colspan: 3, $x y z$),
node((0,1), rowspan: 2, $x$),
node((1,1), $y$),
node((2,1), $z$),
node((2,2), colspan: -2, $y z$)
)in-math
falseWhether to return a metadata object which can be placed inside equations, instead of returning an array of functions which can be inserted into a CeTZ canvas.
If you often use fletcher in math mode, consider defining a shortcut:
#let hom = edge.with(in-math: true)
#let obj = node.with(in-math: true)Now, hom edges and obj nodes can be inserted into equations, like so:
#diagram($x hom(|->) & obj(pi(x), stroke: #yellow)$)See also edge.in-math.
debug
autoEnable debug annotations for only this node. See Node debug options.
If auto, the debug setting is inherited from the enclosing diagram() or flexigrid().