hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/templates/paper.typ
blob: caf33b654392df0d28e5aded02308cfc772c2212 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#let title-block(title, date) = align(center)[
  #text(size: 18pt)[#smallcaps[#title]] \
  #v(0.15em)
  #text(size: 12pt)[--- #smallcaps(date) ---]
]

#let author-block(authors) = align(center)[
  #for author in authors [
    #author.name \
    #text(style: "italic")[#author.location]
  ]
]

#let abstract-block(prefix, body) = block(width: 100%, inset: (x: 10%))[
  #set par(justify: true, first-line-indent: 0pt)
  #text(size: 9pt)[#text(weight: "bold")[#prefix]#body]
]

#let frontmatter(title, date, authors, abstract, abstract-prefix) = place(
  top + center,
  scope: "parent",
  float: true,
)[
  #title-block(title, date)
  #v(0.7em)
  #author-block(authors)
  #v(0.9em)
  #if abstract != none {
    abstract-block(abstract-prefix, abstract)
    v(0.7em)
  }
  #line(length: 100%, stroke: 0.4pt)
  #v(0.5em)
]

// a booktabs table: a top rule, a rule under the header, a bottom rule, and
// nothing else. header is the row of heading cells; the rest are body cells.
#let booktabs(columns: auto, align: auto, header: (), ..rows) = table(
  columns: columns,
  align: align,
  stroke: none,
  inset: (x: 6pt, y: 4pt),
  table.hline(stroke: 0.8pt),
  table.header(..header.map(cell => strong(cell))),
  table.hline(stroke: 0.4pt),
  ..rows.pos(),
  table.hline(stroke: 0.8pt),
)

#let paper(
  title: none,
  date: none,
  authors: (),
  abstract: none,
  lang: "fr",
  region: "FR",
  font: "EB Garamond",
  size: 10pt,
  doc,
) = {
  set document(title: title, author: authors.map(author => author.name))

  set page(
    paper: "a4",
    margin: (top: 19mm, bottom: 25mm, left: 16mm, right: 16mm),
    columns: 2,
    numbering: "- 1/1 -",
  )

  set par(
    justify: true,
    leading: 0.62em,
    spacing: 0.62em,
    first-line-indent: (amount: 1.2em, all: false),
    linebreaks: "optimized",
  )
  set text(font: font, size: size, lang: lang, region: region, number-type: "old-style")
  set figure(gap: 0.65em)
  set table(inset: (x: 6pt, y: 4pt))

  show heading.where(level: 1): it => [
    #v(0.9em)
    #align(center)[#text(size: 11pt, weight: "medium")[#smallcaps[#it.body]]]
    #v(0.4em)
  ]

  show heading.where(level: 2): it => [
    #v(0.7em)
    #align(right)[#text(size: 10pt, style: "italic")[#it.body]]
    #v(0.25em)
  ]

  show heading.where(level: 3): it => [
    #v(0.5em)
    #text(size: 10pt, weight: "bold", style: "italic")[#it.body]
    #v(0.15em)
  ]

  show figure.where(kind: table): set text(size: 8.5pt)
  show figure.caption: set text(size: 8.5pt)
  show bibliography: set text(size: 8.5pt)

  let abstract-prefix = if lang == "fr" { [Résumé --- ] } else { [Abstract---] }

  frontmatter(title, date, authors, abstract, abstract-prefix)

  doc
}