From b6677f5d15ea05b3c7410c8a9cff01f5e426fd39 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Mon, 12 Jan 2026 20:04:13 +0100 Subject: feat(typst): template file --- typst/README.md | 29 +++++++++++++ typst/template.typ | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 typst/README.md create mode 100644 typst/template.typ (limited to 'typst') diff --git a/typst/README.md b/typst/README.md new file mode 100644 index 0000000..2f8dd4c --- /dev/null +++ b/typst/README.md @@ -0,0 +1,29 @@ +# typst scripts + +The version of these scripts will always be `1.0.0`, because using anything else looks like to be too complicated for +anything. + +## `template.typ` + +This template requires: +- `Inter` as the sans-serif font; +- `PT Astra Serif` as the serif font; +- `FiraCode Nerd Font Mono` as the monospace font. + +These can be freely used. +I may add an option to modify this. + +Import it and load it with: +```typ +// import the script from the local repo +// if you have modified the repo name, replace `@local` with their name +#import "@local/template:1.0.0": * + +// initialize template +#show: doc.with( + authors: ( + (name: "Your Name", affiliation: "Your affiliation", email: "Your email"), + ), + page_title: "Page title :D", +) +``` diff --git a/typst/template.typ b/typst/template.typ new file mode 100644 index 0000000..4d7bc4c --- /dev/null +++ b/typst/template.typ @@ -0,0 +1,124 @@ +#let doc(authors: (), page_title: [], doc) = { + // style + set text( + font: "Inter", + size: 11pt, + ) + set par( + leading: 1em, + first-line-indent: 1em, + spacing: 2em, + ) + set heading(numbering: "1.") + + set page( + header: align( + right + horizon, + // Retrieve the document + // element's title property. + context document.title, + ), + numbering: "1", + margin: (x: 2.85cm), + ) + + show heading: set par(leading: 0.75em) + show heading: set text(font: "PT Astra Serif") + show heading.where(level: 1): set block(below: 1em) + show heading.where(level: 1): set text(size: 1.2em) + show heading.where(level: 1, numbering: "1."): it => { + pagebreak(weak: true) + it + } + show heading.where(level: 2): set block(above: 3em, below: 1em) + show heading.where(level: 2): set text(size: 1.1em) + + show title: set text(size: 1.25em, font: "PT Astra Serif") + show title: set align(center) + show title: set block(above: 5em, below: 1em) + show title: set par(leading: 0.5em) + + show enum: set par(leading: 0.9em) + show list: set par(leading: 0.9em) + + show raw: set text(font: "FiraCode Nerd Font Mono") + show raw.where(block: false): set text(weight: 500, size: 1.1em) + + // style + set text( + font: "Inter", + size: 11pt, + ) + set par( + leading: 1em, + first-line-indent: 1em, + spacing: 2em, + ) + set heading(numbering: "1.") + + set page( + header: align( + right + horizon, + // Retrieve the document + // element's title property. + context { + emph([ + #document.title - #authors.first().name + ]) + } + ), + numbering: "1", + margin: (x: 2.85cm), + ) + + show heading: set par(leading: 0.75em) + show heading: set text(font: "PT Astra Serif") + show heading.where(level: 1): set block(below: 1em) + show heading.where(level: 1): set text(size: 1.2em) + show heading.where(level: 2): set block(above: 3em, below: 1em) + show heading.where(level: 2): set text(size: 1.1em) + + show title: set text(size: 1.25em, font: "PT Astra Serif") + show title: set align(center) + show title: set block(above: 5em, below: 1em) + show title: set par(leading: 0.5em) + show outline: it => { + it + pagebreak() + } + + show enum: set par(leading: 0.9em) + show list: set par(leading: 0.9em) + + show raw: set text(font: "FiraCode Nerd Font Mono") + show raw.where(block: false): set text(weight: 500, size: 1.1em) + set document(title: page_title) + let ncols = calc.min(authors.len(), 3) + + title() + + block(below: 5em, context { + grid( + columns: (1fr,) * ncols, + gutter: 2em, + align: center, + ..authors.map(author => { + par(leading: 0.75em)[ + #author.name \ + #author.affiliation \ + #link("mailto:" + author.email) + ] + }) + ) + }) + + + outline(title: "Table des matières") + + show heading.where(level: 1): it => { + pagebreak(weak: true) + it + } + + doc +} -- cgit v1.2.3