I took a look in the documentation, there’s a part called “Cetz integration” that shows the following code:
#diagram(
node((0,1), $A$, stroke: 1pt, shape: fletcher.shapes.diamond),
node((2,0), [Bézier], fill: purple.lighten(80%)),
render: (grid, nodes, edges, options) => {
// cetz is also exported as fletcher.cetz
cetz.canvas({
// this is the default code to render the diagram
fletcher.draw-diagram(grid, nodes, edges, debug: options.debug)
// retrieve node data by coordinates
let n1 = fletcher.find-node-at(nodes, (0,1))
let n2 = fletcher.find-node-at(nodes, (2,0))
let out-angle = 45deg
let in-angle = -110deg
fletcher.get-node-anchor(n1, out-angle, p1 => {
fletcher.get-node-anchor(n2, in-angle, p2 => {
// make some control points
let c1 = (to: p1, rel: (out-angle, 10mm))
let c2 = (to: p2, rel: (in-angle, 20mm))
cetz.draw.bezier(
p1, p2, c1, c2,
mark: (end: ">") // cetz-style mark
)
})
})
})
}
)
But I still can’t figure out how to make this integration based on this, I want to use #line(…) and other cetz commands in the same environment as the fletcher diagrams.
#import "@preview/fletcher:0.5.8" as fletcher: *
#diagram(
node((0,1), $A$, stroke: 1pt, shape: fletcher.shapes.diamond),
node((2,0), [Bézier], fill: purple.lighten(80%)),
render: (grid, nodes, edges, options) => {
// cetz is also exported as fletcher.cetz
cetz.canvas({
import cetz.draw: *
// this is the default code to render the diagram
fletcher.draw-diagram(grid, nodes, edges, debug: options.debug)
line((0, 0), (1, 1))
})
}
)
If I had to guess (hint: if you tell us the error message(s) you get, we can often be more precise in our help), you were maybe missing the import line, or were using #line(...) instead of line(...). The # is needed to switch from markup to code mode, and inside the diagram you were already in code mode.
Hello. Please use backticks for inline code snippets and update your post. Your code example also does not compile, which makes it harder on those who want to answer or use it. See https://sscce.org.