Good day, everyone.
I’m learning how to make a template on Typst, but for some reason I can’t change the space below the #title() inside the template function. However, when I place the same code outside the #let it works. It seems to be specifically the set block function, as the set text renders normally.
// -- Configure title --
// This one doesn't work
show title: set block(
below: line-height * 20
)
// This one does
show title: set text(
size: font-size + 3pt,
weight: "regular"
)
Can someone help me?
Full code
#let dull(
// -- Metadata --
title: none,
subtitle: none,
author: none,
date: none,
// -- Document --
paper-size: "a4",
language: "pt",
// -- Font --
body-font: "Tex Gyre Termes",
raw-font: "JetBrains Mono",
font-size: 11pt,
leading-ratio: 1.75,
// -- Colors --
background-color: rgb("#ffffff"),
foreground-color: rgb("000000"),
// -- Body --
body,
) = {
// -- Type scale --
let title-size = font-size + 3pt
let heading-size = font-size + 2pt
let subheading-size = font-size + 1pt
// ── Baseline grid --
let line-height = font-size * leading-ratio
// -- Spatial system --
let margin-vertical = line-height * 4
let margin-horizontal = line-height * 7
// ── Configure metadata --
set document(title: title, date: date)
if author != none {
set document(author: author)
}
// -- Configure text --
set text(
font: body-font,
size: font-size,
fill: foreground-color,
ligatures: true,
discretionary-ligatures: true,
lang: language
)
show raw: set text(font: raw-font)
// -- Configure paragraph --
set par(
leading: line-height - font-size,
spacing: line-height,
justify: true,
justification-limits: (
spacing: (
min: 100% * 2 / 3,
max: 100% * 3 / 2,
),
tracking: (
min: -0.01em,
max: 0.01em,
),
),
)
// -- Configure page --
set page(
paper: paper-size,
fill: background-color,
margin: (
x: margin-horizontal,
y: margin-vertical
)
)
// -- Configure title --
show title: set block(
below: line-height * 20
)
show title: set text(
size: font-size + 3pt,
weight: "regular"
)
// -- Configure headings --
show heading: set text(
font: body-font,
weight: "regular",
fill: foreground-color
)
show heading: set block(
above: line-height * 4/3,
below: line-height * 1/2
)
show heading.where(level: 1): set text(
size: heading-size
)
show heading.where(level: 2): set text(
size: subheading-size
)
show heading.where(level: 3): set text(
size: font-size,
weight: "bold"
)
// -- Body --
body
}
#show: dull.with(
title: "This is a test",
author: "Paprika"
)
#title()
#lorem(50)
#lorem(75)
= Título 1
#lorem(50)
== Título 2
#lorem(50)
=== Título 3
#lorem(50)