Skip to content

Commit 4bc714d

Browse files
authored
efter-plugget:0.1.0 (#3085)
1 parent 3c23edb commit 4bc714d

File tree

10 files changed

+368
-0
lines changed

10 files changed

+368
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pdf
2+
*.txt
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Permission to use, copy, modify, and/or distribute this software for
2+
any purpose with or without fee is hereby granted.
3+
4+
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
5+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
6+
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
7+
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
8+
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
9+
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
10+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Lab report, essay and exam template for Typst
2+
3+
## Example document
4+
5+
```bash
6+
# Generate new report based on template.
7+
typst init @preview/efter-plugget
8+
```
9+
10+
![Example lab report](inc/thumbnail.png)
11+
12+
## Logo
13+
14+
The default logo used in the template is the [Stockholm University logotype](https://medarbetare.su.se/en/our-su/communicate-su/graphic-profile/logotype). It is goverened by copyright. Replace it with the logo of your University.
15+
16+
## Etymology
17+
18+
The package is named _"Efter plugget"_ in tribute of a Swedish song about finishing Uni.
24.2 KB
Loading
238 KB
Loading
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
#import "@preview/latex-lookalike:0.1.4"
2+
#import "@preview/hallon:0.1.2"
3+
4+
#import "@preview/nth:1.0.1": nth
5+
6+
// template formats the document as a lab report, essay or exam.
7+
#let template(
8+
logo: image("/inc/default_logo.png"),
9+
title: "Lab report",
10+
subtitle: none,
11+
page-header-title: none,
12+
course-name: none,
13+
course-code: none,
14+
course-part: none,
15+
lab-name: none,
16+
authors: none,
17+
lab-partners: none,
18+
lab-supervisor: none,
19+
lab-group: none,
20+
lab-date: none,
21+
22+
// Report contents.
23+
body,
24+
) = {
25+
// Set document metadata.
26+
set document(title: title)
27+
28+
// support both array and string type for authors.
29+
let authors-str = authors
30+
if type(authors) == array {
31+
authors-str = authors.join(", ", last: " and ")
32+
}
33+
34+
// Set page size and margins.
35+
set page(
36+
paper: "a4",
37+
margin: (x: 2.5cm, top: 3.1cm, bottom: 3.55cm),
38+
header: {
39+
grid(
40+
columns: (2fr, 1fr, 2fr),
41+
align: (left, center, right),
42+
inset: (bottom: 5pt),
43+
// left
44+
course-code,
45+
// middle
46+
page-header-title,
47+
//right
48+
authors-str,
49+
grid.hline(stroke: 0.4pt),
50+
)
51+
},
52+
)
53+
54+
// Set default font.
55+
set text(font: "New Computer Modern")
56+
57+
// Style outline, headings, lists and quotes using the style of LaTeX.
58+
show: latex-lookalike.style
59+
60+
// Style links and citations.
61+
let linkblue = blue
62+
show ref: set text(fill: linkblue)
63+
show cite: set text(fill: linkblue)
64+
65+
// Place table and listing captions at top.
66+
show figure.where(kind: table): set figure.caption(position: top)
67+
show figure.where(kind: raw): set figure.caption(position: top)
68+
69+
// Style figures and subfigures.
70+
show: hallon.style-figures
71+
72+
// Set title of bibliography.
73+
set bibliography(title: "References")
74+
75+
// === [ Frontmatter ] ======================================================
76+
77+
// --- [ Front page ] -------------------------------------------------------
78+
79+
page(
80+
numbering: none,
81+
header: none,
82+
margin: (x: 1.55cm, top: 3.1cm, bottom: 3.55cm),
83+
)[
84+
#grid(
85+
columns: (5.10cm, 1fr),
86+
gutter: 3pt,
87+
grid.vline(x: 1, stroke: 0.4pt + black),
88+
// left cell (logo)
89+
{
90+
set image(width: 4.3cm)
91+
logo
92+
},
93+
// right cell (title)
94+
block(height: 100%, inset: 2.1em)[
95+
#v(6.1cm)
96+
#if course-name != none { text(size: 1.2em)[ #course-name \ ] }
97+
#if course-code != none { text(size: 1.2em)[ (#course-code) ] }
98+
99+
// title
100+
#text(size: 2.1em, weight: "bold", title)
101+
102+
// subtitle
103+
#if subtitle != none { v(-1.5em) + text(size: 1.5em, weight: "bold", subtitle) }
104+
105+
// date
106+
#text(size: 1.2em, {
107+
let today = datetime.today()
108+
nth(today.display("[day padding:none]"))
109+
today.display(" [month repr:long] [year]")
110+
})
111+
112+
#v(1fr)
113+
114+
#let cells = ()
115+
#if course-name != none {
116+
cells.push([Course:])
117+
cells.push([#course-name])
118+
}
119+
#if course-part != none {
120+
cells.push([Course part:])
121+
cells.push([#course-part])
122+
}
123+
#if lab-name != none {
124+
cells.push([Lab:])
125+
cells.push([#lab-name])
126+
}
127+
#if authors != none {
128+
// support both array and string type for authors.
129+
if type(authors) != array {
130+
cells.push([Author:])
131+
cells.push([#authors])
132+
} else {
133+
if authors.len() > 1 {
134+
cells.push([Authors:])
135+
} else {
136+
cells.push([Author:])
137+
}
138+
cells.push([#authors.join(", ", last: " and ")])
139+
}
140+
}
141+
#if lab-partners != none {
142+
// support both array and string type for lab partners.
143+
if type(lab-partners) != array {
144+
cells.push([Lab partner:])
145+
cells.push([#lab-partners])
146+
} else {
147+
if lab-partners.len() > 1 {
148+
cells.push([Lab partners:])
149+
} else {
150+
cells.push([Lab partner:])
151+
}
152+
cells.push([#lab-partners.join(", ", last: " and ")])
153+
}
154+
}
155+
#if lab-supervisor != none {
156+
cells.push([Lab supervisor:])
157+
cells.push([#lab-supervisor])
158+
}
159+
#if lab-group != none {
160+
cells.push([Lab group:])
161+
cells.push([#lab-group])
162+
}
163+
#if lab-date != none {
164+
cells.push([Lab date:])
165+
cells.push([#lab-date])
166+
}
167+
#block(inset: 0.4em)[
168+
#grid(
169+
columns: (auto, 1fr),
170+
gutter: 10pt,
171+
..cells,
172+
)
173+
]
174+
],
175+
)
176+
]
177+
178+
pagebreak(weak: true)
179+
180+
// --- [ Table of contents ] ------------------------------------------------
181+
182+
set page(numbering: "i")
183+
counter(page).update(1)
184+
185+
outline()
186+
pagebreak(weak: true)
187+
188+
// Style all links after outline.
189+
show link: set text(fill: linkblue)
190+
191+
// --- [ Main matter ] ------------------------------------------------------
192+
193+
set page(numbering: "1")
194+
counter(page).update(1)
195+
196+
body
197+
}
24.2 KB
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@book{2020_molecular_biology_principles_of_genome_function_craig,
2+
title={Molecular biology: principles of genome function},
3+
author={Craig, Nancy and Green, Rachel and Cohen-Fix, Orna and Greider, Carol and Storz, Gisela and Wolberger, Cynthia},
4+
year={2020},
5+
publisher={Oxford University Press}
6+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#import "@preview/efter-plugget:0.1.0"
2+
3+
#let todo = highlight
4+
5+
// hallon is an optional library for subfigures.
6+
#import "@preview/hallon:0.1.2": subfigure
7+
// cellpress is an optional library for Cell Press table style.
8+
#import "@preview/cellpress-unofficial:0.1.0" as cellpress: toprule, midrule, bottomrule
9+
// smartaref is an optional library for handling consecutive references.
10+
#import "@preview/smartaref:0.1.0": cref, Cref
11+
12+
#show: efter-plugget.template.with(
13+
logo: image("inc/logo.png"),
14+
title: todo[Lab 1 -- Stem Cells],
15+
subtitle: todo[An investigation into the effects of morphogens on differentiation],
16+
page-header-title: todo("Lab 1"),
17+
course-name: todo("Course Name"),
18+
course-code: todo("AA1234"),
19+
//course-part: "",
20+
lab-name: todo("Stem cell differentiation"),
21+
authors: todo("Jane Rue"),
22+
lab-partners: (todo("John Doe"), todo("Eve Smith")),
23+
//lab-supervisor: "",
24+
lab-group: todo("Group 1"),
25+
lab-date: datetime.today().display(), // "2025-09-19"
26+
)
27+
28+
#show: cellpress.style-table
29+
30+
// === [ quote ] ===============================================================
31+
32+
#quote(
33+
block: true,
34+
attribution: [anonymous],
35+
)[
36+
#emph["Chemistry is all around us."]
37+
]
38+
39+
// === [ Introduction ] ========================================================
40+
41+
= Introduction
42+
43+
#lorem(35)
44+
45+
== Purpose
46+
47+
#lorem(10)
48+
49+
== Theory
50+
51+
#lorem(10) @2020_molecular_biology_principles_of_genome_function_craig
52+
53+
#pagebreak(weak: true)
54+
55+
// === [ Methods ] =============================================================
56+
57+
= Methods
58+
59+
#lorem(10)
60+
61+
#pagebreak(weak: true)
62+
63+
// === [ Results ] =============================================================
64+
65+
= Results
66+
67+
#lorem(10)
68+
69+
As seen in #cref[@subfig-foo @subfig-bar] ...
70+
71+
#figure(
72+
grid(
73+
columns: 2,
74+
gutter: 1em,
75+
subfigure(
76+
rect(fill: aqua), // image("/inc/foo.png"),
77+
caption: lorem(3),
78+
label: <subfig-foo>
79+
),
80+
subfigure(
81+
rect(fill: teal), // image("/inc/bar.png"),
82+
caption: lorem(3),
83+
label: <subfig-bar>
84+
),
85+
),
86+
gap: 1em,
87+
caption: lorem(5),
88+
) <fig-baz>
89+
90+
The results of the experiment are presented in @tbl-bar ...
91+
92+
#figure(
93+
caption: lorem(5),
94+
table(
95+
columns: 3,
96+
toprule(),
97+
table.header[*foo*][*bar*][*baz*],
98+
midrule(),
99+
[a], [b], [c],
100+
[a], [b], [c],
101+
[a], [b], [c],
102+
bottomrule(),
103+
),
104+
) <tbl-bar>
105+
106+
#pagebreak(weak: true)
107+
108+
// === [ Discussion ] ==========================================================
109+
110+
= Discussion
111+
112+
#lorem(10)
113+
114+
#pagebreak(weak: true)
115+
116+
// === [ Bibliography ] ========================================================
117+
118+
#bibliography("references.bib")
119+
120+
#pagebreak(weak: true)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "efter-plugget"
3+
version = "0.1.0"
4+
entrypoint = "src/lib.typ"
5+
authors = ["Robin Eklind"]
6+
license = "0BSD"
7+
description = "Lab report, essay and exam template for Typst."
8+
repository = "https://github.com/mewmew/efter-plugget"
9+
categories = ["report"]
10+
exclude = ["/inc"]
11+
12+
[template]
13+
path = "template"
14+
entrypoint = "report.typ"
15+
thumbnail = "inc/thumbnail.png"

0 commit comments

Comments
 (0)