How do I include custom references to items in a table?

With many tricks, it’s possible to achieve something that would be a reasonable way to do this. You had all the elements at hand!!

Basically:

  • You need figure elements to handle your numbering for you when referencing requirements
  • We are still using the req_counter, although I’d probably replace it with counter(figure.where(kind: "req")) if that causes issues (it probably wouldn’t)
  • “invisible” figures have the unfortunate side effect of adding a block, so we can just style them to only show an empty body

Putting all that together, we generate a label for each requirement (figure), and … that’s it!

#let req_counter = counter("req")
#req_counter.update(1)
#show figure.where(kind: "req"): it => it.body // remove block
#let Req(text, priority) = {
  let no = () => req_counter.display() + req_counter.step()
  let number = () => req_counter.get().at(0)
  let req() = figure(
    kind: "req",
    supplement: "Req.",
    numbering: "1.",
  )[]
  return (
    context [#no()#req()#label("req:" + str(number()))],
    text,
    priority,
  )
}

#table(
  columns: (auto, auto, auto),
  align: (center, left, center),
  stroke: none,
  table.hline(stroke: 0.75pt, position: bottom),
  table.header([*No*], [*Requirement*], [*Priority*]),
  ..Req([A requirement on computational load], [1]),
  ..Req([A requirement on UI], [2])
)

@req:1

@req:2
1 Like