Skip to content

Commit 15b1cac

Browse files
bananote:0.1.1 (#3640)
1 parent 47811c9 commit 15b1cac

File tree

6 files changed

+278
-0
lines changed

6 files changed

+278
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Alexander Koller
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Bananote
2+
3+
This is a template for research notes with Typst.
4+
It is intended for quickly writing down a research idea,
5+
with a clean visual look that other people will enjoy looking at.
6+
7+
The style has splashes of yellow, inspired by the [Dagstuhl LIPIcs style](https://submission.dagstuhl.de/documentation/authors).
8+
9+
10+
## Usage
11+
12+
Import bananote and populate the header with the title and authors, as follows.
13+
14+
```
15+
#import "@preview/bananote:0.1.1": *
16+
17+
#show: note.with(
18+
title: [My Research Note],
19+
authors: (
20+
([My Name], [My Affiliation]),
21+
),
22+
)
23+
24+
#abstract[
25+
Here's an abstract.
26+
]
27+
28+
Here's the text of your note.
29+
```
30+
31+
The `authors` field wants an array of authors. Each author can be an array of the form (author, affiliation), or just some content that will be typeset as the author name.
32+
33+
Bananote supports some optional arguments for the `note` function:
34+
35+
- `date`: By default, Bananote prints the compilation date in the top right of the header. You can change the date that should be printed here (as a Typst [datetime](https://typst.app/docs/reference/foundations/datetime/) object), or pass `none` to suppress the date.
36+
- `version`: This will be printed below the date as "Version #version".
37+
- `highlight-by`: Bananote will typeset citations of the authors' own papers in green, rather than blue. More specifically, pass either a string or an array of strings in this argument. Papers will be cited in green if the last name of one of the authors matches one of the strings given to `highlight-by`. By default, no authors will be highlighted.
38+
39+
Bananote comes with a nice configuration of [Pergamon](https://typst.app/universe/package/pergamon). If you import Pergamon, you can use Pergamon's usual citation commands. You can print the bibliography using `print-bananote-bibliography()`.
40+
41+
42+
## Fonts
43+
44+
Bananote typesets headings and the title in [New Computer Modern Sans](https://www.tug.org/FontCatalogue/newcomputermodernsansserif/) if possible, as a callback to the [Koma-Script article classes](https://www.tug.org/FontCatalogue/newcomputermodernsansserif/) in LaTeX.
45+
46+
New Computer Modern Sans is automatically available in the Typst web app. If you want to use it offline, [download it from here](https://www.ctan.org/tex-archive/fonts/newcomputermodern) and [make it available to Typst](https://typst.app/docs/reference/text/text/#parameters-font).
47+
48+
49+
## Example
50+
51+
<img src="https://github.com/coli-saar/bananote/blob/main/template/thumbnail.png" width=500px border=1px />
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
2+
// This style is for internal research notes.
3+
// It is modeled roughly after the Dagstuhl LIPIcs style, https://submission.dagstuhl.de/documentation/authors
4+
5+
#import "@preview/pergamon:0.6.0": *
6+
7+
#let sans = ("New Computer Modern Sans", "Libertinus Serif")
8+
#let sans-weight = 800
9+
#let serif = "Libertinus Serif"
10+
11+
#let text-size = 11pt
12+
13+
#let darkgreen = green.darken(20%)
14+
#let darkblue = blue.darken(20%)
15+
16+
#let fcite = format-citation-authoryear()
17+
#let fref = format-reference(
18+
name-format: "{given} {family}",
19+
format-quotes: it => it,
20+
print-date-after-authors: true,
21+
reference-label: fcite.reference-label,
22+
suppress-fields: (
23+
"*": ("month", "day",),
24+
"inproceedings": ("editor", "publisher", "pages", "location")
25+
),
26+
eval-scope: ("todo": x => text(fill: red, x)),
27+
bibstring: ("in": "In"),
28+
bibstring-style: "long",
29+
)
30+
31+
#let print-bananote-bibliography() = {
32+
print-bibliography(
33+
format-reference: fref,
34+
sorting: "nyt",
35+
label-generator: fcite.label-generator,
36+
)
37+
}
38+
39+
#let note(
40+
title: none,
41+
authors: (),
42+
date: datetime.today(),
43+
version: none,
44+
highlight-by: (),
45+
banana-color: yellow,
46+
doc
47+
) = {
48+
set text(font: serif, size: text-size)
49+
set page(margin: (x: 2.5cm, y: 3cm), numbering: "1")
50+
set par(first-line-indent: 0em, spacing: 1.4em, justify: true, leading: 0.7em)
51+
52+
// TITLE AND AUTHORS
53+
if title != none {
54+
text(font: sans, size: 17pt, weight: sans-weight, title)
55+
parbreak()
56+
}
57+
58+
for (i, author) in authors.enumerate() {
59+
let name = if type(author) == array { author.at(0) } else { author }
60+
let affiliation = if type(author) == array and author.len() > 1 { author.at(1) } else { "" }
61+
62+
63+
text(size: text-size, weight: "bold", name)
64+
if i == 0 and date != none {
65+
h(1fr)
66+
date.display("[day] [month repr:long] [year]")
67+
}
68+
69+
if affiliation == none and i > 1 and version == none [
70+
] else {
71+
linebreak()
72+
affiliation
73+
if i == 0 and version != none {
74+
h(1fr)
75+
[Version #version]
76+
}
77+
}
78+
parbreak()
79+
}
80+
81+
// FORMAT HEADINGS
82+
set heading(numbering: "1.1 ")
83+
let heading-size = 12pt
84+
show heading.where(level: 1): it => {
85+
v(2em, weak: true)
86+
87+
block(below: 1em)[ // block ensures that title and yellow box stay together on pagebreaks
88+
#place(dx:-3mm-2em, dy:-3.5pt)[
89+
#box(width: 2em)[
90+
#context {
91+
align(right)[
92+
#box(fill: banana-color, width: 1em, height: 1em)[
93+
#if it.numbering != none {
94+
align(center+horizon,
95+
text(font: sans, weight: sans-weight, size: heading-size, [#counter(heading).get().first()])
96+
)
97+
}
98+
]
99+
]
100+
}
101+
]
102+
]
103+
104+
#text(font: sans, weight: sans-weight, size: heading-size, it.body)
105+
]
106+
// v(-0.2em)
107+
}
108+
109+
show heading.where(level: 2): set text(font: sans, weight: sans-weight, size: heading-size)
110+
show heading.where(level: 2): set block(below: 1em, above: 2em)
111+
show heading.where(level: 3): set text(font: sans, weight: sans-weight)
112+
show heading.where(level: 4): it => text(font: sans, weight: sans-weight, size: text-size)[*#it.body.*]
113+
114+
115+
// PERGAMON
116+
let maybe-highlight(reference) = {
117+
if type(highlight-by) == array {
118+
highlight-by.any(name => name in family-names(reference.fields.labelname))
119+
} else {
120+
highlight-by in family-names(reference.fields.labelname)
121+
}
122+
}
123+
124+
show link: set text(darkblue) // for non-citations
125+
show ref: set text(darkblue)
126+
show link: it => if-citation(it, value => {
127+
let color = if maybe-highlight(value.reference) { darkgreen } else { darkblue }
128+
set text(fill: color)
129+
it
130+
})
131+
132+
133+
refsection(format-citation: fcite.format-citation, doc)
134+
}
135+
136+
#let abstract(abstr) = {
137+
v(2em)
138+
block[
139+
#line(length: 100%)
140+
#place(dx: 2em, dy: -1em, box(
141+
fill: white,
142+
inset: 6pt,
143+
text(font: sans, weight: sans-weight)[Abstract]
144+
))
145+
]
146+
v(-0.2em)
147+
148+
abstr
149+
150+
v(-0.1em)
151+
line(length: 100%)
152+
v(0.5em)
153+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
#import "@preview/bananote:0.1.1": *
3+
#import "@preview/pergamon:0.6.0": *
4+
5+
6+
#show: note.with(
7+
title: [My Research Note],
8+
authors: (([My Name], [My Affiliation]),)
9+
)
10+
11+
#abstract[
12+
#lorem(50)
13+
]
14+
15+
16+
17+
= Introduction
18+
19+
#lorem(50)
20+
21+
== Subsection
22+
23+
#lorem(50)
24+
25+
26+
= Another Section
27+
28+
#lorem(50)
29+
30+
31+
// Uncomment this to typeset the bibliography:
32+
// #add-bib-resource(read("bibliography.bib"))
33+
// #print-bananote-bibliography()
34+
35+
36+
459 KB
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "bananote"
3+
version = "0.1.1"
4+
compiler = "0.12.0"
5+
entrypoint = "lib.typ"
6+
authors = ["Alexander Koller <https://www.coli.uni-saarland.de/~koller/>"]
7+
license = "MIT"
8+
description = "Nice template for research notes with splashes of yellow."
9+
repository = "https://github.com/coli-saar/bananote"
10+
categories = ["paper"]
11+
disciplines = ["computer-science", "linguistics"]
12+
13+
[template]
14+
path = "template"
15+
entrypoint = "main.typ"
16+
thumbnail = "thumbnail.png"
17+

0 commit comments

Comments
 (0)