|
| 1 | + |
| 2 | +// All imports |
| 3 | +#import "@preview/theoretic:0.1.1" as theoretic: theorem, proof, qed |
| 4 | +#import "@preview/showybox:2.0.3": showybox |
| 5 | + |
| 6 | +// Main noteworthy function |
| 7 | +#let noteworthy( |
| 8 | + paper-size: "a4", |
| 9 | + font: "New Computer Modern", |
| 10 | + language: "EN", |
| 11 | + title: none, |
| 12 | + author: none, |
| 13 | + contact-details: none, |
| 14 | + toc-title: "Table of Contents", |
| 15 | + content, |
| 16 | +) = { |
| 17 | + // Document metadata |
| 18 | + set document( |
| 19 | + title: [#title - #author], |
| 20 | + author: author, |
| 21 | + date: auto, |
| 22 | + ) |
| 23 | + |
| 24 | + // Page settings |
| 25 | + set page( |
| 26 | + paper: paper-size, |
| 27 | + header: context { |
| 28 | + if (counter(page).get().at(0) > 1) [ |
| 29 | + #grid( |
| 30 | + columns: (1fr, 1fr), |
| 31 | + align: (left, right), |
| 32 | + smallcaps(title), datetime.today().display("[day]/[month]/[year]"), |
| 33 | + ) |
| 34 | + #line(length: 100%) |
| 35 | + ] |
| 36 | + }, |
| 37 | + footer: context [ |
| 38 | + #line(length: 100%) |
| 39 | + #grid( |
| 40 | + columns: (1fr, 1fr, 1fr), |
| 41 | + align: (left, center, right), |
| 42 | + author, |
| 43 | + if contact-details != none { |
| 44 | + [#sym.diamond.filled #link(contact-details) #sym.diamond.filled] |
| 45 | + }, |
| 46 | + counter(page).display( |
| 47 | + "(1/1)", |
| 48 | + both: true, |
| 49 | + ), |
| 50 | + ) |
| 51 | + ], |
| 52 | + ) |
| 53 | + |
| 54 | + // Text settings |
| 55 | + set text( |
| 56 | + font: font, |
| 57 | + size: 12pt, |
| 58 | + lang: language, |
| 59 | + ) |
| 60 | + |
| 61 | + // TOC settings |
| 62 | + show outline.entry.where(level: 1): it => { |
| 63 | + v(12pt, weak: true) |
| 64 | + strong(it) |
| 65 | + } |
| 66 | + |
| 67 | + // Heading settings |
| 68 | + set heading(numbering: "1.") |
| 69 | + |
| 70 | + // Paragraph settings |
| 71 | + set par(justify: true) |
| 72 | + |
| 73 | + // Title |
| 74 | + showybox( |
| 75 | + frame: ( |
| 76 | + border-color: blue.darken(50%), |
| 77 | + body-color: blue.lighten(80%), |
| 78 | + ), |
| 79 | + shadow: ( |
| 80 | + offset: 3pt, |
| 81 | + ), |
| 82 | + body-style: ( |
| 83 | + align: center, |
| 84 | + ), |
| 85 | + text(weight: "black", size: 15pt, title), |
| 86 | + ) |
| 87 | + |
| 88 | + // Table of contents |
| 89 | + showybox( |
| 90 | + outline( |
| 91 | + indent: auto, |
| 92 | + title: toc-title, |
| 93 | + depth: 2, |
| 94 | + ), |
| 95 | + ) |
| 96 | + |
| 97 | + // Main content |
| 98 | + content |
| 99 | +} |
| 100 | + |
| 101 | +// Custom environments using theoretic |
| 102 | + |
| 103 | +// 1. Definition |
| 104 | +#let definition = theorem.with( |
| 105 | + kind: "definition", |
| 106 | + supplement: "Definition", |
| 107 | + fmt-prefix: (s, n, t) => { |
| 108 | + text(weight: "bold", stretch: 85%)[#s #n] |
| 109 | + if t != none [ (#t)] |
| 110 | + h(1em) |
| 111 | + }, |
| 112 | +) |
| 113 | + |
| 114 | +// 2. Example |
| 115 | +#let example = theorem.with( |
| 116 | + kind: "example", |
| 117 | + supplement: "Example", |
| 118 | + fmt-prefix: (s, n, t) => { |
| 119 | + text(weight: "bold", stretch: 85%)[#s #n] |
| 120 | + if t != none [ (#t)] |
| 121 | + h(1em) |
| 122 | + }, |
| 123 | +) |
| 124 | + |
| 125 | +// 3. Theorem |
| 126 | +#let theorem = theorem.with( |
| 127 | + fmt-prefix: (s, n, t) => { |
| 128 | + text(weight: "bold", stretch: 85%)[#s #n] |
| 129 | + if t != none [ (#t)] |
| 130 | + h(1em) |
| 131 | + }, |
| 132 | +) |
| 133 | + |
| 134 | +// 4. Note |
| 135 | +#let note = theorem.with( |
| 136 | + kind: "note", |
| 137 | + supplement: "Note", |
| 138 | + fmt-prefix: (s, n, t) => { |
| 139 | + text(weight: "bold", stretch: 85%)[#s #n] |
| 140 | + if t != none [ (#t)] |
| 141 | + h(1em) |
| 142 | + }, |
| 143 | +) |
| 144 | + |
| 145 | +// 5. Exercise |
| 146 | +#let exercise = theorem.with( |
| 147 | + kind: "exercise", |
| 148 | + supplement: "Exercise", |
| 149 | + fmt-prefix: (s, n, t) => { |
| 150 | + text(weight: "bold", stretch: 85%)[#s #n] |
| 151 | + if t != none [ (#t)] |
| 152 | + h(1em) |
| 153 | + }, |
| 154 | +) |
| 155 | + |
| 156 | +// 6. Solution |
| 157 | +#let solution = theorem.with( |
| 158 | + kind: "solution", |
| 159 | + supplement: "Solution", |
| 160 | + fmt-prefix: (s, n, t) => { |
| 161 | + text(weight: "bold")[#s:] |
| 162 | + if t != none [ (#t)] |
| 163 | + h(1em) |
| 164 | + }, |
| 165 | +) |
0 commit comments