Quarto typst template: subtitle not showing and headings not changing format

52 views Asked by At

I am trying to design a custom quarto typst template to align with my corporate style guide. However, I am trying to include a subtitle which is not showing and the headings do not change with the instructions I have given.

This is what I have tried so far.

#let article(
  title: none,
  subtitle: none,
  authors: none,
  date: none,
  abstract: none,
  cols: 1,
  margin: (left: 2cm, right: 1.5cm, top: 1.5cm, bottom: 1.5cm),
  paper: "a4",
  lang: "ca",
  region: "ES",
  font: ("Noticia Text"),
  sansfont: ("Roboto"),
  fontsize: 11pt,
  sectionnumbering: none,
  toc: false,
  doc,
) = {
  set page(
    paper: paper,
    margin: margin,
    numbering: "1",
  )
  set par(justify: false)
  set text(lang: lang,
           region: region,
           font: font,
           size: fontsize)
  set heading(numbering: sectionnumbering)

  if title != none {
    align(left)[#block()[
      #text(font: "Roboto", weight: "bold", size: 33pt)[#title]
    ]]
  }
  if subtitle != none {
    align(left)[#block()[
      #text(font: "Roboto", weight: "regular", size: 20pt)[#subtitle]
    ]]
  }
  if authors != none {
    let count = authors.len()
    let ncols = calc.min(count, 3)
    grid(
      columns: (1fr,) * ncols,
      row-gutter: 1.5em,
      ..authors.map(author =>
          align(left)[
            #author.name \
            #author.affiliation \
            #author.email
          ]
      )
    )
  }

  if date != none {
    align(center)[#block(inset: 1em)[
      #date
    ]]
  }

  if abstract != none {
    block(inset: 2em)[
    #text(weight: "semibold")[Abstract] #h(1em) #abstract
    ]
  }

  if toc {
    block(above: 0em, below: 2em)[
    #outline(
      title: auto,
      depth: none
    );
    ]
  }

  if cols == 1 {
    doc
  } else {
    columns(cols, doc)
  }
  
  
  
// Configure headings.
  set heading(numbering: "1.1.1.")
  show heading: it => locate(loc => {
    // Find out the final number of the heading counter.
    let levels = counter(heading).at(loc)
    let deepest = if levels != () {
      levels.last()
    } else {
      1
    }
    if it.level == 1 [
      #set align(left)
      #set text(18pt, font: "Roboto")
      #v(24pt, weak: true)
      #if it.numbering != none {
        numbering("1.", deepest)
        h(7pt, weak: true)
      }
      #it.body
      #v(18pt, weak: true)
    ] else if it.level == 2 [
      // Second-level headings are run-ins.
      set align(left)
      #set text(14pt, font: "Roboto")
      #v(24pt, weak: true)
      #if it.numbering != none {
        numbering("1.", deepest)
        h(7pt, weak: true)
      }
      #it.body
      #v(12pt, weak: true)
    ] else [
      // Third level headings are run-ins too, but different.
      #if it.level == 3 [
      #set align(left)
      #set text(14pt, font: "Roboto")
      #if it.numbering != none {
        numbering("1.", deepest)
        h(7pt, weak: true)
      }
      #it.body
      #v(10pt, weak: true)
      ]{

      _#(it.body):_
    ]
  })

  
  
  
 

}

This is my template text

---
title: "Format de prova"
subtitle: "Subtítol"
authors: "Senyor Autor, Senyora Autora"
format:
  ivalua_informe-typst: default
---


Això és un format corporatiu per Typst.

# Introduction

*TODO* Create an example file that demonstrates the formatting and features of your format.

## More Information

You can learn more about creating custom Typst templates here: 

### Even more info

<https://quarto.org/docs/prerelease/1.4/typst.html#custom-formats>

This is what it looks like. You can see that the subtitle does not show up and the headings are not in the Roboto font.

Rendered document

0

There are 0 answers