From ee70b7a2646b215dc38b46510e3edac921785f03 Mon Sep 17 00:00:00 2001 From: eqkter Date: Thu, 8 Dec 2022 23:20:01 +0100 Subject: initial commit --- physics-ng.sty | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 physics-ng.sty (limited to 'physics-ng.sty') diff --git a/physics-ng.sty b/physics-ng.sty new file mode 100644 index 0000000..763a687 --- /dev/null +++ b/physics-ng.sty @@ -0,0 +1,147 @@ +\ProvidesPackage{physics-ng} +% physics-ng 1.0 +% This material is subject to the LaTeX Project Public License. +% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the details of that license. +% +% Personal substitute to the obselete physics package, might not be adapted to every one +% The derivative part and the Dirac brakets are respectively taken of by the +% diffcoeff and braket packages. +% It depends on asm ecosystem, siunitx, and esvect (for black board vector notation) +% design for Fourier mathtype-font with sloped setting +% +% Created by Alexis Draussin +% Updated on December 8, 2022 +% Uploaded on December 20, 2022 + +\RequirePackage{amsmath} +\RequirePackage{fourier} +\RequirePackage{bm} +\RequirePackage{siunitx} +\RequirePackage{esvect} + +\DeclareOption{bb}{\let\arrowopt = 1} +\DeclareOption{nobb}{\let\arrowopt = 0} % default +\ExecuteOptions{nobb} +\ProcessOptions\relax + +% incertitude command, using siunitx +\newcommand{\incert}[3]{\left(\num{#1}\pm\num{#2}\right)~\si{#3}} + +% transforms: Laplace, Fourier and Z +\DeclareMathAlphabet{\pazocal}{OMS}{zplm}{m}{n} % fourier overwrite the mathcal alpabet +\newcommand{\LT}[1]{\ensuremath{\pazocal{L}\left\lbrace#1\right\rbrace}} +\newcommand{\FT}[1]{\ensuremath{\pazocal{F}\left\lbrace#1\right\rbrace}} +\newcommand{\ZT}[1]{\ensuremath{\pazocal{Z}\left\lbrace#1\right\rbrace}} + +% math constants +\newcommand{\e}{\ensuremath{\mathrm{e}}} +\newcommand{\im}{\ensuremath{\mathrm{i}}} +\newcommand{\jm}{\ensuremath{\mathrm{j}}} + +% derivative +\DeclareDocumentCommand\dd{ o g d() }{ % Differential 'd' + % o: optional n for nth differential + % g: optional argument for readability and to control spacing + % d: long-form as in d(cos x) + \IfNoValueTF{#2}{ + \IfNoValueTF{#3} + {\mathrm{d}\IfNoValueTF{#1}{}{^{#1}}} + {\mathinner{\mathrm{d}\IfNoValueTF{#1}{}{^{#1}}\argopen(#3\argclose)}} + } + {\mathinner{\mathrm{d}\IfNoValueTF{#1}{}{^{#1}}#2} \IfNoValueTF{#3}{}{(#3)}} + } + +% vectors, bb arrows with \vv or \vv* (for indexes) +\ifx\arrowopt 1 % just use esvect at this point + \newcommand{\vect}[1]{\ensuremath{\vv{#1}}} % italic arrowed + \newcommand{\mat}[1]{\ensuremath{{\mathrm{#1}}} % roman + \newcommand{\tensor}[1]{\ensuremath{\vv{\vv{\mathsf{#1}}}}} % arrow and sans-serif +\else + \newcommand{\vect}[1]{\ensuremath{\bm{#1}}} % bold and italic + \newcommand{\mat}[1]{\ensuremath{\bm{\mathbf{#1}}}} % bold and roman + \newcommand{\tensor}[1]{\ensuremath{\bm{\mathsf{#1}}}} % bold and sans-serif +\fi +\newcommand{\vecu}[1]{\ensuremath{\hat{\vect{#1}}}} % vector unit +\newcommand{\vecui}[1]{\ensuremath{\hat{\vect{e}}_{\bm{#1}}}} % vector unit wth index + +\newcommand{\abs}[1]{\ensuremath{\left|#1\right|}} +\newcommand{\norm}[1]{\ensuremath{\left\|#1\right\|}} + +% Note on vectors: +% - vec v = (v_i) = (v)_i +% - product by scalar, no dot xv = x(v)_i +% - |v| or bb with ||v|| +% - hat e_a = a / |a| +% - scalar product, dot a . b = sum_i a_ib_i +% - vector product, cross a x b = sum_j sum_k LeviCivita_ijk a_j b_k +% - nabla roman, arrow in bb +% - grad, rot and div with nable notation, letter in bb +% - laplacian := nabla^2 only +% - D'Alembertian := square only + +% Note on matrices: +% - mat A = (a_ij) = (A)_ij +% - scalar product, no dot xA = x(A)_ij +% - matrix product, no dot AB = sum_j (A)ij(B)jk +% - unit matrix I = (I)_ij = Krodelta_ij +% - det A, rank A, tr A, ||A|| + +% Note on tensors: +% - dyatic product, between 2 vectors: a otimes b = (ab)_ij = a_ib_j +% - tensor product, between 2 tensors: T otimes S = T_ij S_kl +% - inner product, between 2 tensors: T . S = sum_j T_ij S_jk +% - inner product with a vector: T . a = sum_j T_ij a_j +% - scalar product, column: T:S = sum_i sum_j T_ij S_ji + +% bunch functions not base-declared +\DeclareMathOperator{\tr}{tr} +\DeclareMathOperator{\rank}{rank} +\DeclareMathOperator{\sinc}{sinc} +\DeclareMathOperator{\Ei}{Ei} +\DeclareMathOperator{\Li}{Li} +\DeclareMathOperator{\Si}{Si} +\DeclareMathOperator{\erf}{erf} +\DeclareMathOperator{\erfc}{erfc} +\DeclareMathOperator{\arccot}{arccot} +\DeclareMathOperator{\arcsec}{arcsec} +\DeclareMathOperator{\arccsc}{arccsc} +\DeclareMathOperator{\sech}{sech} +\DeclareMathOperator{\csch}{csch} +\DeclareMathOperator{\arsinh}{arsinh} +\DeclareMathOperator{\arcosh}{arcosh} +\DeclareMathOperator{\artanh}{artanh} +\DeclareMathOperator{\arcoth}{arcoth} +\DeclareMathOperator{\arsech}{arsech} +\DeclareMathOperator{\arcsch}{arcsch} + +\DeclareDocumentCommand\nqty{}{{\ifnum\z@=`}\fi\@nqty} +\DeclareDocumentCommand\@nqty{ t\big t\Big t\bigg t\Bigg g o d() d|| } +{ % Flexible automatic bracketing of an expression in () or [] or {} or || + % Handles manual override of sizing + \IfBooleanTF{#1}{\let\ltag\bigl \let\rtag\bigr}{ + \IfBooleanTF{#2}{\let\ltag\Bigl \let\rtag\Bigr}{ + \IfBooleanTF{#3}{\let\ltag\biggl \let\rtag\biggr}{ + \IfBooleanTF{#4} + {\let\ltag\Biggl \let\rtag\Biggr} + {\let\ltag\left \let\rtag\right} + } + } + } + % Handles actual bracketing + \IfNoValueTF{#5}{ + \IfNoValueTF{#6}{ + \IfNoValueTF{#7}{ + \IfNoValueTF{#8} + {()} + {\ltag\lvert{#8}\rtag\rvert} + } + {\ltag(#7\rtag) \IfNoValueTF{#8}{}{|#8|}} + } + {\ltag[#6\rtag] \IfNoValueTF{#7}{}{(#7)} \IfNoValueTF{#8}{}{|#8|}} + } + {\ltag\lbrace#5\rtag\rbrace \IfNoValueTF{#6}{}{[#6]} \IfNoValueTF{#7}{}{(#7)} \IfNoValueTF{#8}{}{|#8|}} + \ifnum\z@=`{\fi} +} + +\newcommand{\comm}[2]{\ensuremath{\nqty[#1,#2]}} +\newcommand{\acomm}[2]{\ensuremath{\nqty{#1,#2}}} -- cgit v1.2.3