typst icon indicating copy to clipboard operation
typst copied to clipboard

Handle auto returned from supplement function

Open szdytom opened this issue 2 years ago • 2 comments

Description

For example, wants to set the default supplement of math.equation to "Formula" rather than "Equation", this is my approach:

set ref(supplement: it => {
	if it.func() == math.equation {
		"Formula"
	} else {
		auto
	}
})

It auto returned by the function is directly outputed into the PDF rather than using the default supplement. Have i misunderstood the auto keyword?

Reproduction URL

No response

Operating system

Windows

Typst version

  • [X] I am using the latest version of Typst

szdytom avatar May 07 '23 14:05 szdytom

The auto keyword only has meaning where it is given, so it's likely that this fallback behavior wasn't implemented. Doesn't sound that bad of an idea though. But you could have something like it.func() == table to default to Table, and otherwise default to Figure.

PgBiel avatar May 07 '23 17:05 PgBiel

If you already know what the auto indicates (may browser code with Smart:Auto), you can use it instead. For example, ref(supplement: auto) is equal to ref(supplement: it => {it.supplement})

Tiger3018 avatar May 10 '24 18:05 Tiger3018

The original use case should be covered by #set math.equation(supplement: [Formula])

In general, supplement functions will likely be removed since they are now better covered by show-set rules.

laurmaedje avatar Jul 15 '24 19:07 laurmaedje