Skip to content

Commit

Permalink
Add super-T-as-transpose
Browse files Browse the repository at this point in the history
  • Loading branch information
Leedehai committed Dec 21, 2023
1 parent 94c8982 commit b9d7777
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
Binary file modified physica-manual.pdf
Binary file not shown.
37 changes: 35 additions & 2 deletions physica-manual.typ
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ All symbols need to be used in *math mode* `$...$`.
[`TT`],
[],
[`v^TT, A^TT` #sym.arrow $v^TT, A^TT$],
[transpose],
[transpose, also see\ @matrix-tranpose],

[`vectorbold(`_content_`)`],
[`vb`],
Expand Down Expand Up @@ -234,7 +234,7 @@ All symbols need to be used in *math mode* `$...$`.
[`TT`],
[],
[`v^TT, A^TT` #sym.arrow $v^TT, A^TT$],
[transpose],
[transpose, also see\ @matrix-tranpose],

[#builtin([`mat(`...`)`])],
[],
Expand Down Expand Up @@ -785,6 +785,39 @@ In the default font, the Typst built-in symbol `planck.reduce` $planck.reduce$ l
[$ i hbar pdv(,t) psi = -frac(hbar^2, 2m) laplacian psi $],
)

=== Matrix transpose <matrix-tranpose>

#v(1em)

Matrix transposition can be simply written as `..^T`, where the `T` will be
formatted properly to represent transposition instead of a normal letter $T$.
This conversion is disabled if the base is integral symbol.

To enable this feature, users need to first import this and call
```typ
#import "...(this physica package)...": super-T-as-transpose
#show: super-T-as-transpose
```

#align(center, [*Examples*])

#show: super-T-as-transpose // Necessary!

#grid(
columns: (50%, 50%),
row-gutter: 1em,
column-gutter: 2em,

[
*(1)* #hl(`(A_n B_n)^T = B_n^T A_n^T`) \
$ (A_n B_n)^T = B_n^T A_n^T $
],
[
*(2)* #hl(`integral_0^T A^T f(x) dif x`) \
$ integral_0^T A^T f(x) dif x $
],
)

=== Tensors

#v(1em)
Expand Down
13 changes: 13 additions & 0 deletions physica.typ
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@

#let vecrow(..content) = $lr(( #content.pos().join(",") ))$

// Prefer using super-T-as-transpose()
#let TT = $sans(upright(T))$

#let __vector(a, accent, be_bold) = {
Expand Down Expand Up @@ -634,6 +635,18 @@
// Credit: Enivex in https://github.com/typst/typst/issues/355 was very helpful.
#let hbar = (sym.wj, move(dy: -0.08em, strike(offset: -0.55em, extent: -0.05em, sym.planck)), sym.wj).join()

#let super-T-as-transpose(document) = {
show math.attach: elem => {
if elem.base != [∫] and elem.at("t", default: none) == [T] {
$attach(elem.base, t: TT, b: elem.at("b", default: #none))$
} else {
elem
}
}

document
}

#let tensor(T, ..sink) = {
let args = sink.pos()

Expand Down

0 comments on commit b9d7777

Please sign in to comment.