{"id":13524864,"url":"https://github.com/sahasatvik/typst-theorems","last_synced_at":"2025-04-01T03:32:51.001Z","repository":{"id":156202706,"uuid":"620338585","full_name":"sahasatvik/typst-theorems","owner":"sahasatvik","description":"An implementation of numbered theorem environments in typst","archived":false,"fork":false,"pushed_at":"2024-10-20T21:36:43.000Z","size":8126,"stargazers_count":204,"open_issues_count":18,"forks_count":12,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-21T02:07:04.306Z","etag":null,"topics":["typst"],"latest_commit_sha":null,"homepage":"","language":"Typst","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sahasatvik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-28T13:41:53.000Z","updated_at":"2024-10-20T23:11:04.000Z","dependencies_parsed_at":"2024-01-13T22:25:07.287Z","dependency_job_id":"0e9a7ae5-1893-4c15-b3cf-f8a21cb9221b","html_url":"https://github.com/sahasatvik/typst-theorems","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sahasatvik%2Ftypst-theorems","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sahasatvik%2Ftypst-theorems/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sahasatvik%2Ftypst-theorems/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sahasatvik%2Ftypst-theorems/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sahasatvik","download_url":"https://codeload.github.com/sahasatvik/typst-theorems/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222698187,"owners_count":17024877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["typst"],"created_at":"2024-08-01T06:01:14.112Z","updated_at":"2024-11-02T09:30:33.281Z","avatar_url":"https://github.com/sahasatvik.png","language":"Typst","funding_links":[],"categories":["Templates \u0026 Libraries","库和工具类","Typst"],"sub_categories":["Mathematics","数学"],"readme":"# typst-theorems\n\nAn implementation of numbered theorem environments in\n[typst](https://github.com/typst/typst).\nAvailable as [ctheorems](https://typst.app/universe/package/ctheorems) in the\nofficial Typst Universe.\nImport with\n\n```typst\n#import \"@preview/ctheorems:1.1.3\": *\n#show: thmrules\n```\n\nAlternatively, copy and import the [theorems.typ](theorems.typ) file to use in\nyour own projects.\n\n### Features\n- Numbered theorem environments can be created and customized.\n- Environments can share the same counter, via same `identifier`s.\n- Environment counters can be _attached_ (just as subheadings are attached to headings) to other environments, headings, or keep a global count via `base`.\n- The depth of a counter can be manually set, via `base_level`.\n- Environments can be `\u003clabel\u003e`'d and `@reference`'d.\n\n## Manual and Examples\nGet acquainted with `typst-theorems` by checking out the minimal example below!\n\nYou can read the [manual](manual.pdf) for a full walkthrough of functionality offered by this module; flick through [manual_examples](manual_examples.pdf) and its [typ file](manual_examples.typ) to just see the examples.\n\nThe [differential_calculus.typ](differential_calculus.typ) ([render](differential_calculus.pdf)) project provides a practical use case. _(Hastily translated from my notes written in LaTeX)_\n\n![basic example](basic.png)\n\n### Preamble\n```typst\n#import \"theorems.typ\": *\n#show: thmrules.with(qed-symbol: $square$)\n\n#set page(width: 16cm, height: auto, margin: 1.5cm)\n#set text(font: \"Libertinus Serif\", lang: \"en\")\n#set heading(numbering: \"1.1.\")\n\n#let theorem = thmbox(\"theorem\", \"Theorem\", fill: rgb(\"#eeffee\"))\n#let corollary = thmplain(\n  \"corollary\",\n  \"Corollary\",\n  base: \"theorem\",\n  titlefmt: strong\n)\n#let definition = thmbox(\"definition\", \"Definition\", inset: (x: 1.2em, top: 1em))\n\n#let example = thmplain(\"example\", \"Example\").with(numbering: none)\n#let proof = thmproof(\"proof\", \"Proof\")\n```\n\n### Document\n```typst\n= Prime numbers\n\n#definition[\n  A natural number is called a #highlight[_prime number_] if it is greater\n  than 1 and cannot be written as the product of two smaller natural numbers.\n]\n#example[\n  The numbers $2$, $3$, and $17$ are prime.\n  @cor_largest_prime shows that this list is not exhaustive!\n]\n\n#theorem(\"Euclid\")[\n  There are infinitely many primes.\n]\n#proof[\n  Suppose to the contrary that $p_1, p_2, dots, p_n$ is a finite enumeration\n  of all primes. Set $P = p_1 p_2 dots p_n$. Since $P + 1$ is not in our list,\n  it cannot be prime. Thus, some prime factor $p_j$ divides $P + 1$.  Since\n  $p_j$ also divides $P$, it must divide the difference $(P + 1) - P = 1$, a\n  contradiction.\n]\n\n#corollary[\n  There is no largest prime number.\n] \u003ccor_largest_prime\u003e\n#corollary[\n  There are infinitely many composite numbers.\n]\n\n#theorem[\n  There are arbitrarily long stretches of composite numbers.\n]\n#proof[\n  For any $n \u003e 2$, consider $\n    n! + 2, quad n! + 3, quad ..., quad n! + n #qedhere\n  $\n]\n```\n\n\n## Acknowledgements\n\nThanks to\n\n- [MJHutchinson](https://github.com/MJHutchinson) for suggesting and\n  implementing the `base_level` and `base: none` features,\n- [rmolinari](https://github.com/rmolinari) for suggesting and\n  implementing the `separator: ...` feature,\n- [DVDTSB](https://github.com/DVDTSB) for contributing\n  - the idea of passing named arguments from the theorem directly to the `fmt`\n    function.\n  - the `number: ...` override feature.\n  - the `title: ...` override feature in `thmbox`.\n- [PgBiel](https://github.com/PgBiel) for fixing breaking changes in version\n  updates.\n- The awesome devs of [typst.app](https://typst.app/) for their\n  support.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsahasatvik%2Ftypst-theorems","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsahasatvik%2Ftypst-theorems","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsahasatvik%2Ftypst-theorems/lists"}