Leedehai / typst-physics

physica: vectors, fields, differentials, derivatives, Dirac brakets, tensors, and more. See examples in the manual PDF.
https://github.com/Leedehai/typst-physics
MIT License
357 stars 11 forks source link

Add option to make vectors upright (non-italicized) #21

Open notaduck448 opened 10 months ago

notaduck448 commented 10 months ago

Currently, typing in vb(u) or vu(u) makes the vector u appear bold and italicized. However, in some style guides it is customary to make vectors only appear bold without being italics. It would be nice if an option was added to support this.

YDX-2147483647 commented 10 months ago

Before physica updates (or if this request is rejected), you can try the following:

#import "@preview/physica:0.9.2": vb as _vb

#let vb(x) = _vb(math.upright(x))

$vb(v) times vb(mu_1)$

图片

Leedehai commented 10 months ago

It appears to me vb(x, style:"upright") or vb(x, "upright") are too ad-hoc, and also given that Typst doesn't support set-rules for non-native functions, for now I think the workaround given in the above comment is good enough.

Discussions are welcome.

Leedehai commented 10 months ago

btw, Please give a bump to https://github.com/typst/typst/issues/147 that proposes set-rules for non-native functions :)

sjfhsjfh commented 5 months ago

Currently I prefer

#import "@preview/physica:0.9.3": *

#let vb = vb.with(style:"upright")

$vb(v) crossproduct vb(mu_1)$

I doubt the usage of custom element here is necessary, since "vector" is semantic but "bold" is not.

I guess it would be better to set the style for v/vect (like set vect(style: "bold upright")) when Typst supports custom element ~and add support for std import to use vec or fix the single letter function support in math mode to use v~