-
Notifications
You must be signed in to change notification settings - Fork 2
/
tufte-handout.typ
75 lines (70 loc) · 1.74 KB
/
tufte-handout.typ
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
// Size of the left "margin" (note area)
#let margin-size = 23.5%
// Spacer so that main content and notes don't rub up against each other
#let margin-space = 0.2in
/*
* Inserts a margin note containing `content`
* `dy` can be used to adjust the note content vertically
*/
#let margin-note(dy: -1em, content) = {
place(
right,
dx: margin-size + margin-space,
dy: dy,
block(width: margin-size, {
set text(size: 0.75em)
set align(left)
content
})
)
}
/*
* Renders `content` with the module's text styling. This is useful for content
* that is outside of the `template` container but which should be visually consistent.
*/
#let apply-text-styles(content) = {
set text(
font: ("TeX Gyre Pagella")
)
show heading.where(level: 1): it => text(
size: 12pt,
weight: "extralight",
style: "italic",
{
v(1em)
it.body
}
)
show heading.where(level: 2): it => text(
size: 10pt,
style: "italic",
it.body
)
content
}
/* Call to wrap `doc` in the handout layout
* `title` will be rendered in the page header
* `wrapper` should be either `none` or a function that takes `doc` and returns
* content. This can be used to inject custom styles.
*/
#let template(
title: none,
wrapper: apply-text-styles,
doc,
) = {
set page(
header: {
set text(size: 7pt, weight: "semibold", tracking: 1.25pt)
h(1fr)
upper(title)
}
)
grid(
columns: (100% - margin-size, margin-size),
if type(wrapper) == "function" {
wrapper(doc)
} else {
doc
}
)
}