Open-source project
Leedehai/typst-physics avatar
Leedehai/typst-physics

physica: physics notation for Typst documents

physica: vectors, fields, differentials, derivatives, Dirac brakets, tensors, and more. See examples in the manual PDF.

620 stars26 forksTypstMIT

At a glance

What is it?
physica is a Typst package that adds braces, vectors and vector fields, Jacobian and Hessian matrices, Dirac braket notation, tensor abstract index notation and mixed partial derivatives to a Typst document. It is MIT licensed for the code, and its documentation is a PDF manual generated from the package itself.
Who is it for?
Adopt physica if you write physics or mathematics in Typst and want consistent notation for vectors, brakets, tensors and derivatives without hand building every symbol. Skip it if you typeset in LaTeX, where the equivalent packages and a much larger body of examples already exist, and skip it if you cannot pin a Typst version, since the package declares a compiler requirement and errors on an unsupported one.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 41 days ago.
What is it written in?
Mainly Typst, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

A notation package, not a computation package

physica is a Typst package providing typesetting utilities for the natural sciences, and the list of what it covers is specific enough to be worth reading in full. There are braces. There are vectors and vector fields. There are special matrices, including the Jacobian and the Hessian. There is smart rendering of the transpose marker as a transpose and the dagger marker as a conjugate transpose, so you write the symbol and the package decides how it reads. There are Dirac braket notations. There are common math functions. There are differentials and derivatives, including partial derivatives of mixed orders with automatic order summation, which is the feature that saves the most typing, since a fourth order mixed derivative no longer needs its four indices written in the order you happen to be thinking about. And there is a family of familiar shorthands, the h-bar, tensor abstract index notations, isotopes, and the Taylor series term. The word to keep in mind is typesetting. The package renders notation; it does not compute Jacobians or evaluate derivatives. If you want arithmetic, you want something else, and if you want a document that reads like a physics paper, this is the part you need.

Three import styles, and why the choice matters

Using the package with Typst's own package management is the recommended route, and the README shows three import styles for the same set of symbols. The first imports everything.

typst
// Style 1
#import "@preview/physica:0.9.8": *

$ curl (grad f), tensor(T, -mu, +nu), pdv(f,x,y,[1,2]) $

The second names the specific symbols you want.

typst
// Style 2
#import "@preview/physica:0.9.8": curl, grad, tensor, pdv

$ curl (grad f), tensor(T, -mu, +nu), pdv(f,x,y,[1,2]) $

The third imports the module itself and qualifies each call.

typst
// Style 3
#import "@preview/physica:0.9.8"

$ physica.curl (physica.grad f), physica.tensor(T, -mu, +nu), physica.pdv(f,x,y,[1,2]) $

The difference between style 1 and style 2 is name collisions, since a wildcard import of a notation package can shadow symbols you already use, and style 3 costs you a qualifier on every call in exchange for never colliding at all. The same three examples appear with an undecorated file path when you are not using Typst's package management, importing physica.typ directly. Package management is also what makes the version visible in the import string, since the preview path pins 0.9.8, and the README notes that the local compiler downloads packages on demand and caches them on disk while the web app has them readily available.

The compiler version is a hard requirement, not a suggestion

The Typst version section is short and unambiguous. The version requirement for the compiler is in the compiler field of typst.toml, and if you are using an unsupported Typst version the compiler will throw an error. The README offers two ways forward, updating your compiler with typst update, or choosing an earlier version of the physica package. The package was developed with Typst 0.14.0, as the version check reports. This is the price of Typst's package system, and it is a real cost rather than a formality. Typst's API still moves, a package written against 0.14 can fail to compile under a newer compiler, and the fix is either an upgrade or a downgrade of the package, which in a document that pins a version means an edit to your import line. The pattern of pinning the version inside the import path is what makes this manageable, since a project can stay on 0.9.8 of physica while the compiler moves, and the compiler field tells you when that combination stops working. The repository ships a pkg-repo.py script alongside physica.typ, typst.toml and the manual, which is the packaging machinery for the preview repository.

The manual is a PDF generated by Typst, and that is the documentation strategy

The documentation for physica is a PDF manual, linked from the top of the README, and the description says to see the examples in the manual PDF. The manual is not a hand-written document, it is generated directly with the Typst binary from physica-manual.typ, which is in the repository alongside the generated physica-manual.pdf. To regenerate it, the README gives one command.

sh
typst watch physica-manual.typ

That has two consequences. The first is that the examples you see are real, compiled output rather than descriptions of intended behaviour, so if a symbol renders a particular way in the manual, that is what the package does. The second is that the manual doubles as the package's test suite, and the contribution section admits this. Testing is currently done by closely inspecting the generated manual, which does not scale well, and the author plans to add programmatic testing by comparing rendered pictures with golden images. For a notation package that is a defensible interim arrangement, since most of what can go wrong is a symbol rendering in an unexpected way, and a human reading the PDF catches that where a unit test on a string would not. The larger demo.typ file in the repository gives a longer tour of the same features, and there is a changelog.md for the release history. The most recent tags are v0.9.8 from 2025-12-20, v0.9.7 from 2025-10-27 and v0.9.6 from 2025-10-25, so the version numbers track Typst compatibility closely and the last push to the repository was on 2026-09-12.

Two licences, one for the code and one for the documentation

The license section splits the project in two. The code is under the MIT License, in the LICENSE.txt file, and the docs are under the Creative Commons BY-ND 4.0 licence. That is a sensible split for a package like this, since the code is meant to be embedded in your document pipeline and MIT asks nothing of you, while the manual is a creative work with a defined licence that permits sharing with attribution but not derivative works. The practical effect is that you can take the code into a commercial or non-commercial document without restriction, and you can quote and redistribute the manual with attribution, but you should not produce a modified manual and publish it as your own. For a package distributed through the Typst package collection, the split means the license field in typst.toml presumably covers the code, since that is what the package collection deals in. The repository also has the usual project files, a .github directory with a CI workflow badge, a .gitignore, and a LICENSE.txt alongside the documentation links. The name comes with a definition too, since the README glosses physica as a Latin noun meaning the study of nature, which is a small piece of typographic courtesy rather than a technical detail.

A Typst notation package against the LaTeX physics ecosystem

The alternative for anyone typesetting physics is LaTeX, and it is a strong one, since there are long-established packages for vectors, tensors, bra-ket notation, differential operators and the rest, along with decades of accumulated examples, journal templates and troubleshooting. The difference in approach is worth stating plainly. A LaTeX physics setup is a large body of conventions and macros that you assemble, configure and often fight with, and the quality of the output depends on how well you have tuned that stack. physica is a single package with a coherent set of conventions, and because it is a Typst package it inherits Typst's own virtues, which is to say a typesetting system with sane defaults and a scriptable, programmable design where a function can be a first class value. The cost is the smallness of the ecosystem. There is one manual, the author, and a package whose version is pinned to a Typst release, so when a Typst update lands you are negotiating with a much smaller body of maintainers than the LaTeX world provides. A physics paper being written for publication is not a good fit for the smaller side of that trade, while notes, slides, a course handout or a thesis draft are exactly where a package this focused earns its keep. Typst's own templates and start projects are worth checking as well, since a general Typst template may already cover the notation you need without a physics specific package at all.

Editorial conclusion

Adopt physica if you write physics or mathematics in Typst and want consistent notation for vectors, brakets, tensors and derivatives without hand building every symbol. Skip it if you typeset in LaTeX, where the equivalent packages and a much larger body of examples already exist, and skip it if you cannot pin a Typst version, since the package declares a compiler requirement and errors on an unsupported one. Verify first that your compiler satisfies the compiler field in typst.toml, that the import path style you prefer works with the version you fetch, and that the manual PDF covers the functions you need before you commit to it.

Frequently asked questions

How do I import physica into a Typst document?

With Typst package management, use one of three styles: import everything with `#import "@preview/physica:0.9.8": *`, import named symbols such as curl, grad, tensor and pdv, or import the module and qualify calls with physica. Without package management, import the undecorated file path like "physica.typ".

Which Typst version does physica require?

The requirement is declared in the compiler field of typst.toml, and the package was developed with Typst 0.14.0. Using an unsupported Typst version makes the compiler throw an error, and the fix is to update the compiler or to pin an earlier version of physica.

What does the physica package provide for derivatives?

It provides differentials and derivatives, including partial derivatives of mixed orders with automatic order summation, so the order of the indices does not have to be written out by hand. It also provides common math functions, braces, vectors and vector fields, Jacobian and Hessian matrices, Dirac braket notation and tensor abstract index notation.

Official sources

  1. Leedehai/typst-physics on GitHub
  2. License: MIT
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/leedehai-typst-physics.svg)](https://hysenlabs.com/projects/leedehai-typst-physics)

Was this useful?