commit 940f1f64b27d117066ead5d8661c6f788646c1d4 Author: Lyes Saadi Date: Thu Jan 15 17:26:07 2026 +0100 Initial commit diff --git a/environment.typ b/environment.typ new file mode 100644 index 0000000..f05b060 --- /dev/null +++ b/environment.typ @@ -0,0 +1,69 @@ +#import "palette.typ": * + +#let envc = counter("environment") + +#let count(counter, follows) = { + let c = counter; + if c == auto { + c = envc; + } + + if type(c) == str { + c + } else if not follows { + c.step() + context c.display() + } else { + context c.display() + } +} + +#let environment(body, name: "Environment", subtitle: none, counter: auto, follows: false, boxed: true, margin: 2.5cm, scheme: light) = [ + #v(10pt) + + // #v(margin + 2pt) + + #pad(block( + width: 100% + 2*margin, + inset: (left: margin, right: margin, top: 1em, bottom: 1em), + fill: scheme.env.bg, + stroke: (top: scheme.env.stroke, bottom: scheme.env.stroke), + breakable: true, + text(fill: scheme.env.fg)[ + #place( + block( + fill: scheme.env.bg, + inset: .4em, + radius: .2em, + stroke: scheme.env.title-stroke, + )[ + #text( + name + if counter != none { " " + count(counter, follows) } + if subtitle != none { ":" }, + weight: if not follows { "bold" } else { "regular" }, + style: if follows { "italic" } else { "normal" }, + fill: scheme.env.fg + ) + #if cite != none { + subtitle + } + ], + dx: -3em, dy: -1.8em + ) + + #body + ]), + left: -margin, + right: margin) + // top: -margin - 2pt, + // bottom: -margin - 2pt) + + // #v(margin + 2pt) +] + +#let environment_(body, name: "Environment", counter: auto, follows: false, boxed: true, margin: 2.5cm, scheme: light) = { + scheme.env.insert("bg", scheme.bg) + scheme.env.insert("title-stroke", none) + scheme.env.insert("stroke", scheme.env.sub-stroke) + + environment(body, name: name, counter: counter, follows: follows, boxed: boxed, margin: margin, scheme: scheme) +} diff --git a/lib.typ b/lib.typ new file mode 100644 index 0000000..576bf19 --- /dev/null +++ b/lib.typ @@ -0,0 +1,3 @@ +#import "palette.typ": * +#import "paper.typ": paper, abstract +#import "environment.typ": environment, environment_ diff --git a/math.typ b/math.typ new file mode 100644 index 0000000..fc19e0d --- /dev/null +++ b/math.typ @@ -0,0 +1,97 @@ +#let math_shorthands = ( + ($-o$, $multimap$), + ($~=$, $tilde.equiv$), + ($(*)$, $times.o$), + ($(times)$, $times.o$), + ($(+)$, $plus.o$), + ($(plus)$, $plus.o$), + ($|=$, $tack.r.double$), + ($|-$, $tack.r$), + ($t->$, $mapsto$), + ($t-->$, $mapsto.long$), +) + +#let par = rotate(180deg, "&") +#let yo = $よ$ +#let inj = $"inj"$ + +#let lA = $overline(A)$ +#let lB = $overline(B)$ +#let lC = $overline(C)$ +#let lD = $overline(D)$ +#let lE = $overline(E)$ +#let lF = $overline(F)$ +#let lG = $overline(G)$ +#let lH = $overline(H)$ +#let lI = $overline(I)$ +#let lJ = $overline(J)$ +#let lK = $overline(K)$ +#let lL = $overline(L)$ +#let lM = $overline(M)$ +#let lN = $overline(N)$ +#let lO = $overline(O)$ +#let lP = $overline(P)$ +#let lQ = $overline(Q)$ +#let lR = $overline(R)$ +#let lS = $overline(S)$ +#let lT = $overline(T)$ +#let lU = $overline(U)$ +#let lV = $overline(V)$ +#let lW = $overline(W)$ +#let lX = $overline(X)$ +#let lY = $overline(Y)$ +#let lZ = $overline(Z)$ + +#let la = $overline(a)$ +#let lb = $overline(b)$ +#let lc = $overline(c)$ +#let ld = $overline(d)$ +#let le = $overline(e)$ +#let lf = $overline(f)$ +#let lg = $overline(g)$ +#let lh = $overline(h)$ +#let li = $overline(i)$ +#let lj = $overline(j)$ +#let lk = $overline(k)$ +#let ll = $overline(l)$ +#let lm = $overline(m)$ +#let ln = $overline(n)$ +#let lo = $overline(o)$ +#let lp = $overline(p)$ +#let lq = $overline(q)$ +#let lr = $overline(r)$ +#let ls = $overline(s)$ +#let lt = $overline(t)$ +#let lu = $overline(u)$ +#let lv = $overline(v)$ +#let lw = $overline(w)$ +#let lx = $overline(x)$ +#let ly = $overline(y)$ +#let lz = $overline(z)$ + +#let cA = math.cal("A") +#let cB = math.cal("B") +#let cC = math.cal("C") +#let cD = math.cal("D") +#let cE = math.cal("E") +#let cF = math.cal("F") +#let cG = math.cal("G") +#let cH = math.cal("H") +#let cI = math.cal("I") +#let cJ = math.cal("J") +#let cK = math.cal("K") +#let cL = math.cal("L") +#let cM = math.cal("M") +#let cN = math.cal("N") +#let cO = math.cal("O") +#let cP = math.cal("P") +#let cQ = math.cal("Q") +#let cR = math.cal("R") +#let cS = math.cal("S") +#let cT = math.cal("T") +#let cU = math.cal("U") +#let cV = math.cal("V") +#let cW = math.cal("W") +#let cX = math.cal("X") +#let cY = math.cal("Y") +#let cZ = math.cal("Z") diff --git a/palette.typ b/palette.typ new file mode 100644 index 0000000..2a16ae3 --- /dev/null +++ b/palette.typ @@ -0,0 +1,105 @@ +#let broken-stroke(paint) = (thickness: 1pt, paint: paint, dash: (array: (2em, 1em, 1em, 1em))) +#let dotted-stroke(paint) = (thickness: 1pt, paint: paint, dash: "densely-dotted") +#let fill-stroke(paint) = (thickness: 1pt, paint: paint) + +#let light = ( + bg: white, + fg: black, + title: ( + bg: rgb("eee"), + fg: black, + sub: rgb("555"), + stroke: broken-stroke(rgb("999")), + ), + env: ( + bg: rgb("eee"), + fg: black, + stroke: broken-stroke(rgb("999")), + title-stroke: fill-stroke(rgb("999")), + sub-stroke: dotted-stroke(rgb("999")), + ), +) + +#let printing = ( + bg: white, + fg: black, + title: ( + bg: white, + fg: black, + sub: rgb("555"), + stroke: broken-stroke(black), + ), + env: ( + bg: white, + fg: black, + stroke: broken-stroke(black), + title-stroke: fill-stroke(black), + sub-stroke: dotted-stroke(black), + ), +) + +#let ensps-light = ( + bg: light.bg, + fg: light.fg, + title: ( + bg: rgb("00778b"), + fg: white, + sub: rgb(255, 255, 255, 200), + img: ( + path: "static/ensps.png" + ), + stroke: broken-stroke(color.hsl(187deg, 80%, 20%)), + ), + env: light.env +) + +#let dark = ( + bg: black, + fg: white, + title: ( + bg: rgb("111"), + fg: white, + sub: rgb("aaa"), + stroke: broken-stroke(rgb("777")), + ), + env: ( + bg: rgb("111"), + fg: white, + stroke: broken-stroke(rgb("777")), + title-stroke: fill-stroke(rgb("777")), + sub-stroke: dotted-stroke(rgb("777")), + ), +) + +#let ensps-dark = ( + bg: dark.bg, + fg: dark.fg, + title: ( + bg: rgb("00778b"), + fg: white, + sub: rgb(255, 255, 255, 200), + img: ( + path: "static/ensps.png" + ), + stroke: broken-stroke(color.hsl(187deg, 80%, 20%)), + ), + env: dark.env +) + +#let night = ( + bg: rgb("#111b3b"), + fg: rgb("#f2ecbe"), + title: ( + bg: rgb("#1c113a"), + fg: rgb("#f2ecbe"), + sub: rgb("#f2ecbe"), + stroke: broken-stroke(rgb("#3a3011")), + ), + env: ( + bg: rgb("#1c113a"), + fg: rgb("#f2ecbe"), + stroke: broken-stroke(rgb("#3a3011")), + title-stroke: fill-stroke(rgb("#3a3011")), + sub-stroke: dotted-stroke(rgb("#3a3011")), + ), +) diff --git a/paper.typ b/paper.typ new file mode 100644 index 0000000..6fb359f --- /dev/null +++ b/paper.typ @@ -0,0 +1,80 @@ +#import "palette.typ": * +#import "environment.typ": * +#import "math.typ": math_shorthands +#import "@preview/quick-maths:0.2.1": shorthands + +#let header(title, author, scheme, margin) = ( + context { + let p = here().page() + + // if p >= 1 { + move(dx: - margin - 1pt, block( + width: 100% + 2*margin + 2pt, + height: margin, + stroke: scheme.title.stroke, + fill: scheme.title.bg, + )[ + #place(top + left, block(inset: 30% * margin)[#text(title, scheme.title.fg) #text("- " + author, scheme.title.sub)]) + #place(top + right, block(inset: 30% * margin, text(scheme.title.fg)[Page #p / #counter(page).final().at(0)])) + ]) + // } + } +) + +#let paper( + body, + title: "Titre", + subtitle: none, + author: "Lyes Saadi", + scheme: light, + margin: 2.5cm, +) = [ + #set document(title: title, author: author) + #set page(fill: scheme.bg, footer: header(title, author, scheme, margin), margin: margin) + #set text(fill: scheme.fg, font: "New Computer Modern") + #set table(stroke: scheme.fg) + #set heading(numbering: "I.1 -") + + #show heading: it => [ + #block[ + #place(text("#", size: 0.8em), dx: -0.8em) + #it + ] + ] + + #show heading.where(level: 1): it => [ + #move(block( + text(it, scheme.title.fg), + width: 100% + 2*margin, + inset: (left: margin, right: margin, top: 1em, bottom: 1em), + fill: scheme.title.bg, + stroke: (top: scheme.title.stroke, bottom: scheme.title.stroke), + ), dx: -margin) + ] + + #show : set heading(numbering: none) + + #show: shorthands.with(..math_shorthands) + + #move(block( + [ + #if "img" in scheme.title.keys() and scheme.title.img != none { + place(top + right, image(scheme.title.img.path, height: margin), dx: margin, dy: -margin) + } + #align(center, text(size: 3em, title, fill: scheme.title.fg)) + #align(center, text(size: 2em, fill: scheme.title.sub, subtitle)) + #align(center, text(size: 1.5em, fill: scheme.title.sub, author)) + ], + fill: scheme.title.bg, + inset: margin, + height: auto, + width: 100% + 2 * margin, + stroke: (bottom: scheme.title.stroke), + ), dx: -margin, dy: -margin) + + #body +] + +#let abstract(body, name: [Abstract.], margin: 2.5cm) = { + align(center, move(dy: -margin/2, block(width: 75%, par(justify: true)[#text(name, weight: "bold") #text(style: "italic", body)]))) +} diff --git a/state.typ b/state.typ new file mode 100644 index 0000000..93e43f1 --- /dev/null +++ b/state.typ @@ -0,0 +1,6 @@ +#import "palette.typ": * + +#let template = ( + margin: 0, + scheme: light, +) diff --git a/static/ensps.png b/static/ensps.png new file mode 100644 index 0000000..109b103 Binary files /dev/null and b/static/ensps.png differ diff --git a/test.pdf b/test.pdf new file mode 100644 index 0000000..b5f2e1c Binary files /dev/null and b/test.pdf differ diff --git a/test.typ b/test.typ new file mode 100644 index 0000000..d6aa308 --- /dev/null +++ b/test.typ @@ -0,0 +1,39 @@ +#import "lib.typ": * + +#show: paper.with(scheme: ensps-light, title: "Devoir Maison de Catégories", subtitle: "2ème DM") + += hi + +#lorem(40) + +== hi +#lorem(40) +== hi +#lorem(40) +=== hi +#lorem(40) +=== hi +#lorem(40) +== hi +#lorem(40) + +=== hi +#lorem(40) + += hi +#lorem(40) + +== hi +#lorem(40) + +=== hi +#lorem(40) + += hi +#lorem(40) + +== hi +#lorem(40) + +=== hi +#lorem(40) diff --git a/typst.toml b/typst.toml new file mode 100644 index 0000000..d6bfca1 --- /dev/null +++ b/typst.toml @@ -0,0 +1,7 @@ +[package] +name = "lyes-typstbox" +version = "0.1.0" +entrypoint = "lib.typ" +authors = ["Lyes Saadi "] +license = "MIT-0" +description = "Lyes' Typst ToolBox"