Skip to content

Commit

Permalink
improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Marmare314 committed Sep 30, 2023
1 parent 46f04a6 commit aa8a34a
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 374 deletions.
143 changes: 135 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,73 @@ The result should now look something like this:

## Examples

This example shows how corollaries can be numbered after the last theorem.
By default theorems are reset on every heading. This can be changed with the
`max-reset-level`
parameter of
`default-theorems()`. This also
changes which heading levels will be used in the numbering. To not reset them
at all
`max-reset-level`
can be set to 0.

```typst
#import "@preview/lemmify:0.2.0": theorem-rules, theorem-kind, select-kind, reset-counter
#import "@preview/lemmify:0.2.0": default-theorems
#let theorem = theorem-kind("Theorem")
#let corollary = theorem-kind(
"Corollary",
group: "CorollaryGroup",
#let (
theorem, theorem-rules
) = default-theorems(max-reset-level: 2)
#show: theorem-rules
#set heading(numbering: "1.1")
= Heading
#theorem(lorem(5))
== Heading
#theorem(lorem(5))
=== Heading
#theorem(lorem(5))
```

![image](docs/images/reset-example.png)

Each theorem belongs to a group and every group shares one counter. The theorems created
by
`default-theorems()`
all belong to the same group, except for proofs.
You can create seperate groups by passing a group parameter to
`default-theorems()`.
The next example shows how to create seperately numbered examples.

```typst
#import "@preview/lemmify:0.2.0": default-theorems
#let (theorem, theorem-rules) = default-theorems()
#show: theorem-rules
#let (
example, theorem-rules
) = default-theorems(group: "example-group")
#show: theorem-rules
#theorem(lorem(5))
#example(lorem(5))
#example(lorem(5))
#theorem(lorem(5))
```

![image](docs/images/group-example.png)

The link-to parameter can be used to link theorems to other content. By default
theorems are linked to the last heading and proofs are linked to the last theorem.
This example shows how corallaries can be linked to the last theorem.
Note that it's fine to only apply the
`theorem-rules`
once here since both theorem-kinds belong to the same group.

```typst
#import "@preview/lemmify:0.2.0": default-theorems, select-kind, reset-counter
#let (theorem, theorem-rules) = default-theorems()
#let (corollary,) = default-theorems(
group: "corollary-group",
link-to: select-kind(theorem)
)
#show: theorem-rules
Expand All @@ -93,7 +151,51 @@ This example shows how corollaries can be numbered after the last theorem.
#corollary(lorem(5))
```

![image](docs/images/corollary-numbering-example.png)
![image](docs/images/corollary-example.png)

The best and easiest way to change the look of theorems is to use show-rules.
The next example shows another way how the appearance of theorems can be changed.

```typst
#import "@preview/lemmify:0.2.0": default-theorems, style-simple
#let (
theorem, proof, theorem-rules
) = default-theorems(
lang: "en",
style: style-simple.with(seperator: ". "),
proof-style: style-simple.with(kind-name-style: emph, seperator: ". ")
)
#show: theorem-rules
#theorem(lorem(5))
#proof(lorem(5))
```

![image](docs/images/proof-example.png)

Doing the same thing to remarks is a bit more complicated since the style parameter applies to both theorems and remarks.

```typst
#import "@preview/lemmify:0.2.0": default-theorems, style-simple
#let (
theorem, theorem-rules
) = default-theorems(
lang: "en",
style: style-simple.with(seperator: ". ")
)
#let (remark,) = default-theorems(
style: style-simple.with(kind-name-style: emph, seperator: ". "),
numbering: none
)
#show: theorem-rules
#theorem(lorem(5))
#remark(lorem(5))
```

![image](docs/images/remark-example.png)

If the pre-defined styles are not customizable enough you can also provide your own style.

Expand Down Expand Up @@ -133,4 +235,29 @@ If the pre-defined styles are not customizable enough you can also provide your

![image](docs/images/custom-style-example.png)

For a full documentation of all functions check [readme.pdf](docs/readme.pdf)
There is one other way to create
`theorem-function`s:
the
`theorem-kind()`
function. It is used to create
the theorem-functions returned by
`default-theorems()`
so it behaves almost the same. The only difference is that there is no
`max-reset-level`
parameter and that no
`theorem-rules`
are returned.
A default rule which does not reset any theorem counters can be imported.

```typst
#import "@preview/lemmify:0.2.0": theorem-kind, theorem-rules
#let note = theorem-kind("Note")
#show: theorem-rules
#note(lorem(5))
```

![image](docs/images/kind-example.png)

For a full documentation of all functions check the [pdf-version](docs/readme.pdf) of this readme.
Loading

0 comments on commit aa8a34a

Please sign in to comment.