|
| 1 | +#import "@preview/big-todo:0.2.0": * |
| 2 | +#import "@preview/cetz:0.2.2" |
| 3 | +#import "@preview/codly:1.0.0": * |
| 4 | +#import "@preview/drafting:0.2.0": * |
| 5 | +#import "@preview/fletcher:0.4.2" as fletcher: node, edge |
| 6 | +#import "@preview/wrap-it:0.1.0": wrap-content |
| 7 | +#import "@preview/lovelace:0.2.0": * |
1 | 8 |
|
2 |
| -#let project(title: [], subtitle: [], author: [], professors: (), body) = { |
3 |
| - set document(author: author, title: title) |
4 |
| - set page(paper: "a4", margin: (inside: 3cm, outside: 2.5cm), numbering: none) |
5 |
| - set text(font: "New Computer Modern", lang: "it") |
6 |
| - set par(justify: true, leading: 0.75em) |
7 |
| - set text(size: 12pt) |
8 |
| - show par: set block(spacing: 1.6em) |
9 |
| - show link: underline |
10 |
| - show heading: it => block(it.body, below: 2em, above: 2em) |
11 |
| - align(center, [ |
12 |
| - #v(15em) |
13 |
| - #heading(level: 1, outlined: false, text(size: 30pt, title)) |
14 |
| - #v(2em) |
15 |
| - #heading(level: 2, outlined: false, text(size: 18pt, subtitle)) |
16 |
| - #align(bottom, [ |
17 |
| - #text(size: 18pt, emph(author)) |
18 |
| - #v(1em) |
19 |
| - #if type(professors) == "string" { |
20 |
| - text(size: 16pt, professors) |
21 |
| - } else { |
22 |
| - text(size: 16pt, professors.join(", ")) |
23 |
| - } |
24 |
| - #v(2em) |
25 |
| - #text(size: 16pt, datetime.today().display("[year]")) |
26 |
| - #v(2cm) |
27 |
| - ]) |
28 |
| - ]) + body |
| 9 | +#let algorithm = algorithm.with(supplement: "Algoritmo") |
| 10 | + |
| 11 | + |
| 12 | +#let project( |
| 13 | + title: [], |
| 14 | + subtitle: [], |
| 15 | + author: [], |
| 16 | + professors: (), |
| 17 | + school: [], |
| 18 | + department: [], |
| 19 | + course: [], |
| 20 | + session: [], |
| 21 | + aa: [], |
| 22 | + abstract: [], |
| 23 | + dedication: [], |
| 24 | + final: false, |
| 25 | + body, |
| 26 | +) = { |
| 27 | + set document(author: author, title: title) |
| 28 | + set page( |
| 29 | + paper: "a4", |
| 30 | + margin: (x: 2.5cm, y: 1.25cm), |
| 31 | + numbering: none, |
| 32 | + ) |
| 33 | + |
| 34 | + set text( |
| 35 | + font: "Libertinus Serif", |
| 36 | + lang: "it", |
| 37 | + region: "it", |
| 38 | + size: 12pt, |
| 39 | + hyphenate: true, |
| 40 | + ) |
| 41 | + |
| 42 | + // Bozza header |
| 43 | + set page(header: if not final { |
| 44 | + box( |
| 45 | + width: 100%, |
| 46 | + stroke: 1pt + red, |
| 47 | + inset: .5em, |
| 48 | + align( |
| 49 | + center + horizon, |
| 50 | + text(fill: red, size: 18pt, [Bozza del #datetime.today().display("[day]/[month]/[year]")]), |
| 51 | + ), |
| 52 | + ) |
| 53 | + } else { |
| 54 | + none |
| 55 | + }) |
| 56 | + |
| 57 | + for logo in ("assets/logo_bw.png", "assets/logo_colored.png") { |
| 58 | + align( |
| 59 | + center, |
| 60 | + [ |
| 61 | + |
| 62 | + #image(logo, width: 6.5cm) |
| 63 | + #v(2em, weak: true) |
| 64 | + |
| 65 | + #upper[Dipartimento di #text(department)] |
| 66 | + #v(2em, weak: true) |
| 67 | + |
| 68 | + #text(size: 14pt, strong([Corso di #text(course)])) |
| 69 | + #line(stroke: (dash: "dotted", thickness: 1pt), length: 100%) |
| 70 | + #v(5em) |
| 71 | + |
| 72 | + #heading(level: 1, outlined: false, text(size: 28pt, hyphenate: false, title)) |
| 73 | + #v(2em) |
| 74 | + #heading(level: 2, outlined: false, text(size: 18pt, weight: "regular", hyphenate: false, subtitle)) |
| 75 | + |
| 76 | + #align(bottom)[ |
| 77 | + #text(size: 14pt)[ |
| 78 | + #grid( |
| 79 | + columns: (auto, 1fr, auto), |
| 80 | + align: (top + left), |
| 81 | + rows: 1, |
| 82 | + row-gutter: 2em, |
| 83 | + [ |
| 84 | + *Relatore:* \ |
| 85 | + #text(professors.at(0), hyphenate: false) |
| 86 | + ], |
| 87 | + { }, |
| 88 | + [ |
| 89 | + *Presentata da:* \ |
| 90 | + #text(author) |
| 91 | + ], |
| 92 | + { |
| 93 | + if professors.len() > 0 { |
| 94 | + let title = if professors.len() > 1 { |
| 95 | + "Correlatori:" |
| 96 | + } else { |
| 97 | + "Correlatore:" |
| 98 | + } |
| 99 | + text(size: 14pt, weight: "bold", title) |
| 100 | + linebreak() |
| 101 | + for professor in professors.slice(1) { |
| 102 | + text(professor, hyphenate: false) |
| 103 | + linebreak() |
| 104 | + } |
| 105 | + } |
| 106 | + }, |
| 107 | + ) |
| 108 | + |
| 109 | + #v(2em, weak: true) |
| 110 | + |
| 111 | + #line(stroke: (dash: "solid", thickness: 1pt), length: 100%) |
| 112 | + |
| 113 | + Sessione #text(session) \ |
| 114 | + Anno accademico #text(aa) |
| 115 | + ] |
| 116 | + ] |
| 117 | + ], |
| 118 | + ) |
| 119 | + |
| 120 | + pagebreak() |
| 121 | + } |
| 122 | + |
| 123 | + set page(margin: 2.5cm) |
| 124 | + show link: underline |
| 125 | + |
| 126 | + set par(justify: true, leading: 0.75em) |
| 127 | + |
| 128 | + show raw.where(block: false): box.with( |
| 129 | + stroke: (paint: gray, thickness: .5pt), |
| 130 | + outset: (y: .2em, x: -.2em), |
| 131 | + inset: (x: .5em), |
| 132 | + radius: .2em, |
| 133 | + ) |
| 134 | + |
| 135 | + counter(page).update(1) // reset page counter |
| 136 | + |
| 137 | + show par: set block(spacing: 1.6em) |
| 138 | + show heading: set block(spacing: 1em) |
| 139 | + |
| 140 | + if abstract != [] { |
| 141 | + align( |
| 142 | + horizon, |
| 143 | + { |
| 144 | + heading(level: 1, "Sommario") |
| 145 | + text(abstract) |
| 146 | + }, |
| 147 | + ) |
| 148 | + pagebreak() |
| 149 | + } |
| 150 | + |
| 151 | + if dedication != [] and final { |
| 152 | + align(horizon + end, text(dedication)) |
| 153 | + pagebreak() |
| 154 | + } |
| 155 | + |
| 156 | + set page(numbering: "1") |
| 157 | + |
| 158 | + outline(title: [ Indice dei contenuti ], indent: 20pt, depth: 2) |
| 159 | + |
| 160 | + { |
| 161 | + show heading.where(level: 1): it => { |
| 162 | + pagebreak() |
| 163 | + v(8cm) |
| 164 | + set par(justify: false) |
| 165 | + show par: set block(spacing: 0cm) |
| 166 | + let c = counter(heading).display("1") |
| 167 | + // text(size: 40pt, c) |
| 168 | + v(1cm) |
| 169 | + text(size: 40pt, it.body, hyphenate: false) |
| 170 | + v(1cm) |
| 171 | + } |
| 172 | + |
| 173 | + show heading.where(level: 2): it => { |
| 174 | + set text(size: 20pt) |
| 175 | + v(2cm) |
| 176 | + it |
| 177 | + } |
| 178 | + |
| 179 | + show heading.where(level: 3): it => { |
| 180 | + set text(size: 14pt) |
| 181 | + it |
| 182 | + } |
| 183 | + |
| 184 | + set heading(numbering: "1.1.") |
| 185 | + |
| 186 | + set-page-properties() |
| 187 | + |
| 188 | + show: codly-init.with() |
| 189 | + codly( |
| 190 | + number-format: none, |
| 191 | + zebra-fill: none, |
| 192 | + languages: ( |
| 193 | + python: (name: "Python", icon: "", color: rgb("#3572A5")), |
| 194 | + ), |
| 195 | + ) |
| 196 | + |
| 197 | + show: setup-lovelace |
| 198 | + |
| 199 | + body |
| 200 | + |
| 201 | + bibliography( |
| 202 | + "./bibliography.bib", |
| 203 | + // style: "association-for-computing-machinery", |
| 204 | + style: "institute-of-electrical-and-electronics-engineers" |
| 205 | + ) |
| 206 | + } |
29 | 207 | }
|
0 commit comments