Skip to content

Commit

Permalink
Unify vector builder functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Leedehai committed Nov 22, 2023
1 parent 029d450 commit f2b6cc5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Binary file modified physica-manual.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions physica-manual.typ
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ With `typst`'s #linkurl("package management", "https://github.com/typst/packages
```typst
#import "@preview/physica:0.8.1": *
$ curl (grad f), pdv(,x,y,[1,2]), tensor(Gamma,+k,-i,-j) = pdv(vb(e)_i,x^j)vb(e)^k $
$ curl (grad f), pdv(,x,y,[1,2]), tensor(Gamma,+k,-i,-j) = pdv(vb(e_i),x^j)vb(e^k) $
```

$ curl (grad f), pdv(,x,y,[1,2]), tensor(Gamma,+k,-i,-j) = pdv(vb(e)_i,x^j)vb(e)^k $
$ curl (grad f), pdv(,x,y,[1,2]), tensor(Gamma,+k,-i,-j) = pdv(vb(e_i),x^j)vb(e^k) $

= The symbols

Expand Down
21 changes: 13 additions & 8 deletions physica.typ
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,20 @@

#let TT = $sans(upright(T))$

#let vectorbold(a) = $bold(italic(#a))$
#let vb = vectorbold

#let __vectoraccent(a, accent, be_bold) = {
#let __vector(a, accent, be_bold) = {
let maybe_bold(e) = if be_bold {
math.bold(math.italic(e))
} else {
math.italic(e)
}
let maybe_accent(e) = if accent != none {
math.accent(maybe_bold(e), accent)
} else {
maybe_bold(e)
}
if type(a) == content and a.func() == math.attach {
math.attach(
math.accent(maybe_bold(a.base), accent),
maybe_accent(a.base),
t: if a.has("t") { maybe_bold(a.t) } else { none },
b: if a.has("b") { maybe_bold(a.b) } else { none },
tl: if a.has("tl") { maybe_bold(a.tl) } else { none },
Expand All @@ -173,17 +175,20 @@
br: if a.has("br") { maybe_bold(a.br) } else { none },
)
} else {
math.accent(maybe_bold(a), accent)
maybe_accent(a)
}
}

#let vectorunit(a) = __vectoraccent(a, math.hat, true)
#let vectorbold(a) = __vector(a, none, true)
#let vb = vectorbold

#let vectorunit(a) = __vector(a, math.hat, true)
#let vu = vectorunit

// According to "ISO 80000-2:2019 Quantities and units — Part 2: Mathematics"
// the vector notation should be either bold italic or non-bold italic accented
// by a right arrow
#let vectorarrow(a) = __vectoraccent(a, math.arrow, false)
#let vectorarrow(a) = __vector(a, math.arrow, false)
#let va = vectorarrow

#let gradient = $bold(nabla)$
Expand Down

0 comments on commit f2b6cc5

Please sign in to comment.