|
| 1 | +/***********************/ |
| 2 | +/* TEMPLATE DEFINITION */ |
| 3 | +/***********************/ |
| 4 | + |
| 5 | +/* HANDLING DATE DISPLAY */ |
| 6 | + |
| 7 | +#let translate_month(month) = { |
| 8 | + // Construction mapping for months |
| 9 | + let t = (:) |
| 10 | + let fr-month-s = ("Janv.", "Févr.", "Mars", "Avr.", "Mai", "Juin", |
| 11 | + "Juill.", "Août", "Sept.", "Oct.", "Nov.", "Déc.") |
| 12 | + let fr-months-l = ("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", |
| 13 | + "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre") |
| 14 | + for i in range(12) { |
| 15 | + let idate = datetime(year: 0, month: i + 1, day: 1) |
| 16 | + let ml = idate.display("[month repr:long]") |
| 17 | + let ms = idate.display("[month repr:short]") |
| 18 | + t.insert(ml, fr-months-l.at(i)) |
| 19 | + t.insert(ms, fr-month-s.at(i)) |
| 20 | + } |
| 21 | + |
| 22 | + // Translating month |
| 23 | + let fr_month = t.at(month) |
| 24 | + fr_month |
| 25 | +} |
| 26 | + |
| 27 | +#let display-date(date, short-month) = { |
| 28 | + context { |
| 29 | + // Getting adapted month string |
| 30 | + let repr = if short-month { "short" } else { "long" } |
| 31 | + let month = date.display("[month repr:" + repr + "]") |
| 32 | + |
| 33 | + // Translate if necessary |
| 34 | + if text.lang == "fr" { |
| 35 | + month = translate_month(month) |
| 36 | + } |
| 37 | + |
| 38 | + // Returns month and year |
| 39 | + [#month #str(date.year())] |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | + |
| 44 | +/* MAIN COVER DEFINITION */ |
| 45 | + |
| 46 | +#let cover(title, author, date-start, date-end, subtitle: none, logo: none, short-month: false, logo-horizontal: true) = { |
| 47 | + set page(background: move(dx: 0pt, dy: -13%, image("assets/armes.svg"))) |
| 48 | + set text(font: "New Computer Modern Sans", hyphenate: false, fill: rgb(1, 66, 106)) |
| 49 | + set align(center) |
| 50 | + |
| 51 | + v(1.8fr) |
| 52 | + |
| 53 | + set text(size: 24pt, weight: "bold") |
| 54 | + upper(title) |
| 55 | + |
| 56 | + v(1.5fr) |
| 57 | + |
| 58 | + if subtitle != none { |
| 59 | + set text(size: 20pt) |
| 60 | + subtitle |
| 61 | + } |
| 62 | + |
| 63 | + v(1.5fr) |
| 64 | + |
| 65 | + set text(size: 18pt, weight: "regular") |
| 66 | + display-date(date-start, short-month); [ \- ]; display-date(date-end, short-month) |
| 67 | + |
| 68 | + image("assets/filet-court.svg") |
| 69 | + |
| 70 | + set text(size: 16pt) |
| 71 | + smallcaps(author) |
| 72 | + |
| 73 | + v(1fr) |
| 74 | + |
| 75 | + let logo-height = if (logo-horizontal) { 20mm } else { 30mm } |
| 76 | + let path-logo-x = if (logo-horizontal) { "assets/logo-x-ip-paris.svg" } else { "assets/logo-x.svg" } |
| 77 | + |
| 78 | + set image(height: logo-height) |
| 79 | + |
| 80 | + if (logo != none) { |
| 81 | + grid( |
| 82 | + columns: (1fr, 1fr), align: center + horizon, |
| 83 | + logo, image(path-logo-x) |
| 84 | + ) |
| 85 | + } else { |
| 86 | + grid( |
| 87 | + columns: (1fr), align: center + horizon, |
| 88 | + image(path-logo-x) |
| 89 | + ) |
| 90 | + } |
| 91 | + |
| 92 | +} |
| 93 | + |
| 94 | + |
| 95 | +/********************/ |
| 96 | +/* TESTING TEMPLATE */ |
| 97 | +/********************/ |
| 98 | + |
| 99 | +#set text(lang: "fr") |
| 100 | + |
| 101 | +#cover( |
| 102 | + [A very long title over multiple lines automatically], |
| 103 | + "Jane Doe", |
| 104 | + datetime.today(), |
| 105 | + datetime.today(), |
| 106 | + subtitle: "Je n'ai pas de stage mais je suis détendu", |
| 107 | + logo-horizontal: true, |
| 108 | +) |
0 commit comments