A typst package providing environments for theorems and proofs.
Usage
Before using any of the features this package has to offer, add the following lines to the top of your document:
#import "@preview/thmbox:0.1.1": *
#show: thmbox-init()
Now, the basic building block for thmbox environments is thmbox
:
#thmbox[
This is a basic Thmbox
] <basic-box>
It can be referenced (see @basic-box).
Using the color
, variant
, and title
parameters, we can style this box:
#thmbox(
variant: "Important Theorem",
title: "Fundamental Theorem of Math",
color: red
)[
A statement can only be believed if it is proven.
]
To prove this statement, we can follow up with a proof
:
#proof[
Proven by obviousness.
]
For your environments, Thmbox actually ships with a variety of predefined ones, for theorems, corollaries, definitions, examples, etc:
Usage Notes
The recommended way of implementing new types of thmboxes is like this:
#let important(
// Specify parameters you want to change
fill: rgb("#ffdcdc"),
variant: "Important",
color: red,
// Use an args sink
..args
) = note(fill: fill, variant: variant, color: color, ..args)
// derive from some predefined function
#important[
This is in fact very important!
]
Of course, deriving from thmbox
is just as good, but the predefined environments have some other parameters already set as well.
As set rules don’t work with user-defined functions, a similar effect can be achieved the following way:
// Define your custom thmbox
#let my-thmbox(
// Specify parameters you want to change
fill: rgb("#fffdd3"),
// Use an args sink
..args
) = thmbox(fill: fill, ..args)
// redefine predefined environments
#let my-definition(..args) = definition(thmbox: my-thmbox, ..args)
// use
#my-definition[
This definition has a yellow background!
]
The recommended font for documents using this package is New Computer Modern (shipped with Typst).
The recommended sans-serif font (can be changed with the sans-fonts
and title-fonts
parameter) is New Computer Modern Sans (download at CTAN)
By default, the counter for thmboxes has two levels where the first one marks the chapter and the second gets reset at the start of each chapter. To change that, use the counter-level
parameter of thmbox-init
. The default is 2, but for example, 1 will be one number counting in the entire document, 3 will count per section, and so on.
Also by default, thmboxes don’t break across pages. To enable that, you can use the rule #show figure: set block(breakable: true)
. Other set
and show
rules for figures can be used with thmboxes as well, as figures are used under the hood.
Installation
No steps are required when installing from @preview
. To install this package locally, do
cd /typst/packages/local/thmbox
git clone https://github.com/s15n/typst-thmbox.git 0.1.1
where <data-dir>
is
$XDG_DATA_HOME
or~/.local/share
on Linux~/Library/Application Support
on macOS%APPDATA%
on Windows
You might have to create the folder in the first line first.
Translations
Thmbox automatically translates to the language of your document (if translations are available for it).
Translations are found in src/translations.typ. You are welcome to contribute for languages you speak.