Skip to content

Show-set rule is not able to set all fields (synthesized ones) #2459

Closed

Description

@padix-key

Description

It is not possible to set some settable figure parameters via a show-set rule. Take the following example that aims to remove the supplement from a figure caption:

//#show figure: set figure(supplement: none) // DOES NOT WORK

//#set figure(supplement: none) // DOES WORK

#figure(
  [],
  caption: [
    This is a caption.
  ],
  //supplement: none // DOES WORK
)

A possible use case is to make the supplement bold for figures but not for tables.

I found this behavior for the supplement and numbering parameters, but interestingly not for gap.

Reproduction URL

No response

Operating system

Linux

Typst version

  • I am using the latest version of Typst

Activity

  1. added
    bug
    on Oct 21, 2023
  2. laurmaedje commented on Oct 21, 2023

    @laurmaedje
    Member

    More generally show-set on the same element does not work for synthesized fields (which aren't really a user-facing concept). I intend to fix this alongside other styling bugs like recursive show rule crashes.

  3. added
    styling
    on Oct 22, 2023
  4. changed the title [-]Show-set rule is not able to set set some figure parameters[/-] [+]Show-set rule is not able to set all fields (synthesized ones)[/+] on Nov 14, 2023
  5. SeSodesa commented on Nov 23, 2023

    @SeSodesa
    Contributor

    Possibly related, trying to set supplement via just a normal set rule does not work as expected. The code

    set figure(
      numbering : it => text(weight:"bold", fill:purple)[#it],
      supplement : it => text(weight:"bold", fill:purple)[#it],
    )

    is supposed to set figure supplements and numbers to have the same weight and color. The numbering setting works as expected, but the supplement setting ends up replacing the supplement with the figure itself. I would expect that it in this context refers to the supplement and not to the figure.

  6. laxsjo commented on Dec 13, 2023

    @laxsjo

    @SeSodesa Pretty sure that example is working as intended. You're just overiding the values of the numbering and supplement fields with the functions you wrote. It just happens that both those fields can take functions.

    numbering happens to take an argument that is usefull,
    but functions in supplement take the figure body element as an argument (I assume to be able to adjust the supplement based on the figure content)
    Here is the documentaiton for numbering: https://typst.app/docs/reference/model/figure/#parameters-supplement

    I agree that it would be very usefull for there to be some mechanic to "set" a field by updating whatever value was set previously.

  7. Dherse commented on Jan 26, 2024

    @Dherse
    Contributor

    @laurmaedje Do we consider this:

    • a bug of the content rework
    • a missing feature from styling and the #[elem] macro?
  8. laurmaedje commented on Jan 26, 2024

    @laurmaedje
    Member

    The bug is longer-standing than the content rework. It falls directly under styling rework and is, in fact, what I am working on right now, as we speak (alongside #351).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugstyling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions