Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/epicericee/typst-quick-maths
A Typst package for creating custom shorthands for math equations.
https://github.com/epicericee/typst-quick-maths
typst typst-package typst-plugin
Last synced: 28 days ago
JSON representation
A Typst package for creating custom shorthands for math equations.
- Host: GitHub
- URL: https://github.com/epicericee/typst-quick-maths
- Owner: EpicEricEE
- License: mit
- Created: 2024-07-05T10:51:57.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2024-11-12T21:10:07.000Z (about 1 month ago)
- Last Synced: 2024-11-12T22:20:39.301Z (about 1 month ago)
- Topics: typst, typst-package, typst-plugin
- Language: Typst
- Homepage:
- Size: 46.9 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# quick-maths
A package for creating custom shorthands for math equations.
## Usage
The package comes with a single template function `shorthands` that takes one or more tuples of the form `(shorthand, replacement)`, where `shorthand` can be a string or content.
There are some small quality of life features for interaction of shorthands with fractions and attachments:
- If the right-most symbol of a shorthand has any attachments, they are moved to the shorthand's replacement.
- If a shorthand ends in the numerator of a fraction, the whole replacement is placed in the numerator.
- If a shorthand starts in the denominator of a fraction, the whole replacement is placed in the denominator.As the implementation of these features is quite hacky, you may encounter some edge cases, where the use of explicit parentheses hopefully saves you.
## Notes
- Shorthands are parsed in the order they are given, so if you have a shorthand that is a prefix of another shorthand, you should put the longer shorthand first.
- The content of an equation is traversed from left to right, so the left-most matching shorthand will be replaced first.
- Shorthands consisting of only a single character or element may be applied using show rules, so that they can affect non-sequence elements. This may lead to different behavior than multi-character shorthands.
- If the replacement of a shorthand contains a shorthand itself, there are no protections against infinite recursion or overflows.
## Example
```typ
#import "@preview/quick-maths:0.2.0": shorthands#show: shorthands.with(
($+-$, $plus.minus$),
($|-$, math.tack),
($<=$, math.arrow.l.double) // Replaces '≤'
)$ x^2 = 9 quad <==> quad x = +-3 $
$ A or B |- A $
$ x <= y $
```![Result of example code.](./assets/example.svg)