diff --git a/packages/preview/lacy-ubc-math-project/0.1.0/format.typ b/packages/preview/lacy-ubc-math-project/0.1.0/format.typ index 4e8f9454e..0722ba78b 100644 --- a/packages/preview/lacy-ubc-math-project/0.1.0/format.typ +++ b/packages/preview/lacy-ubc-math-project/0.1.0/format.typ @@ -136,3 +136,68 @@ #supplement#body ] } + +#let get-orientation(dir) = { + if dir == ltr { + return ( + dir: ltr, + cols: (1fr, 1fr), + align: (x, y) => horizon + (right, left).at(calc.rem(x, 2)), + line: grid.vline, + ) + } else if dir == ttb { + return ( + dir: ttb, + cols: 1, + align: (x, y) => (bottom, top).at(calc.rem(y, 2)), + line: grid.hline, + ) + } +} + +#let showcode(code, dir: ltr) = { + import "@preview/showman:0.1.2": runner + let prefix-orig = ( + "#import \"@preview/lacy-ubc-math-project:0.1.0\": *", + "#let __example-question-counters = range(1, unsafe.__max-qs-level + 1).map(i => counter(\"example-question-\" + str(i)))", + "#for c in __example-question-counters {", + " c.update(1)", + "}", + "#let __example-question-labels = (\"ex:1\", \"a\", \"i\",)", + "#set text(font: (\"DejaVu Serif\", \"New Computer Modern\"))", + "#let question = question.with(counters: __example-question-counters, labels: __example-question-labels)", + "#set math.equation(numbering: \"(1.1)\")", + "#show: equate.with(breakable: true, sub-numbering: true)", + ).join("\n") + let suffix-orig = "" + let orientation = get-orientation(dir) + let prefix = prefix-orig + let suffix = suffix-orig + if code.lang == "typc" { + prefix = prefix + "\n#{" + suffix = "}\n" + suffix + } + + runner.standalone-example( + code, + eval-prefix: prefix, + eval-suffix: suffix, + direction: orientation.dir, + container: (input, output, direction: ltr) => { + block( + // breakable: false, + width: 100%, + grid( + columns: orientation.cols, + align: orientation.align, + inset: (x: 1em, y: 0.8em), + grid.cell(input), + orientation.at("line")(stroke: 0.5pt), + grid.cell(output), + ), + ) + }, + ) +} + + diff --git a/packages/preview/lacy-ubc-math-project/0.1.0/help.typ b/packages/preview/lacy-ubc-math-project/0.1.0/help.typ index 80950b0d0..75a6b8ced 100644 --- a/packages/preview/lacy-ubc-math-project/0.1.0/help.typ +++ b/packages/preview/lacy-ubc-math-project/0.1.0/help.typ @@ -12,72 +12,7 @@ "caveats", ) -#let get-orientation(tag) = { - if tag == { - return ( - dir: ltr, - cols: (1fr, 1fr), - align: (x, y) => horizon + (right, left).at(calc.rem(x, 2)), - line: grid.vline, - ) - } else if tag == { - return ( - dir: ttb, - cols: 1, - align: (x, y) => (bottom, top).at(calc.rem(y, 2)), - line: grid.hline, - ) - } -} - #let help-setup(body) = { - import "@preview/showman:0.1.2": runner - let prefix-orig = ( - "#import \"@preview/lacy-ubc-math-project:0.1.0\": *", - "#let __example-question-counters = range(1, unsafe.__max-qs-level + 1).map(i => counter(\"example-question-\" + str(i)))", - "#for c in __example-question-counters {", - " c.update(1)", - "}", - "#let __example-question-labels = (\"ex:1\", \"a\", \"i\",)", - "#set text(font: (\"DejaVu Serif\", \"New Computer Modern\"))", - "#let question = question.with(counters: __example-question-counters, labels: __example-question-labels)", - "#set math.equation(numbering: \"(1.1)\")", - "#show: equate.with(breakable: true, sub-numbering: true)", - ).join("\n") - let suffix-orig = "" - show raw.where(block: true): it => context { - if "label" in it.fields() and it.label in (, ) and it.lang in ("typst", "typc") { - let orientation = get-orientation(it.label) - let prefix = prefix-orig - let suffix = suffix-orig - if it.lang == "typc" { - prefix = prefix + "\n#{" - suffix = "}\n" + suffix - } - - runner.standalone-example( - it, - eval-prefix: prefix, - eval-suffix: suffix, - direction: orientation.dir, - container: (input, output, direction: ltr) => { - block( - // breakable: false, - width: 100%, - grid( - columns: orientation.cols, - align: orientation.align, - inset: (x: 1em, y: 0.8em), - grid.cell(input), - orientation.at("line")(stroke: 0.5pt), - grid.cell(output), - ), - ) - }, - ) - } else { it } - } - show raw.where(block: false): r => box( fill: black.transparentize(95%), radius: 0.4em, diff --git a/packages/preview/lacy-ubc-math-project/0.1.0/manual.pdf b/packages/preview/lacy-ubc-math-project/0.1.0/manual.pdf index 6db43ac2f..c9a76383f 100644 Binary files a/packages/preview/lacy-ubc-math-project/0.1.0/manual.pdf and b/packages/preview/lacy-ubc-math-project/0.1.0/manual.pdf differ diff --git a/packages/preview/lacy-ubc-math-project/0.1.0/manuals/author.typ b/packages/preview/lacy-ubc-math-project/0.1.0/manuals/author.typ index 29a31c1a0..4bf4a4acf 100644 --- a/packages/preview/lacy-ubc-math-project/0.1.0/manuals/author.typ +++ b/packages/preview/lacy-ubc-math-project/0.1.0/manuals/author.typ @@ -1,3 +1,5 @@ +#import "../format.typ": showcode + = Author The `author()` function is to be used as an argument of the `setup()` function, providing an author dictionary. It takes the first name, last name, and student number as arguments. For example, ```typst @@ -7,9 +9,9 @@ The `author()` function is to be used as an argument of the `setup()` function, ) ``` Inside, the `author()` function will return a dictionary: -```typc +#showcode(```typc author("Jane", "Doe", 12345678) -``` +```) And in the PDF metadata there will be a "Jane Doe" in the authors field, student number not included. @@ -24,22 +26,22 @@ Hypothesize that In this case, we can - provide an English translation of the name; - use the `strname` argument to specify the English version of the name. -```typc +#showcode(```typc author( "Alex", "k\u{02b7}ik\u{02b7}\u{0259}\u{019b}\u{0313} (Coquitlam)", 12345678, strname: "Alex Coquitlam" ) -``` +```) If `strname` is set, it will be used in the PDF metadata instead of the displayed name. In some more extreme cases, `strname` would be a necessity, rather than a backup. Take name #underline(text(fill: purple)[Ga])#strike[*_lli_*]#overline($cal("leo")$) as an example. The name is so special that it cannot be converted to plain text. In this case, you must provide a `strname` to avoid incomprehensible PDF metadata. -```typc +#showcode(```typc author( [#underline(text(fill: purple)[Ga])#strike[*_lli_*]#overline($cal("leo")$)], "Smith", 12345678, strname: "Gallileo Smith" ) -``` +```, dir: ttb) diff --git a/packages/preview/lacy-ubc-math-project/0.1.0/manuals/drawing.typ b/packages/preview/lacy-ubc-math-project/0.1.0/manuals/drawing.typ index 6580e910a..04fd7c42e 100644 --- a/packages/preview/lacy-ubc-math-project/0.1.0/manuals/drawing.typ +++ b/packages/preview/lacy-ubc-math-project/0.1.0/manuals/drawing.typ @@ -1,3 +1,5 @@ +#import "../format.typ": showcode + = Drawing As we are doing math, inevitably we will need to draw some graphs. @@ -35,7 +37,7 @@ Find more visualization packages #link("https://staging.typst.app/universe/searc Besides importing the drawing packages, the `drawing` module also provides some helper functions. For example, the `cylinder()` function draws an upright no-perspective cylinder. -```typst +#showcode(```typst #import drawing: * #cetz.canvas({ import cetz.draw: * @@ -50,7 +52,7 @@ For example, the `cylinder()` function draws an upright no-perspective cylinder. ) }) }) -``` +```) == Example//s #[ diff --git a/packages/preview/lacy-ubc-math-project/0.1.0/manuals/getting-started.typ b/packages/preview/lacy-ubc-math-project/0.1.0/manuals/getting-started.typ index 6cd192d0c..a95645f67 100644 --- a/packages/preview/lacy-ubc-math-project/0.1.0/manuals/getting-started.typ +++ b/packages/preview/lacy-ubc-math-project/0.1.0/manuals/getting-started.typ @@ -1,3 +1,5 @@ +#import "../format.typ": showcode + = Getting Started #quote[So, how do I even start using Typst?] @@ -66,7 +68,7 @@ Below this ```typst #show: setup.with(...)``` is your project content. == Questions & Solutions A math group project mostly consists of questions and solutions. You can use the ```typc question()``` and ```typc solution()``` functions to structure your content. -```typst +#showcode(```typst #question(1)[ What is the answer to the universe, life, and everything? // The solution should be in the question. @@ -81,13 +83,13 @@ A math group project mostly consists of questions and solutions. You can use the ] ] ] -``` +```) == Learn Typst Yes, you do have to learn it, but it is simple (for our purpose). Here is a quick peek at some useful syntaxes: -```typst +#showcode(```typst You will sometimes _emphasize important information_ in your questions and solutions. // 1 linebreak = 1 space. Or, go a step further to *boldly* state the matter. // to place a label. // 1+ blank lines = 1 paragraph break. @@ -101,7 +103,7 @@ $ // #link()[displayed text] to reference a label. // For equation, figure and bibliography, @label-name is also available. Want to get #link()[*_bold_*]? Let's look at @eq:ex:lim. -``` +```) For general techniques, consult the #link("https://staging.typst.app/docs")[Typst documentation]. diff --git a/packages/preview/lacy-ubc-math-project/0.1.0/manuals/math.typ b/packages/preview/lacy-ubc-math-project/0.1.0/manuals/math.typ index 78fe6cc5b..75cc63217 100644 --- a/packages/preview/lacy-ubc-math-project/0.1.0/manuals/math.typ +++ b/packages/preview/lacy-ubc-math-project/0.1.0/manuals/math.typ @@ -15,76 +15,79 @@ Unlike LaTex, math in Typst is simple. "cal(l) = (-b plus.minus sqrt(b^2 - 4a c))\n\t / (2a)", ) .map(eq => [ - #raw("$" + eq + "$", lang: "typst", block: true) + #showcode(raw("$" + eq + "$", lang: "typst", block: true)) ]) .join() ) Most of the time, you have to leave a space between single letters to show consecutive letters. The template has you covered on some common multi-letter operators, like -```typst +#showcode(```typst $lim, inf$ -``` +```) For "block" or "display" math, leave a space or newline between _both_ dollar signs and the equations. -```typst +#showcode(```typst $ E = m c^2 $ -``` +```) Documented are the built-in #link("https://staging.typst.app/docs/reference/math/")[math functions] and #link("https://staging.typst.app/docs/reference/symbols/sym/")[symbols] == Texts In Math To display normal text in math mode, surround the text with double quotes function. -```typst +#showcode(```typst $x = "We are going to find out!"$ -``` +```) If you need normal single-letter text, fist see if it is a lone unit. If so, use the ```typc unit()``` function. -```typst +#showcode(```typst $unit(N) = unit(kg m s^(-2))$ -``` +```) A unit with a value is called a quantity, ```typc qty()```. -```typst +#showcode(```typst $qty(1, m) = qty(100, cm)$ -``` +```) More about these in #link()[Units and Quantities]. Otherwise, use ```typc upright()```. -```typst +#showcode(```typst $U space upright(U) space U$ -``` +```) There are other text styles available in math mode. -```typst +#showcode(```typst $serif("Serif") sans("Sans-serif") frak("Fraktur") \ mono("Monospace") bb("Blackboard bold") cal("Calligraphic")$ -``` +```) + +== Language Syntax in Math +In (at least) MATH 100 group projects, math equations is a part of your English (or whatever) writings. Make sure to use proper grammar and *punctuations*. Yes, you will add periods after finishing equations. == Numbering and Referencing Equations Note that you must enable equation numbering to reference equations, which is set by this template. Add a ```typst #``` right after the equation you wish to reference. -```typst +#showcode(```typst $ e^(i pi) = -1 # $ @eq:ex:euler is Euler's identity. \ #link()[The same reference]. -``` +```) == Extra Math Symbols and Functions The `physica` package provides additional math symbols and functions. -```typst +#showcode(```typst $A^T, curl vb(E) = - pdv(vb(B), t)$ -``` +```) -```typst +#showcode(```typst $tensor(Lambda,+mu,-nu) = dmat(1,RR)$ -``` +```) -```typst +#showcode(```typst $f(x,y) dd(x,y)$ -``` +```) It is imported in this template. @@ -92,20 +95,20 @@ It is imported in this template. Although no as common as in physics, we do sometimes need to use units and quantities. Directly typing the 'units' will not result in correct output. -```typst +#showcode(```typst $1 m = 100 cm$ -``` -```typst +```) +#showcode(```typst $N = kg m s^(-2)$ -``` +```) This template uses the `metro` package for this purpose. If you prefer, you can also import and use the `unify` package. -```typst +#showcode(```typst $qty(1, m) = qty(100, cm)$ -``` -```typst +```) +#showcode(```typst $unit(N) = unit(kg m s^(-2))$ -``` +```) As you see, the ```typc qty()``` and ```typc unit()``` functions correct the numbers, units and spacing. diff --git a/packages/preview/lacy-ubc-math-project/0.1.0/manuals/question.typ b/packages/preview/lacy-ubc-math-project/0.1.0/manuals/question.typ index 8a0e2d0a6..c29c5ba54 100644 --- a/packages/preview/lacy-ubc-math-project/0.1.0/manuals/question.typ +++ b/packages/preview/lacy-ubc-math-project/0.1.0/manuals/question.typ @@ -1,6 +1,8 @@ +#import "../format.typ": showcode + = Question The `question()` function is to create a question block. -```typst +#showcode(```typst #question(4)[ The question. #question(2)[ @@ -20,7 +22,7 @@ The `question()` function is to create a question block. The risky bonus question. ] You see #link()[that question]? -``` +```) == Referencing Questions Questions can be referenced by their automatically assigned labels. For example, question 1.b.ii has label `` and can be referenced by `#link()[That question]`. Note that it cannot be referenced by `@qs:1-b-ii`. diff --git a/packages/preview/lacy-ubc-math-project/0.1.0/template/assets/madeline-math.jpg b/packages/preview/lacy-ubc-math-project/0.1.0/template/assets/madeline-math.jpg index 970f4b53c..c6579dc6f 100644 Binary files a/packages/preview/lacy-ubc-math-project/0.1.0/template/assets/madeline-math.jpg and b/packages/preview/lacy-ubc-math-project/0.1.0/template/assets/madeline-math.jpg differ diff --git a/packages/preview/lacy-ubc-math-project/0.1.0/template/project1.typ b/packages/preview/lacy-ubc-math-project/0.1.0/template/project1.typ index 398057552..b947204d9 100644 --- a/packages/preview/lacy-ubc-math-project/0.1.0/template/project1.typ +++ b/packages/preview/lacy-ubc-math-project/0.1.0/template/project1.typ @@ -14,21 +14,21 @@ = The Problem #question(5)[ - Hey there's a cool math problem, let's solve it! + Hey, there's a cool math problem, let's solve it! // Encapsulate important visuals in figures, // so that they can be referenced later. #figure( // Include images from the assets folder. image( "assets/madeline-math.jpg", - width: 90%, - height: 30%, + width: 80%, + height: 25%, fit: "stretch", ), - // Give descriptions and credits. + // Description. + // Don't forget to give credit while using others' work. caption: [ - #link("https://preview.redd.it/madeline-has-math-homework-v0-8eaw2g1k2p191.png?auto=webp&s=8bffecf0548fb5e0ddb39eceb3e3cd933f5997c7")["Madeline has math homework"] - (#link("https://www.reddit.com/r/celestegame/comments/uxsb6t/madeline_has_math_homework/")[r/celestegame]) + Madeline's math problem (image credit: #link("https://example.com")[Badeline]). ], )