cetz-package / cetz

CeTZ: ein Typst Zeichenpaket - A library for drawing stuff with Typst.
https://cetz-package.github.io
GNU Lesser General Public License v3.0
733 stars 34 forks source link

[proposal] Syntax for the previous element #606

Open tapyu opened 1 month ago

tapyu commented 1 month ago

Inspired by () for the previous coordinate, I propose anything equivalent to refer to a previous element. For instance:

line((y: 10), (rel: (x: 10)), mark: (end: ">"))
line("{}.5%", (rel: (y: 10)), mark: (end: ">"))

where {} would refer to the last element (i.e., the line).

Motivation

Although name: "my-name" would also serve for this purpose, I frequently find myself in a situation where I want to refer to the previous element as an starting point for the next element, and nothing more. Creating a label for this purpose seems an overkill and makes the syntax unnecessarily lengthy. I do believe that this proposal would make the typst syntax even more convenient. Regarding using "{}" or something else, it is opened to discussions.