Skip to content

Move header-includes earlier in Typst template? #9996

Closed
@gordonwoodhull

Description

@gordonwoodhull

Currently header-includes in default.typst are included after

#show: doc => conf(
 // ...
)

They are also directly before include-before:

$for(header-includes)$
$header-includes$
$endfor$
$for(include-before)$
$include-before$
$endfor$

causing these two kinds of include to have the same effect.

Typst doesn't really have "headers", but I argue it would be more more consistent with the HTML behavior to move header-includes before the show rule.

Currently, attempting to set the page color or background in header-includes will cause the title and abstract to be rendered on a default black-on-white page, followed by a page break, before the rest of the content is rendered with the desired page settings.

Here is an example:

---
title: header-includes is too late in Typst template
abstract: |
  The title and abstract will be printed in black on a white page,
  and the rest of the content will be printed in white on a navy page.
header-includes: |
  ```{=typst}
  #set page(fill: navy)
  #set text(fill: white)
  ```
---

# Text on a new page

Because we did

```typst
#set page(fill: navy)
```

after

```typst
#show: doc => conf(
 // ...
)
```

we started a new page with the new background color.

Happy to open a pull request with this change, but I figured I'd open a issue to discuss first.

cc @cscheid

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions