Skip to content

Support multiple templates with typst init and typst.toml #7575

@jassielof

Description

@jassielof

Description

Possibility to specify the template to initialize a template package with.

A possibility to define multiple template in typst.toml would be like:

# The default
[template]
path = "template"
entrypoint = "main.typ"        
thumbnail = "thumbnail.png"

# The variants
[[template.variants]]
name = "student"
entrypoint = "main.typ"        
thumbnail = "thumbnail.png"
description = "Student format (default)" # A variant could maybe also be used to point to the default?

[[template.variants]]
name = "professional"
entrypoint = "professional.typ"
thumbnail = "thumbnails/professional.png"
description = "Professional format"

And that could be used with:

# Default template
typst init "<the template>" 

# Specifying a custom variant of the template
typst init "<the template package to use>" --variant "<the specific template to initialize from>".

# Listing the possible variants?
typst init "<the template>" --list-variants
# Outputs the list of each name and its descriptions, as well which one might be the default?

Use Case

  • Templates with shared styling/functionality
  • Avoid creating multiple template packages and bundling the same functions on each one
  • Avoid bundling a lot of templates for the user to choose (or bundling none expecting the user to initialize it from scratch)
  • Have the option for different template styles, for example:
    • APA has 2 main formats, student and professional
    • ACM (I'm trying to port the whole document class, and it shares a lot of functionalities and styles, and it would help avoiding creating templates for each format)
    • LaTeX standard/KOMA-script, both also share similar code, and it would help having an option to specify a default or select which template to initialize it with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions