Closed smorad closed 3 months ago
We're definitely looking to improving our documentation but I'm not entirely sure what you mean. Are you asking for a flowchart that uses relative positioning or a flowchart that explains relative positioning? The former makes more sense...
For the relative positioning example you've given you can instead just use "A"
for the coordinate to content
. As anchors are resolved to the correct position anyway. See section 4.6 of the manual (use the version on typst/packages).
Wrapping elements in another element, equivalent to tikz's
node[fit=(a) (b)]
You can kind of do this with content
's frame
argument and there's a propsal #372 to change it. Actual fitting of points we don't have the algorithms for yet (you could make an issue).
Combining cardinal directions
a.top + a.left == a.top_left
.
For anchors these exist as top-left
(section 2.2)
Drawing rectangles using a center and height/width, rather than the corners.
You can do height/width by using relative coordinates for the second corner: rect((0, 0), (rel: (width, height))
.
Using
interpolate
to position something part way between two elements
You can use anchor coordinates and interpolation coordinates, they should work the same way as tikz's versions. (section 4.9)
Labeling above edges, in tikz:
\draw (a) -- (b) node [above] {edge label};
You can use the anchor
argument, it will move the element so that the given anchor is where the element's center is. In the example below, if anchor
is not used the content will be struck through the line as that is where it's center is. By using anchor: "bottom"
the content is effectively placed above the line. We don't currently have (we used to but it got confusing) the sugar of being able to say "above" for anchors.
line(a, b, name: "line")
content("line", [edge label], anchor: "bottom")
Nodes with self-loops
I do not know what you mean here.
Thank you for the tips!
We're definitely looking to improving our documentation but I'm not entirely sure what you mean. Are you asking for a flowchart that uses relative positioning or a flowchart that explains relative positioning? The former makes more sense...
Sorry, I should've been more specific. I mean a flowchart that uses relative positioning (among other pieces necessary for good flowcharts). The manual is good, but I think users like myself could get started more quickly if there were examples similar to this one, this one, or this one
By nodes with self-loops, I mean something the edge for SC_n != 0
in the second image.
Flowcharts should probably be drawn using Fletcher: https://github.com/Jollywatt/typst-fletcher. It uses CeTZ as a backend so we could include an example in the gallery.
Fletcher looks great, thanks for the tip. It seems like exactly what I need.
I am both new to typst and cetz. I think a flowchart example showing the ins and outs of relative positioning could be quite helpful to new users, such as myself. I've figued out basic relative positioning using
Some other things I don't know how to do yet, but would be useful and also fit in the same example:
node[fit=(a) (b)]
a.top + a.left == a.top_left?
interpolate
to position something part way between two elements\draw (a) -- (b) node [above] {edge label};
The tree function/example is very cool, but I think many flowcharts tend to have cycles and cannot be expressed as trees.