Giter Site home page Giter Site logo

typst-theorems's Introduction

typst-theorems

An implementation of numbered theorem environments in typst. Available as ctheorems in the official Typst packages. Import with

#import "@preview/ctheorems:1.1.2": *
#show: thmrules

Alternatively, copy and import the theorems.typ file to use in your own projects.

Features

  • Numbered theorem environments can be created and customized.
  • Environments can share the same counter, via same identifiers.
  • Environment counters can be attached (just as subheadings are attached to headings) to other environments, headings, or keep a global count via base.
  • The depth of a counter can be manually set, via base_level.
  • Environments can be <label>'d and @reference'd.

Manual and Examples

Get acquainted with typst-theorems by checking out the minimal example below!

You can read the manual for a full walkthrough of functionality offered by this module; flick through manual_examples and its typ file to just see the examples.

The differential_calculus.typ (render) project provides a practical use case. (Hastily translated from my notes written in LaTeX)

basic example

Preamble

#import "theorems.typ": *
#show: thmrules.with(qed-symbol: $square$)

#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"))
#let corollary = thmplain(
  "corollary",
  "Corollary",
  base: "theorem",
  titlefmt: strong
)
#let definition = thmbox("definition", "Definition", inset: (x: 1.2em, top: 1em))

#let example = thmplain("example", "Example").with(numbering: none)
#let proof = thmproof("proof", "Proof")

Document

= Prime numbers

#definition[
  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.
  @cor_largest_prime shows that this list is not exhaustive!
]

#theorem("Euclid")[
  There are infinitely many primes.
]
#proof[
  Suppose to the contrary that $p_1, p_2, dots, p_n$ is a finite enumeration
  of all primes. Set $P = p_1 p_2 dots p_n$. Since $P + 1$ is not in our list,
  it cannot be prime. Thus, some prime factor $p_j$ divides $P + 1$.  Since
  $p_j$ also divides $P$, it must divide the difference $(P + 1) - P = 1$, a
  contradiction.
]

#corollary[
  There is no largest prime number.
] <cor_largest_prime>
#corollary[
  There are infinitely many composite numbers.
]

#theorem[
  There are arbitrarily long stretches of composite numbers.
]
#proof[
  For any $n > 2$, consider $
    n! + 2, quad n! + 3, quad ..., quad n! + n #qedhere
  $
]

Acknowledgements

Thanks to

  • MJHutchinson for suggesting and implementing the base_level and base: none features,
  • rmolinari for suggesting and implementing the separator: ... feature,
  • 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 for their support.

typst-theorems's People

Contributors

sahasatvik avatar mjhutchinson avatar rmolinari avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.