diff --git a/README.md b/README.md index 18ef317..d9ab5e9 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ The [differential_calculus.typ](differential_calculus.typ) ([render](differentia #show: thmrules #set page(width: 16cm, height: auto, margin: 1.5cm) +#set text(font: "Linux Libertine", lang: "en") #set heading(numbering: "1.1.") #let theorem = thmbox("theorem", "Theorem", fill: rgb("#eeffee")) @@ -51,8 +52,8 @@ The [differential_calculus.typ](differential_calculus.typ) ([render](differentia = Prime numbers #definition[ - A natural number is called a _prime number_ if it is greater than 1 - and cannot be written as the product of two smaller natural numbers. + A natural number is called a #highlight[_prime number_] if it is greater + than 1 and cannot be written as the product of two smaller natural numbers. ] #example[ The numbers $2$, $3$, and $17$ are prime. @@ -76,6 +77,21 @@ The [differential_calculus.typ](differential_calculus.typ) ([render](differentia #corollary[ There are infinitely many composite numbers. ] - ``` + +## Acknowledgements + +Thanks to + +- [MJHutchinson]("https://github.com/MJHutchinson") for suggesting and + implementing the `base_level` and `base: none` features, +- [rmolinari]("https://github.com/rmolinari") for suggesting and + implementing the `separator: ...` feature, +- [DVDTSB]("https://github.com/DVDTSB") for contributing + - the idea of passing named arguments from the theorem directly to the `fmt` + function. + - the `number: ...` override feature. + - the `title: ...` override feature in `thmbox`. +- The awesome devs of [typst.app]("https://typst.app/") for their + support. diff --git a/basic.pdf b/basic.pdf index 71a1bc1..7c3bb7a 100644 Binary files a/basic.pdf and b/basic.pdf differ diff --git a/basic.png b/basic.png index 86d132a..6f41037 100644 Binary files a/basic.png and b/basic.png differ diff --git a/basic.typ b/basic.typ index bb89c3c..55737b3 100644 --- a/basic.typ +++ b/basic.typ @@ -26,8 +26,8 @@ = Prime numbers #definition[ - A natural number is called a _prime number_ if it is greater than 1 - and cannot be written as the product of two smaller natural numbers. + A natural number is called a #highlight[_prime number_] if it is greater + than 1 and cannot be written as the product of two smaller natural numbers. ] #example[ The numbers $2$, $3$, and $17$ are prime. diff --git a/differential_calculus.pdf b/differential_calculus.pdf index f67a830..ebb4c6e 100644 Binary files a/differential_calculus.pdf and b/differential_calculus.pdf differ diff --git a/manual.pdf b/manual.pdf index 63a9681..e667ba8 100644 Binary files a/manual.pdf and b/manual.pdf differ diff --git a/manual.typ b/manual.typ index 9ffa6ab..6bde365 100644 --- a/manual.typ +++ b/manual.typ @@ -180,6 +180,18 @@ sets some plainer defaults. You can also write Note that the last _Lemma_ is _not_ numbered 3.1.2! +You can also override the automatic numbering as follows. +```typst +#lemma(number: "42")[ + The square of any natural number cannot be two more than a multiple of 4. +] +``` +#lemma(number: "42")[ + The square of any natural number cannot be two more than a multiple of 4. +] + +Note that this does _not_ affect the counters either! + == Limiting depth @@ -286,9 +298,10 @@ You can go even further and use the `thmenv` function directly. It accepts an "Notation", // supplement none, // base - do not attach, count globally none, // base_level - use the base as-is - (name, number, body) => [ // fmt - format content using the environment - // name, number, and body - #h(1.2em) *Notation (#number) #name*: + (name, number, body, color: black) => [ + // fmt - format content using the environment + // name, number, body, and an optional color + #text(color)[#h(1.2em) *Notation (#number) #name*]: #h(0.2em) #body #v(0.5em) @@ -298,14 +311,18 @@ You can go even further and use the `thmenv` function directly. It accepts an #notation[ The variable $p$ is reserved for prime numbers. ] +#notation("for Reals", color: green)[ + The variable $x$ is reserved for real numbers. +] ``` #let notation = thmenv( "notation", // identifier "Notation", // supplement none, // base - do not attach, count globally none, // base_level - use the base as-is - (name, number, body) => [ // fmt - format content using the environment name, number, and body - #h(1.2em) *Notation (#number) #name*: + (name, number, body, color: black) => [ + // fmt - format content using the environment name, number, body, and an optional color + #text(color)[#h(1.2em) *Notation (#number) #name*]: #h(0.2em) #body #v(0.5em) @@ -315,6 +332,27 @@ You can go even further and use the `thmenv` function directly. It accepts an #notation[ The variable $p$ is reserved for prime numbers. ] +#notation("for Reals", color: green)[ + The variable $x$ is reserved for real numbers. +] + +Note that the `color: green` named argument supplied to the theorem +environment gets passed to the `fmt` function. In general, all extra named +arguments supplied to the theorem will be passed to `fmt`. +On the other hand, the positional argument `"for Reals"` will always be +interpreted as the `name` argument in `fmt`. + +```typst +#lemma(title: "Lem.")[ + All multiples of 3 greater than 3 are composite. +] +``` +#lemma(title: "Lem.")[ + All multiples of 3 greater than 3 are composite. +] + +Here, we override the `title` (which defaults to the `head`) in the `fmt` +produced by `thmbox`. == Labels and references @@ -392,15 +430,20 @@ The `thmenv` function produces a _theorem environment_. base, // base counter name, can be "heading" or none base_level, // number of base number levels to use fmt // formatting function of the form - // (name, number, body) -> content + // (name, number, body, ..args) -> content ) = { ... } ``` +The `fmt` function must aceept a theorem `name`, `number`, `body`, and produce +formatted content. It may also accept additional positional arguments, via +`args`. + A _theorem environment_ is itself a map of the following form. ```typst ( - ..name, // name, often used in the title + ..args, body, // body content + number: auto, // number, overrides numbering if present numbering: "1.1", // numbering style, can be a function refnumbering: auto, // numbering style used in references, // defaults to "numbering" @@ -409,6 +452,11 @@ A _theorem environment_ is itself a map of the following form. ) -> content ``` +Positional arguments in `args` are as follows +- `name`: The name of the theorem, typically displayed after the title. + +All additional named arguments in `args` will be passed on to the associated +`fmt` function supplied in `thmenv`. == `thmbox` and `thmplain` @@ -452,8 +500,15 @@ defaults. = Acknowledgements -Thanks to #link("https://github.com/MJHutchinson")[MJHutchinson] for -suggesting and implementing the `base_level` and `base: none` features, -#link("https://github.com/rmolinari")[rmolinari] for suggesting and -implementing the `separator: ...` feature, and to the awesome devs of -#link("https://typst.app/")[typst.app] for their support. +Thanks to +- #link("https://github.com/MJHutchinson")[MJHutchinson] for suggesting and + implementing the `base_level` and `base: none` features, +- #link("https://github.com/rmolinari")[rmolinari] for suggesting and + implementing the `separator: ...` feature, +- #link("https://github.com/DVDTSB")[DVDTSB] for contributing + - the idea of passing named arguments from the theorem directly to the `fmt` + function. + - the `number: ...` override feature. + - the `title: ...` override feature in `thmbox`. +- The awesome devs of #link("https://typst.app/")[typst.app] for their + support. diff --git a/manual_examples.pdf b/manual_examples.pdf index 4a50f0f..ee57150 100644 Binary files a/manual_examples.pdf and b/manual_examples.pdf differ diff --git a/manual_examples.typ b/manual_examples.typ index 6f02de5..d0ab5a7 100644 --- a/manual_examples.typ +++ b/manual_examples.typ @@ -68,7 +68,9 @@ these has been explained in full detail there. #lemma[ The square of any odd number is one more than a multiple of $4$. ] - +#lemma(number: "42")[ + The square of any natural number cannot be two more than a multiple of 4. +] == Limiting depth @@ -120,8 +122,9 @@ these has been explained in full detail there. "Notation", // supplement none, // base - do not attach, count globally none, // base_level - use the base as-is - (name, number, body) => [ // fmt - format content using the environment name, number, and body - #h(1.2em) *Notation (#number) #name*: + (name, number, body, color: black) => [ + // fmt - format content using the environment name, number, body, and an optional color + #text(color)[#h(1.2em) *Notation (#number) #name*]: #h(0.2em) #body #v(0.5em) @@ -131,7 +134,13 @@ these has been explained in full detail there. #notation[ The variable $p$ is reserved for prime numbers. ] +#notation("for Reals", color: green)[ + The variable $x$ is reserved for real numbers. +] +#lemma(title: "Lem.")[ + All multiples of 3 greater than 3 are composite. +] == Labels and references diff --git a/theorems.typ b/theorems.typ index 0046db6..69db8dd 100644 --- a/theorems.typ +++ b/theorems.typ @@ -13,24 +13,26 @@ let global_numbering = numbering return ( - ..name, + ..args, body, + number: auto, numbering: "1.1", refnumbering: auto, base: base, base_level: base_level ) => { - if name != none and name.pos().len() > 0 { - name = name.pos().first() - } else { - name = none + let name = none + if args != none and args.pos().len() > 0 { + name = args.pos().first() } if refnumbering == auto { refnumbering = numbering } - let number = none let result = none - if not numbering == none { + if number == auto and numbering == none { + number = [] + } + if number == auto and numbering != none { result = locate(loc => { return thmcounters.update(thmpair => { let counters = thmpair.at("counters") @@ -79,7 +81,7 @@ } figure( result + // hacky! - align(left, fmt(name, number, body)) + + align(left, fmt(name, number, body, ..args.named())) + figure(none, supplement: none, numbering: none, kind: "thmenv-counter", gap: 0em), // even more hacky! kind: "thmenv", outlined: false, @@ -111,13 +113,15 @@ if supplement == auto { supplement = head } - let boxfmt(name, number, body) = { + let boxfmt(name, number, body, title: auto) = { if not name == none { name = [ #namefmt(name)] } else { name = [] } - let title = head + if title == auto { + title = head + } if not number == none { title += " " + number }