Is there a way to find what values are accepted on the RHS of a show rule?

For example, for heading, we at least have:

#show heading: set align(...)
#show heading: set text(...)
#show heading: set block(...)

Other than align(), text(), and block() what other aspects of heading can be customized on the right hand side of its show rule?

Is the only way to find this out at the moment reading Typst’s source code?

Thanks in advance.

When writing #show heading: set elem(...) you are changing the default values for elem while building a heading. This is quite general and works for all kinds of elements so it wouldn’t make sense to make a list.

For example you can change the stroke of box elements that appear in headings:

#show heading: set box(stroke: red)
= Heading with a #box[box]

image

Now the three examples you gave are actually rather special:

  • align is special because you generally don’t have to put explicit align elements in your content: blocks automatically behave as if wrapped in an align element, and paragraphs also use this setting to align lines accordingly.

  • text is special because the text function doesn’t insert a text element: it only changes the default settings as if you did #set text(...). The text elements themselves are inserted when you actually insert text. For example #text(red, strong[x]) is equivalent to

    #set text(red)
    #strong([x])
    

    The real text element is the [x] inside of the strong element.

  • block is a bit special because the heading (like any block-level element) is automatically put in a block: you don’t see it in your source code like the #box call in the example above.

I think these might be the most special cases.

1 Like

I think the implied question here is: what elements are contained/in effect for certain more complex elements. heading/block (e.g. for spacing) is a classic one, but others may be less obvious. For example, you used to be able to show bibliography: set grid (for certain bibliography styles). Relevant question:

Relevant issue: Add default typst implementation code where possible · Issue #5095 · typst/typst · GitHub

3 Likes