You need context, but not that much. I suspect that this will basically work if you put the whole CeTZ canvas into the context, and don’t use context
anywhere else.
this function would not return a length but content
(and children.map(width)
would result in an array of contents instead of an array of lengths as well). To learn more about the reasons, take a look at Why is the value I receive from context always content? - #2 by laurmaedje
Since each context
expression results in opaque content, everything that depends on the non-opaque values within the block needs to be nested inside the context. Since the CeTZ canvas itself needs structured data (i.e. the CeTZ drawing functions) you can’t put context between the canvas and the drawing functions; from that it follows that you put the context around the canvas.