How do I reference plain text with tags to be used later in the document?

Good day!

I’ve been using Typst for the past couple weeks for creating template reports and have been loving it since!

I’m trying to tackle a scenario where I have a text listed in a table, and I want that exact text to be referenced below, perhaps as a heading or text. Below is an example code of what I am trying to achieve.

The below @tab:SimulationsPerformed describes the scenarios run as per the requirements:
#figure(
  caption: "Simulations performed",
  table(
    columns:(15%,35%,50%), 
    table.header([*CASE*],[*VALUES*],[*REMARKS*]),
    [A.1 <0.9Case>],[0.9],[All units in operation],
    [A.2],[1],[All units in operation],
    [A.3],[1.1],[All units in operation],
    )
  )<tab:SimulationsPerformed>

As per @0.9Case, blah blah blah.
Or I want a heading from the referenced text.
=== @0.9Case

Hope you case see here from the example that, I want the text “A.1” to be referenceable as text or to be part of a heading.
Currently with the above example, I’m getting an error at the referencing point as “cannot reference text”.

I’ve checked the Typst documentation and it seems like only headings, equations, etc. can be referenced, and that too by the heading/eqn. number?

I would appreciate any inputs to help out here.

Thank you in advance!

1 Like

Hi there! In the documentation it also says

To create a custom referenceable element like a theorem, you can create a figure of a custom kind and write a show rule for it. In the future, there might be a more direct way to define a custom referenceable element.

So instead of [A.1] <0.9Case> you can write #figure(kind: "table", supplement: "value")[A.1] <0.9Case>]. The kind is important for the counting. Image, table, heading are examples for pre-implemented kinds I think. The supplement is the text that is displayed at the reference. In my example it would say value 1, value 2, and so on.
If you would like to have just the value shown as text, you could use the link function:

As per #link(<0.9Case>)[0.9], blah blah blah.
Or I want a heading from the referenced text.
=== #link(<0.9Case>)[0.9]

If you have further questions don’t hesitate to ask again :slight_smile: