diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b8c9e71..fcc544a 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -5,7 +5,7 @@ on:
tags:
- "v*.*.*"
-permissions:
+permissions:
contents: write
jobs:
diff --git a/README.md b/README.md
index 1305278..70cb82c 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,12 @@
# The physica module (for physics)
[![CI](https://github.com/Leedehai/typst-physics/actions/workflows/ci.yml/badge.svg)](https://github.com/Leedehai/typst-physics/actions/workflows/ci.yml)
-[![Latest release date](https://img.shields.io/github/release-date/Leedehai/typst-physics)][latest-release]
+[![Latest release](https://img.shields.io/github/v/release/Leedehai/typst-physics.svg?color=gold)][latest-release]
-Current semantic version: `0.7`. [Manual](physica-manual.pdf).
+The [manual](physica-manual.pdf).
+Download releases [here](https://github.com/Leedehai/typst-physics/releases/).
-Available at [https://typst.app/docs/packages/](https://typst.app/docs/packages/).
+Available at the official collection of [Typst packages](https://typst.app/docs/packages/).
This [Typst](https://typst.app) package provides handy typesetting utilities for
physics, including:
@@ -37,29 +38,34 @@ See the [manual](physica-manual.pdf) for more details.
See https://github.com/typst/packages.
+
+
+
+
```
-#import "@preview/physica:0.7.5": *
+// Style 1
+#import "@preview/physica:0.8.0": *
-$op("curl")(op("grad") f) = curl (grad f)$
+$ curl (grad f), tensor(T, -mu, +nu), pdv(f,x,y,[1,2]) $
```
-### Without `typst` package management
+```
+// Style 2
+#import "@preview/physica:0.8.0": curl, grad, tensor, pdv
-* To use the `physica` package, simply insert `#import "physica.typ": *` at the
-beginning of your document.
-* To reduce the possibility of name collisions, you may want to import the
-package under name scope `physica`:
- ```
- #import "physica.typ"
+$ curl (grad f), tensor(T, -mu, +nu), pdv(f,x,y,[1,2]) $
+```
- $op("curl")(op("grad") f) = physica.curl (physica.grad f)$
- ```
-* You may also import names specifically:
- ```
- #import "physica.typ": curl, grad
+```
+// Style 3
+#import "@preview/physica:0.8.0"
+
+$ physica.curl (physica.grad f), physica.tensor(T, -mu, +nu), physica.pdv(f,x,y,[1,2]) $
+```
+
+### Without `typst` package management
- $op("curl")(op("grad") f) = curl (grad f)$
- ```
+Similar to examples above, but import with the undecorated file path like `"physica.typ"`.
## Manual
@@ -70,7 +76,7 @@ CLI Version:
```sh
$ typst --version
-typst 0.6.0 (2dfd44fe)
+typst 0.8.0 (360cc9b9)
```
To regenerate the manual, use command
@@ -97,4 +103,3 @@ testing by comparing rendered pictures with golden images.
* Docs: the [Creative Commons BY-ND 4.0 license](https://creativecommons.org/licenses/by-nd/4.0/).
[latest-release]: https://github.com/Leedehai/typst-physics/releases/latest "The latest release"
-[latest-manual]: https://github.com/Leedehai/typst-physics/releases/latest/download/physica-manual.pdf "Download the latest manual"
diff --git a/physica-manual.pdf b/physica-manual.pdf
index fbef760..145f032 100644
Binary files a/physica-manual.pdf and b/physica-manual.pdf differ
diff --git a/physica-manual.typ b/physica-manual.typ
index 9a28df5..c125729 100644
--- a/physica-manual.typ
+++ b/physica-manual.typ
@@ -1,7 +1,7 @@
// Copyright 2023 Leedehai
// This document is shared under the Creative Commons BY-ND 4.0 license.
-#let version = "0.7.5"
+#let version = "0.8.0"
#set page(
numbering: "1/1",
@@ -22,8 +22,8 @@
]
#align(center)[
- Version #version, July 30, 2023 \
- Doc updated: July 30, 2023
+ Version #version, September 12, 2023 \
+ Doc updated: September 12, 2023
]
#set par(justify: true)
@@ -52,18 +52,20 @@ This manual itself was generated using the Typst CLI and the `physica` package,
With `typst`'s #linkurl("package management", "https://github.com/typst/packages"):
+#import "physica.typ": *
+
```
-#import "@preview/physica:0.7.5": *
+#import "@preview/physica:0.8.0": *
-$op("curl")(op("grad") f) = curl (grad f)$
+$ curl (grad f), tensor(T, -mu, +nu), pdv(f,x,y,[1,2]) $
```
+$ curl (grad f), tensor(T, -mu, +nu), pdv(f,x,y,[1,2]) $
+
= The symbols
#v(1em)
-#import "physica.typ": *
-
// Put the superscript *before* the symbol, in case there are symbols after it.
#let builtin(symbol) = [#super(text(fill: blue, "typst "))#symbol]
diff --git a/physica.typ b/physica.typ
index 8c181f3..b143927 100644
--- a/physica.typ
+++ b/physica.typ
@@ -10,13 +10,13 @@
// Given a Content generated from lr(), return the array of sub Content objects.
// Example: "[1,a_1,(1,1),n+1]" => "1", "a_1", "(1,1)", "n+1"
-#let __extract_array_contents(content) = {
- assert(type(content) == "content", message: "expecting a content type input")
- if content.func() != math.lr { return none }
+#let __extract_array_contents(input) = {
+ assert(type(input) == content, message: "expecting a content type input")
+ if input.func() != math.lr { return none }
// A Content object made by lr() definitely has a "body" field, and a
// "children" field underneath it. It holds an array of Content objects,
// starting with a Content holding "(" and ending with a Content holding ")".
- let children = content.at("body").at("children")
+ let children = input.at("body").at("children")
let result_elements = () // array of Content objects
@@ -45,7 +45,7 @@
// A bare-minimum-effort symbolic addition.
#let __bare_minimum_effort_symbolic_add(elements) = {
- assert(type(elements) == "array", message: "expecting an array of content")
+ assert(type(elements) == array, message: "expecting an array of content")
let operands = () // array
for e in elements {
if not e.has("children") {
@@ -161,7 +161,7 @@
} else {
math.italic(e)
}
- if type(a) == "content" and a.func() == math.attach {
+ if type(a) == content and a.func() == math.attach {
math.attach(
math.accent(maybe_bold(a.base), accent),
t: if a.has("t") { maybe_bold(a.t) } else { none },
@@ -246,7 +246,7 @@
#let identitymatrix(order, delim:"(", fill:none) = {
let order_num = 1
- if type(order) == "content" and __content_holds_number(order) {
+ if type(order) == content and __content_holds_number(order) {
order_num = int(order.text)
} else {
panic("the order shall be an integer, e.g. 2")
@@ -259,7 +259,7 @@
#let zeromatrix(order, delim:"(") = {
let order_num = 1
- if type(order) == "content" and __content_holds_number(order) {
+ if type(order) == content and __content_holds_number(order) {
order_num = int(order.text)
} else {
panic("the order shall be an integer, e.g. 2")
@@ -271,8 +271,8 @@
#let zmat = zeromatrix
#let jacobianmatrix(fs, xs, delim:"(") = {
- assert(type(fs) == "array", message: "expecting an array of function names")
- assert(type(xs) == "array", message: "expecting an array of variable names")
+ assert(type(fs) == array, message: "expecting an array of function names")
+ assert(type(xs) == array, message: "expecting an array of variable names")
let arrays = () // array of arrays
for f in fs {
arrays.push(xs.map((x) => math.frac($diff#f$, $diff#x$)))
@@ -282,10 +282,10 @@
#let jmat = jacobianmatrix
#let hessianmatrix(fs, xs, delim:"(") = {
- assert(type(fs) == "array", message: "expecting a one-element array")
+ assert(type(fs) == array, message: "expecting a one-element array")
assert(fs.len() == 1, message: "expecting only one function name")
let f = fs.at(0)
- assert(type(xs) == "array", message: "expecting an array of variable names")
+ assert(type(xs) == array, message: "expecting an array of variable names")
let row_arrays = () // array of arrays
let order = xs.len()
for r in range(order) {
@@ -306,19 +306,19 @@
#let xmatrix(m, n, func, delim:"(") = {
let rows = none
- if type(m) == "content" and __content_holds_number(m) {
+ if type(m) == content and __content_holds_number(m) {
rows = int(m.text)
} else {
panic("the first argument shall be an integer, e.g. 2")
}
let cols = none
- if type(n) == "content" and __content_holds_number(m) {
+ if type(n) == content and __content_holds_number(m) {
cols = int(n.text)
} else {
panic("the second argument shall be an integer, e.g. 2")
}
assert(
- type(func) == "function",
+ type(func) == function,
message: "func shall be a function (did you forget to add a preceding '#' before the function name)?"
)
let row_arrays = () // array of arrays
@@ -349,7 +349,7 @@
let ket = args.at(1, default: bra)
let height = measure($ bra ket $, styles).height;
- let phantom = box(height: height, width: 0pt, inset: 0pt, stroke: none);
+ let phantom = box(height: height * 0.8, width: 0pt, inset: 0pt, stroke: none);
$ lr(angle.l bra lr(|phantom#h(0pt)) ket angle.r) $
})
@@ -363,8 +363,8 @@
let ket = args.at(1, default: bra)
let height = measure($ bra ket $, styles).height;
- let phantom = box(height: height, width: 0pt, inset: 0pt, stroke: none);
- $ lr(|bra#h(0pt)phantom angle.r)lr(angle.l phantom#h(0pt)ket|) $
+ let phantom = box(height: height * 0.8, width: 0pt, inset: 0pt, stroke: none);
+ $ lr(bar.v bra#h(0pt)phantom angle.r)lr(angle.l phantom#h(0pt)ket bar.v) $
})
#let innerproduct = braket
@@ -376,8 +376,8 @@
// we use the same hack as braket().
#let matrixelement(n, M, m) = style(styles => {
let height = measure($ #n #M #m $, styles).height;
- let phantom = box(height: height, width: 0pt, inset: 0pt, stroke: none);
- $ lr(angle.l #n |#M#h(0pt)phantom| #m angle.r) $
+ let phantom = box(height: height * 0.8, width: 0pt, inset: 0pt, stroke: none);
+ $ lr(angle.l #n lr(|#M#h(0pt)phantom|) #m angle.r) $
})
#let mel = matrixelement
@@ -439,7 +439,7 @@
let var_num = args.len()
let default_order = [1] // a Content holding "1"
let last = args.at(args.len() - 1)
- if type(last) == "content" {
+ if type(last) == content {
if last.func() == math.lr and last.at("body").at("children").at(0) == [\[] {
var_num -= 1
orders = __extract_array_contents(last) // array
@@ -448,7 +448,7 @@
default_order = last // treat as a single element
orders.push(default_order)
}
- } else if type(last) == "integer" {
+ } else if type(last) == int {
var_num -= 1
default_order = [#last] // make it a Content
orders.push(default_order)
@@ -485,7 +485,7 @@
#let __combine_var_order(var, order) = {
let naive_result = math.attach(var, t: order)
- if type(var) != "content" or var.func() != math.attach {
+ if type(var) != content or var.func() != math.attach {
return naive_result
}
@@ -545,7 +545,7 @@
// The last argument might be the order numbers, let's check.
let last = args.at(args.len() - 1)
- if type(last) == "content" {
+ if type(last) == content {
if last.func() == math.lr and last.at("body").at("children").at(0) == [\[] {
var_num -= 1
orders = __extract_array_contents(last) // array
@@ -554,7 +554,7 @@
default_order = last
orders.push(default_order)
}
- } else if type(last) == "integer" {
+ } else if type(last) == int {
var_num -= 1
default_order = [#last] // make it a Content
orders.push(default_order)
@@ -642,7 +642,7 @@
} else {
([+], sym.square)
}
- assert(type(tuple) == "array", message: "shall be array")
+ assert(type(tuple) == array, message: "shall be array")
let pos = tuple.at(0)
let symbol = if tuple.len() >= 2 {
@@ -737,12 +737,12 @@
}
}
-#let signals(str, step: 1em, color: black) = {
- assert(type(str) == "string", message: "input needs to be a string")
+#let signals(input, step: 1em, color: black) = {
+ assert(type(input) == str, message: "input needs to be a string")
let elements = () // array
let previous = " "
- for e in str {
+ for e in input {
if e == " " { continue; }
if e == "." {
elements.push(__signal_element(previous, step, color))
diff --git a/typst.toml b/typst.toml
index aa5662d..6603ef0 100644
--- a/typst.toml
+++ b/typst.toml
@@ -3,7 +3,7 @@ name = "physica"
version = "0.7.5"
entrypoint = "physica.typ"
license = "MIT"
-description = "Physics: derivative, differential, field, matrix, braket, tensor, etc."
+description = "Physics: derivative, differential, field, matrix, braket, tensor, hbar, etc."
authors = ["Leedehai"]
repository = "https://github.com/Leedehai/typst-physics"
keywords = [
@@ -12,4 +12,5 @@ keywords = [
"differential", "derivative", "partial", "dv", "odv", "pdv", "Planck", "hbar",
"tensor", "isotope", "signal", "electromagnetism", "mechanics", "quantum",
]
+compiler = "0.8.0"
exclude = ["*.pdf", "*.py"]