pandoc icon indicating copy to clipboard operation
pandoc copied to clipboard

Improving the Typst base template to match equivalent PDF options

Open christopherkenny opened this issue 7 months ago • 1 comments

Proposed Improvement:

The default template for Typst currently supports many fewer base features than the PDF template. This, of course makes sense, as Typst is much newer. Many features included in PDF templates could be added to the Typst base template without substantial amounts of code. Below, I've shortened a list from a discussion in Quarto:

Title & Author

  • thanks: To the call to #title, we could add:
#if thanks != none {
    footnote(thanks, numbering: "*")
    counter(footnote).update(n => n - 1)
}

Fonts

  • linestretch: 1 = single spaced, 2 = double spaced, and so on
set par(leading: linestretch * 0.65em)
  • mathfont:
#show math.equation: set text(font: mathfont)
  • codefont:
#show raw: set text(font: codefont)
  • linkcolor: Each color setting below require converting content to string or running a .replace("\\#", "#") on linkcolor due to pandoc's escaping
#show link: set text(fill: rgb(linkcolor))
  • filecolor, urlcolor: these have to be handled together as far as I know
#show link: this => {
    if type(this.dest) != label {
        text(this, fill: rgb(filecolor))
    }
}
  • citecolor:
#show ref: this => {
    text(this, fill: rgb(citecolor))
}
  • toccolor
#show link: this => {
    if type(this.dest) == label {
        text(this, fill: rgb(to-string(filecolor)))
    }
}

Metadata

  • keywords
#set document(keywords: keywords)
  • title-meta
#set document(title: title-meta)
  • author-meta
#set document(author: author-meta)

I'm happy to PR in any of these, if you are interested.

Alternatives:

  • This started as a downstream discussion for Quarto (https://github.com/quarto-dev/quarto-cli/discussions/10223), but it was suggested to look here for editing template-specific pieces.

  • These could also be in custom templates, of course. However, at least some set of these options are probably good to have in the default template.

christopherkenny avatar Jul 05 '24 21:07 christopherkenny