Hello,
I’m struggling to define templates for my different documents types, such that they inherit from the definition of a more general template.
In concrete term, what I want is to be able to have one general template document doc-template.typ such as:
#let template(
doc_title: [],
author: "",
doc
) = [
// Some template rules
...
]
One other template document my-doc-template, that inherits from the previous one, but fixing some of its arguments and adding new rules:
#let my_template(
doc_title: [],
doc
) = [
// Definition of the template inheritance
#show template.with(
doc_title: doc_title,
author: "DreamerPhi",
)
// Definition of the new template rules
...
]
And finally being able to use this second template in a document my-document.typ:
#import "my-doc-template.typ": my_template
#show my_template.with(
doc_title: [My document title],
)
Thanks in advance!
Hi. As far as I know, it is difficult to arbitrarily adjust the behavior of the inner template. For example, if a fixed font size/color is set in the inner template.
// template.typ
#let template(
doc_title: [],
author: "",
doc
) = [
#set text(fill: blue)
Title: *#doc_title* \
Author: *#author* \
#doc
]
// my-doc-template.typ
// import "template.typ": *
#let my_template(
doc_title: [],
doc
) = [
// new rules (not working)
#set text(fill: maroon)
#show: template.with(
doc_title: doc_title,
author: "DreamerPhi"
)
#doc
]
// main.typ
// import "my-doc-template.typ": my_template
#show: my_template.with(
doc_title: [My document title],
)
Content
maucejo
September 26, 2026, 9:28am
3
You may have a look at community-cnam-thesis which is built on top of bookly.
ensko
September 26, 2026, 10:00am
4
Not necessarily a thread with concrete answers, but a lot of relevant discussion:
TL;DR: in my experience it is difficult or impossible to “tweak” Typst templates to change some layout policies without copying and modifying its source code. Is it just that we are collectively bad at writing templates, or a fundamental design flaw or missing feature in the Typst language?
Context
I’ve been using Typst for various documents for a few months now (free-form documents, talk slides, more structured document looking like math research papers). My experience is that “packages” work …