-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Lacewing | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# UBC Math Group Project Template | ||
This is a Typst template for UBC Math 100 group projects. It aims to reproduce most of the existing LaTex template while providing a more user-friendly interface for students who are not familiar with LaTex. | ||
|
||
For more information, please refer to the [documentation](/manual.pdf). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(ls).name | ||
| where (str ends-with ".pdf") | ||
| each {|el| if $el != "manual.pdf" { rm $el } } | ||
|
||
rm template/*.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#import "@preview/cetz:0.3.1" | ||
#import "@preview/cetz-plot:0.1.0" | ||
|
||
/// Get the 2D coordinates in form of (x: i, y: j). | ||
/// - coord (array, dictionary): The coordinates, must be 2-elements long. | ||
#let get-2d-coord(coord) = { | ||
assert(type(coord) in (array, dictionary)) | ||
|
||
if (type(coord) == dictionary) { return coord } | ||
return (x: coord.at(0), y: coord.at(1)) | ||
} | ||
|
||
/// Use in a `cetz.canvas`! | ||
/// Draw an upright no-perspective cylinder. | ||
/// - center (array, dictionary): The center of the cylinder. | ||
/// - radius (array): The radius of the cylinder. | ||
/// - height (length): The height of the cylinder. | ||
/// - fill-top (color): The color to fill the top of the cylinder. | ||
/// - fill-side (color): The color to fill the side of the cylinder. | ||
#let cylinder(center, radius, height, fill-top: none, fill-side: none) = { | ||
assert(type(center) in (array, dictionary)) | ||
assert(type(radius) == array) | ||
assert(type(height) == length) | ||
|
||
import cetz.draw: * | ||
let center = get-2d-coord(center) | ||
let lt = (center.x - radius.at(0), center.y) | ||
|
||
merge-path(fill: fill-side, { | ||
line(lt, (rel: (0, -height))) | ||
arc((), start: 180deg, delta: 180deg, radius: radius) | ||
line((), (rel: (0, height))) | ||
arc((), stop: 180deg, delta: -180deg, radius: radius) | ||
}) | ||
circle(center, radius: radius, fill: fill-top) | ||
} |
149 changes: 149 additions & 0 deletions
149
packages/preview/lacy-ubc-math-project/0.1.0/format.typ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
// Question levels, corresponding numbering and labeling. | ||
|
||
// The maximum number of question levels. | ||
#let __max-qs-level = 3 | ||
// The current question level. | ||
#let __question-level = state("question-level", 0) | ||
// The question counters. | ||
#let __question-counters = range(1, __max-qs-level + 1).map(i => counter("question-" + str(i))) | ||
// Duplicate question numbers | ||
#let __question-duplicates = state("question-duplicates", (:)) | ||
// Numbering for each question level. | ||
#let __question-numbering = ( | ||
"1.", | ||
"(a)", | ||
"i.", | ||
) | ||
// Label numbering for each question level. | ||
#let __question-labels = ( | ||
"1", | ||
"a", | ||
"i", | ||
) | ||
// Make sure the numbering and labeling are consistent. | ||
#assert(__question-numbering.len() == __max-qs-level and __question-labels.len() == __max-qs-level) | ||
|
||
// solution visibility | ||
#let __solution-visible = state("solution-visible", true) | ||
#let toggle-solution(visible) = { | ||
assert(type(visible) == bool, message: "The visibility of the solution must be a boolean.") | ||
__solution-visible.update(v => visible) | ||
} | ||
#let __solution-disabled = sys.inputs.at("hide-solution", default: "") in ("1", "true", "yes", "y") | ||
|
||
/// Creates an author (a `dictionary`). | ||
/// - firstname (str, content): The author's first name, bold when displayed. | ||
/// - lastname (str, content): The author's last name. | ||
/// - id (int, content): The author's student ID. | ||
/// - strname (str, none): `str` alternative as the full name. In case of special characters or formatting in the name, a plain text version can be used for PDF metadata. | ||
#let author(firstname, lastname, id, strname: none) = { | ||
( | ||
name: ( | ||
first: firstname, | ||
last: lastname, | ||
), | ||
id: id, | ||
strname: strname, | ||
) | ||
} | ||
|
||
// The green used for solution frame and text. | ||
#let green-solution = rgb(10%, 40%, 10%) | ||
|
||
/// Creates a question block. | ||
/// Automatically increments the question level for further questions in `body`. | ||
/// Supports up to 3 levels of questions. | ||
/// [WARN] Do not provide `counters`, `numbering` or `labels` if unsure of what they do. | ||
/// | ||
/// - point (int, content, str, none): The number of points for the question. Does not display if it is `0` or `none`; does not attach "points" if it is `content` or `str`. | ||
/// | ||
/// - body (block): The question, sub-questions and solutions. | ||
/// | ||
/// - counters (array): The question counters for each level. | ||
/// | ||
/// - numbering (array): The numbering for each question level. | ||
/// For example, `("1.", "(a)", "i.")`. | ||
/// | ||
/// - labels (array): The label numbering for each question level. Must not contain anything not allowed in `label`, e.g. spaces, plus signs. | ||
/// For example, `("1", "a", "i")` will result in question 1.1.1 being labeled with `<qs:1-a-i>`. | ||
#let question(point, body, counters: __question-counters, numbering: __question-numbering, labels: __question-labels) = context { | ||
// Increment the question level. | ||
__question-level.update(n => n + 1) | ||
// Get the current question level. | ||
let level = __question-level.get() | ||
// Make sure the question level is within the supported range. | ||
assert( | ||
level <= __max-qs-level, | ||
message: "Maximum question level exceeded. Only " + str(__max-qs-level) + " levels are supported.", | ||
) | ||
|
||
// Gutter between the question number and the question body. | ||
let gut = 0.45em | ||
// Width of the question number, which is the width of an enum number. | ||
let w = measure(enum.item([])).width | ||
// The question number#. | ||
let numbers = range(0, level + 1).map(i => str(counters.at(i).display(labels.at(i)))).join("-") | ||
// Update the duplicate question numbers. | ||
__question-duplicates.update(d => { | ||
if numbers in d.keys() { | ||
(..d, (numbers): d.at(numbers) + 1) | ||
} else { | ||
d + ((numbers): 1) | ||
} | ||
}) | ||
context grid( | ||
columns: (w, 100% - w - gut), | ||
column-gutter: gut, | ||
align: (top + right, top + left), | ||
|
||
// Question number with label. | ||
[ | ||
#counters.at(level).display(numbering.at(level)) | ||
|
||
#let occ = __question-duplicates.get().at(numbers, default: 1) | ||
#label( | ||
"qs:" | ||
+ numbers | ||
+ if occ > 1 { "_" + str(occ) } else { none }, | ||
) | ||
], | ||
// Question body. | ||
[ | ||
#if point not in (none, 0) { | ||
if type(point) == str or type(point) == content [(#point)] else if ( | ||
type(point) == int and point == 1 | ||
) [(#point point)] else [(#point points)] | ||
sym.space.thin | ||
} | ||
#body | ||
] | ||
) | ||
|
||
// Increment the question counter at the current level. | ||
counters.at(level).step() | ||
// Set all lower level question counters to 1. | ||
for i in range(level + 1, counters.len()) { | ||
counters.at(i).update(1) | ||
} | ||
// Reduce the question level, leave. | ||
__question-level.update(n => n - 1) | ||
} | ||
|
||
/// Creates a solution block. | ||
/// - body (content): The solution. | ||
/// - color (color): The color of the solution frame and text. | ||
/// - supplement (content): The supplemental text to be displayed before the solution. | ||
#let solution(body, color: green-solution, supplement: [*Solution*: ], force: false) = { | ||
context block( | ||
width: 100%, | ||
inset: 1em, | ||
stroke: color + 0.5pt, | ||
)[ | ||
#if __solution-disabled { return none } | ||
#if not force and not __solution-visible.get() { return none } | ||
#set align(left) | ||
#set text(fill: color) | ||
#supplement#body | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#let font-size = 10pt | ||
|
||
#let sections = ( | ||
"introduction", | ||
"getting-started", | ||
"setup", | ||
"author", | ||
"math", | ||
"drawing", | ||
"question", | ||
"solution", | ||
"caveats", | ||
) | ||
|
||
#let help-setup(body) = { | ||
show raw.where(block: false): r => box( | ||
fill: black.transparentize(95%), | ||
radius: 0.4em, | ||
inset: 0.35em, | ||
baseline: 0.35em, | ||
r, | ||
) | ||
|
||
body | ||
} | ||
|
||
#let help = (:) | ||
#for section in sections { | ||
help.insert( | ||
section, | ||
block( | ||
width: 100%, | ||
inset: font-size, | ||
stroke: blue + 0.5pt, | ||
[ | ||
#set text(size: font-size) | ||
#set heading(outlined: false) | ||
|
||
#text(fill: gray)[User Manual] | ||
#v(font-size * 0.5, weak: true) | ||
|
||
#show: help-setup | ||
#include "manuals/" + section + ".typ" | ||
#import "shorthand.typ": hrule | ||
#hrule | ||
|
||
#context v(par.spacing * -0.5) | ||
|
||
#text( | ||
size: font-size * 0.8, | ||
[ | ||
Other helps: #sections.filter(s => s != section).map(s => raw(s)).join(", "). | ||
], | ||
) | ||
], | ||
), | ||
) | ||
} |
Oops, something went wrong.