Skip to content

scope-dependent default settings #67

@tomeichlersmith

Description

@tomeichlersmith

Image

I think the most elegant solution would be to wait until after user-defined element functions are available in Typst, making it possible to use set rules directly. I believe this is related to user-defined types typst/typst#147 although I am unfamiliar with the details.

A work around that folks can use (or could be implemented into zero) is to avoid state and use let and with to have local copies of functions. But that is more annoying for the nested configuration (like round) where I need to repeat the sub-parameters that aren't changing to ensure they aren't lost.

Image

Of course, another solution is to "reset" the state at the end of the scope (is there a way to do this automatically? I don't think so) or use some combination of global-state (for document-wide default parameters) and local function copies (for parameters that change within the document).

I just want to say thank you for this great package. I understand that this particular issue is low priority - I only need to regulary change round: (precision: N) because I am passing float to num so I can both present the number to the reader and use it later to calculate the answer to the practice problem. I'm mainly making this issue so that whenever Typst gets user-defined types and you begin refactoring this package, I'd request that you check if the global state could just be replaced by using Typst-native set rules (maybe by having your num type conform to some "element-function" requirements).

Metadata

Metadata

Assignees

No one assigned

    Labels

    waiting for typesNeeds user-defined types in order to be approached.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions