|
1 | | -// [v1.0] Tim Xie, Fall 2025 |
2 | | -// Please retain attribution for future semesters, and direct any questions to xie@berkeley.edu. |
3 | | - |
4 | 1 | #import "@preview/codly:1.3.0": * |
5 | 2 | #import "@preview/codly-languages:0.1.1": * |
6 | 3 |
|
7 | | -#let section_counter = counter("sectioncounter") |
8 | | -#let section_points = state("sectionpoints", ()) |
| 4 | +#let section-counter = counter("sectioncounter") |
| 5 | +#let section-points = state("sectionpoints", ()) |
9 | 6 |
|
10 | | -#let add_points = p => { |
11 | | - let section = section_counter.get().at(0) - 1 |
| 7 | +#let add-points = p => { |
| 8 | + let section = section-counter.get().at(0) - 1 |
12 | 9 |
|
13 | | - section_points.update(it => { |
| 10 | + section-points.update(it => { |
14 | 11 | for i in range(it.len(), section + 1) { |
15 | 12 | it.push(0) |
16 | 13 | } |
|
108 | 105 | #let section(title, height: auto, number: true, points: false, content) = { |
109 | 106 | block(height: height)[ |
110 | 107 | #if number == true [ |
111 | | - #section_counter.step() |
| 108 | + #section-counter.step() |
112 | 109 | #context { |
113 | | - let pts = section_points.final().at(section_counter.get().at(0) - 1, default: 0) |
| 110 | + let pts = section-points.final().at(section-counter.get().at(0) - 1, default: 0) |
114 | 111 |
|
115 | 112 | let pstr = if pts == 1 { "point" } else { "points" } |
116 | | - add_points(0.0) |
| 113 | + add-points(0.0) |
117 | 114 | if points { |
118 | | - text(section_counter.display("1. ") + "[" + repr(pts) + " " + pstr + "] " + title, size: 14.5pt, weight: 500, tracking: -0.01em) |
| 115 | + text(section-counter.display("1. ") + "[" + repr(pts) + " " + pstr + "] " + title, size: 14.5pt, weight: 500, tracking: -0.01em) |
119 | 116 | } else { |
120 | | - text(section_counter.display("1. ") + title, size: 14.5pt, weight: 500, tracking: -0.01em) |
| 117 | + text(section-counter.display("1. ") + title, size: 14.5pt, weight: 500, tracking: -0.01em) |
121 | 118 | } |
122 | 119 | } |
123 | 120 |
|
|
173 | 170 |
|
174 | 171 | block(width: 100%)[ |
175 | 172 | #if points != "" [ |
176 | | - #context add_points(points); |
| 173 | + #context add-points(points); |
177 | 174 | #text("[" + repr(points) + " " + pstr + "] ", weight: 500) #text(question) |
178 | 175 | ] else [ |
179 | 176 | #question |
|
246 | 243 |
|
247 | 244 | block(width: 100%)[ |
248 | 245 | #if points != "" [ |
249 | | - #context add_points(points); |
| 246 | + #context add-points(points); |
250 | 247 | #text("[" + repr(points) + " " + pstr + "] ", weight: 500) #text(question) |
251 | 248 | ] else [ |
252 | 249 | #question |
|
0 commit comments