First commit

This commit is contained in:
Lyes Saadi 2026-03-26 18:39:28 +01:00
commit 8808f32ece
Signed by: lyes
GPG key ID: 55A1D803917CF39A

109
lib.typ Normal file
View file

@ -0,0 +1,109 @@
#let signature(at: none, date: none, ..signatories) = {
let answer = [ _Fait à_ ]
if at == none {
answer += box(width: 30%, stroke: (bottom: (thickness: 0.5pt, dash: "dotted")), none)
} else {
answer += text(weight: "bold", at)
}
answer += [, _le_ ]
if date == none {
answer += box(width: 30%, stroke: (bottom: (thickness: 0.5pt, dash: "dotted")), none)
} else {
answer += text(weight: "bold", date.display("[day]/[month]/[year]"))
}
let grid-construction(s) = text(weight: "bold", s.at(0)) + "\n" + text(style: "italic", s.at(1))
let g = signatories.pos().map(grid-construction)
answer += grid(columns: (50%, 50%), rows: (100pt), ..g)
block(answer, breakable: false)
}
#let template(body, title: "Title", subtitle: "Subtitle", logo: none, watermark: "", size: 10pt) = {
// Apparence du document
set page(columns: 2, margin: 1.5cm, numbering: "1/1")
set page(background: rotate(-55deg, text(size: 50pt, rgb(0, 0, 0, 30))[*#watermark*]))
set text(font: "New Computer Modern", lang: "fr", size: size)
set par(justify: true, first-line-indent: (amount: 1em, all: true))
set list(marker: sym.bar.h)
// Style des titres
let premier(.., last, format: "I") = numbering(format, last) + if last == 1 { super[er] }
set heading(numbering: "I.1.I.", supplement: [])
show heading.where(level: 1): it => [
#align(center, block[
#if it.numbering != none [
Titre #context counter(heading).display(premier.with(format: "I"))
]
#text(size: 0.9em, it.body)
#line(length: 3cm)
#v(1em)
])
]
let articlecounter = counter("article")
show heading.where(level: 2): it => {
articlecounter.step()
align(center, block[
Article #context articlecounter.display(premier.with(format: "1")) #sym.bar.h #text(size: 0.9em, style: "italic", it.body)
])
}
show heading.where(level: 3): it => [
#context counter(heading).display(premier.with(format: "I")) #sym.bar.h #if it.body != [] { text(size: 0.9em, style: "italic", [#it.body.]) }
]
show ref: it => {
let el = it.element
let article = articlecounter.at(el.location()).at(0, default: none)
let par = counter(heading).at(el.location()).at(2, default: none)
if el != none and el.func() == heading and article != none {
// Override heading references.
if (par == none) {
link(el.location(), numbering(
"1",
article + 1,
))
} else {
link(el.location(), numbering(
"1.I",
article,
par
))
}
} else {
// Other references as usual.
it
}
}
// Début du document
place(
top + center,
scope: "parent",
float: true,
align(center)[
#if logo != none {
image(logo, height: 5em)
}
#text(size: 2.5em, weight: "extrabold")[#title]
#text(size: 1.5em)[#subtitle]
#v(1cm)
],
)
body
}