From d8522a98c6a1db7a4b240c4d36cfadb59e22304e Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 20 Jan 2026 17:46:35 +0100 Subject: feat(typst): callouts also fix package hierarchy --- typst/README.md | 33 +++++++++++++++-- typst/callout/1.0.0/lib.typ | 70 ++++++++++++++++++++++++++++++++++++ typst/callout/1.0.0/typst.toml | 7 ++++ typst/template.typ | 78 ---------------------------------------- typst/template/1.0.0/lib.typ | 79 +++++++++++++++++++++++++++++++++++++++++ typst/template/1.0.0/typst.toml | 7 ++++ 6 files changed, 193 insertions(+), 81 deletions(-) create mode 100644 typst/callout/1.0.0/lib.typ create mode 100644 typst/callout/1.0.0/typst.toml delete mode 100644 typst/template.typ create mode 100644 typst/template/1.0.0/lib.typ create mode 100644 typst/template/1.0.0/typst.toml diff --git a/typst/README.md b/typst/README.md index 2f8dd4c..531a3e9 100644 --- a/typst/README.md +++ b/typst/README.md @@ -3,16 +3,18 @@ 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` +## `template` -This template requires: +This package 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. +It is the template that I use everywhere. +It can be freely used. + Import it and load it with: ```typ // import the script from the local repo @@ -27,3 +29,28 @@ Import it and load it with: page_title: "Page title :D", ) ``` + +## `callout` + +This package contains my callouts. + +List of callouts: +- `warning` +- `defn` (definition) +- `props` (proposition) +- `thm` (théorème, which is theorem in French) + +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/callout:1.0.0": * +``` + +You can use any callouts with +```typ +#defn[ + Let $f$ a function where: + $ forall x in RR, f(x) = x^2 $ +] +``` diff --git a/typst/callout/1.0.0/lib.typ b/typst/callout/1.0.0/lib.typ new file mode 100644 index 0000000..5add04a --- /dev/null +++ b/typst/callout/1.0.0/lib.typ @@ -0,0 +1,70 @@ +#let emptyblock((fontcolor, bgcolor), content) = { + set par( + leading: 0.75em, + first-line-indent: 0em, + spacing: 1.3em, + ) + set text(fill: fontcolor) + block( + width: 100%, + inset: 1.5em, + radius: 0.5em, + breakable: false, + fill: bgcolor, + content + ) +} + +#let callout(icon, title, title_content, colors, content) = { + emptyblock(colors)[ + #text(size: 1.25em)[#icon~ #strong(title)] + + #content + ] +} + +#let warning(body) = { + callout( + emoji.warning, + "Attention", + title, + (oklch(25%, 35%, 52.55deg), oklch(68.9%, 44%, 52.55deg, 15%)), + body, + ) +} + +#let solution(body) = { + callout(emoji.checkmark.box, "Solution", + (rgb("#2AA63D"), rgb("#DBFCE7"), rgb("#7AF0A8")), + body) +} + +#let defn(body) = { + callout( + $Delta$, + "Définition", + title, + (oklch(20%, 20%, 247deg), oklch(75%, 25%, 247deg, 40%)), + body, + ) +} + +#let props(body) = { + callout( + $Pi$, + "Proposition", + title, + (oklch(20%, 20%, 247deg), oklch(85%, 10%, 247deg, 50%)), + body, + ) +} + +#let thm(body) = { + callout( + $Tau$, + "Théorème", + title, + (oklch(20%, 20%, 220deg), oklch(80%, 25%, 220deg, 40%)), + body, + ) +} diff --git a/typst/callout/1.0.0/typst.toml b/typst/callout/1.0.0/typst.toml new file mode 100644 index 0000000..be0b876 --- /dev/null +++ b/typst/callout/1.0.0/typst.toml @@ -0,0 +1,7 @@ +[package] +name = "callout" +version = "1.0.0" +entrypoint = "lib.typ" +authors = ["Anhgelus Morhtuuzh"] +license = "MIT" +description = "My callouts" diff --git a/typst/template.typ b/typst/template.typ deleted file mode 100644 index 5de1617..0000000 --- a/typst/template.typ +++ /dev/null @@ -1,78 +0,0 @@ -#let doc(authors: (), page_title: [], doc) = { - 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 -} diff --git a/typst/template/1.0.0/lib.typ b/typst/template/1.0.0/lib.typ new file mode 100644 index 0000000..be0d931 --- /dev/null +++ b/typst/template/1.0.0/lib.typ @@ -0,0 +1,79 @@ +#let doc(authors: (), page_title: [], doc) = { + // style + set text( + font: "Inter", + size: 11pt, + ) + set par( + leading: 1em, + //first-line-indent: (amount: 1em, all: true), + 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: 3.5cm), + ) + + 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 +} diff --git a/typst/template/1.0.0/typst.toml b/typst/template/1.0.0/typst.toml new file mode 100644 index 0000000..11b0f63 --- /dev/null +++ b/typst/template/1.0.0/typst.toml @@ -0,0 +1,7 @@ +[package] +name = "template" +version = "1.0.0" +entrypoint = "lib.typ" +authors = ["Anhgelus Morhtuuzh"] +license = "MIT" +description = "My custom template" -- cgit v1.2.3