├── .gitattributes ├── zip.sh ├── README.md ├── doc ├── phy2docdef.tex ├── physics2-legacy.tex └── physics2.tex ├── .gitignore ├── physics2-code-doc-intro.dtx ├── physics2-code-utility.dtx ├── physics2-code.dtx ├── LICENSE └── physics2-code-base.dtx /.gitattributes: -------------------------------------------------------------------------------- 1 | .md text eol=lf 2 | .tex text eol=lf 3 | .sty text eol=lf 4 | .cls text eol=lf 5 | .ltx text eol=lf 6 | .dtx text eol=lf 7 | .ini text eol=lf 8 | .pdf binary 9 | -------------------------------------------------------------------------------- /zip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # For macOS X: 3 | if [ ! -d "physics2" ]; then 4 | mkdir physics2 5 | fi 6 | cp README.md physics2 7 | cp physics2-code.dtx physics2 8 | cp physics2-code.src.*.dtx physics2 9 | cp physics2.ins physics2 10 | cp physics2-code.pdf physics2 11 | cp doc/physics2.tex physics2 12 | cp doc/physics2-legacy.tex physics2 13 | cp physics2.pdf physics2 14 | cp doc/physics2-legacy.pdf physics2 15 | cp doc/phy2docdef.tex physics2 16 | COPYFILE_DISABLE=1 tar --no-acls --exclude ".DS_Store" --exclude "__MACOSX" -cvzf "physics2.tar.gz" "physics2" 17 | rm -rf physics2 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The `physics2` package 2 | 3 | This package defines commands for typesetting math formulae faster and 4 | more simply. `physics2` is a modularized package, each module provides its 5 | own function while the package itself only provides very few functions. 6 | You can load modules of `physics2` after loading the `physics2` package. 7 | 8 | ## Functions and usages 9 | 10 | See `physics2.pdf`. 11 | 12 | ## Build 13 | 14 | Run 15 | 16 | ``` 17 | ./build.sh 18 | ``` 19 | 20 | ## For developers and advanced users 21 | 22 | If you want to contribute to this repository, you can 23 | 24 | - pull requests [here](https://github.com/AlphaZTX/physics2/pulls); 25 | - report bugs or request enhancement [here](https://github.com/AlphaZTX/physics2/issues). 26 | 27 | Before committing, please read `physics2-code.pdf` first. 28 | 29 | ## License 30 | 31 | This work may be distributed and/or modified under the conditions of the 32 | [LaTeX Project Public License](http://www.latex-project.org/lppl.txt), 33 | either version 1.3c of this license or (at your option) any later version. 34 | 35 | This work has the LPPL maintenance status `maintained`. 36 | 37 | The Current Maintainer of this work is 38 | [Zhang Tingxuan](https://www.ctan.org/author/zhang-tx). 39 | 40 | -------------------------------------------------------------------------------- /doc/phy2docdef.tex: -------------------------------------------------------------------------------- 1 | %% This is part of physics2 documentation. 2 | %% ****************************************************** 3 | %% * This work may be distributed and/or modified under * 4 | %% * the conditions of the LaTeX Project Public License * 5 | %% * http://www.latex-project.org/lppl.txt * 6 | %% * either version 1.3c of this license or any later * 7 | %% * version. * 8 | %% ****************************************************** 9 | \makeatletter 10 | \usepackage[nohyperref]{doc} 11 | \renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{2.1em}} 12 | \def\contentsonly{\@starttoc{toc}} 13 | \usepackage{manfnt} 14 | \protected\def\pardanger{\ifnum\lastnodetype=1% 15 | \leavevmode\hbox to \z@{\hss\dbend\hskip10pt\hskip\parindent}\else 16 | \ifnum\lastnodetype=11% 17 | \leavevmode\hbox to \z@{\hss\dbend\hskip10pt}% 18 | \fi\fi\ignorespaces} 19 | \usepackage{hyperref,color,xr} 20 | \definecolor{pkgcolor}{RGB}{0,120,80} 21 | \definecolor{moducolor}{RGB}{0,0,150} 22 | \hypersetup{colorlinks,urlcolor=magenta,linkcolor=black,filecolor=blue, 23 | pdfstartview=FitH,pdfview=FitH,pdfcreator=XeTeX output} 24 | \def\s@pkg#1{\texorpdfstring{\textcolor{pkgcolor}{\textsf{#1}}}{“#1”}} 25 | \def\@pkg#1{\texorpdfstring{\href{https://www.ctan.org/pkg/#1}% 26 | {\textcolor{pkgcolor}{\textsf{#1}}}}{“#1”}} 27 | \DeclareRobustCommand\pkg{\@ifstar\@pkg\s@pkg} 28 | \def\modu#1{\texorpdfstring{\textcolor{moducolor}{\textsf{#1}}}{“#1”}} 29 | \def\opt#1{\texorpdfstring{\texttt{#1}}{“#1”}} 30 | \protected\def\marg#1{\texttt\{\meta{#1}\texttt\}} 31 | \protected\def\oarg#1{\texttt[\meta{#1}\texttt]} 32 | \parindent2.4em 33 | \linespread{1.06} 34 | \usepackage{multicol,fancyvrb,verbatim,array,hologo} 35 | \fvset{xleftmargin=\parindent} 36 | \newenvironment{displayed}{\trivlist\item[]\leftskip\parindent\relax}{\endtrivlist} 37 | \usepackage[normalem]{ulem} 38 | \newcounter{example}[subsection] 39 | \renewcommand\theexample{\thesubsection.\arabic{example}} 40 | \newwrite\example@out 41 | \def\example@name{\jobname.example.aux} 42 | \long\def\example@start{\begingroup\@bsphack 43 | \immediate\openout\example@out=\example@name 44 | \let\do\@makeother\dospecials\catcode`\^^M\active 45 | \def\verbatim@processline{\immediate\write\example@out{\the\verbatim@line}}% 46 | \verbatim@start} 47 | \long\def\example@end{\immediate\closeout\example@out\@esphack\endgroup% 48 | \trivlist\item[]\relax 49 | \leavevmode\hbox to \z@{% 50 | \hbox to \z@{\hss{\footnotesize[\theexample]}\hskip10pt}% 51 | \hskip\parindent 52 | \begin{minipage}[c]{0.55\textwidth}% 53 | \small\verbatiminput{\example@name}% 54 | \end{minipage}% 55 | \fbox{% 56 | \begin{minipage}[c]{0.5\textwidth}% 57 | \normalsize\input{\example@name}% 58 | \end{minipage}% 59 | }% 60 | \hss}% 61 | \endtrivlist} 62 | \newenvironment{example*}[1]% 63 | {\refstepcounter{example}\label{#1}\example@start}{\example@end} 64 | \newenvironment{example} 65 | {\stepcounter{example}\example@start}{\example@end} 66 | \author{Zhang Tingxuan} 67 | \date{2024/01/22\quad Version 1.0.2\thanks{% 68 | \url{https://www.github.com/AlphaZTX/physics2}}} 69 | \makeatother 70 | \endinput 71 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | testpkg.tex 2 | testpkg.aux 3 | testpkg.log 4 | testpkg.toc 5 | testpkg.out 6 | testpkg.pdf 7 | testpkg.synctex.gz 8 | testpkg.synctex.gz(busy) 9 | 10 | .DS_Store 11 | *.sty 12 | *.tar.gz 13 | physics2/ 14 | *.ins 15 | 16 | ## Core latex/pdflatex auxiliary files: 17 | *.aux 18 | *.lof 19 | *.log 20 | *.lot 21 | *.fls 22 | *.out 23 | *.toc 24 | *.fmt 25 | *.fot 26 | *.cb 27 | *.cb2 28 | .*.lb 29 | *.hd 30 | 31 | ## Intermediate documents: 32 | *.dvi 33 | *.xdv 34 | *-converted-to.* 35 | # these rules might exclude image files for figures etc. 36 | # *.ps 37 | # *.eps 38 | # *.pdf 39 | 40 | ## Generated if empty string is given at "Please type another file name for output:" 41 | .pdf 42 | 43 | ## Bibliography auxiliary files (bibtex/biblatex/biber): 44 | *.bbl 45 | *.bcf 46 | *.blg 47 | *-blx.aux 48 | *-blx.bib 49 | *.run.xml 50 | 51 | ## Build tool auxiliary files: 52 | *.fdb_latexmk 53 | *.synctex 54 | *.synctex(busy) 55 | *.synctex.gz 56 | *.synctex.gz(busy) 57 | *.pdfsync 58 | 59 | ## Build tool directories for auxiliary files 60 | # latexrun 61 | latex.out/ 62 | 63 | ## Auxiliary and intermediate files from other packages: 64 | # algorithms 65 | *.alg 66 | *.loa 67 | 68 | # achemso 69 | acs-*.bib 70 | 71 | # amsthm 72 | *.thm 73 | 74 | # beamer 75 | *.nav 76 | *.pre 77 | *.snm 78 | *.vrb 79 | 80 | # changes 81 | *.soc 82 | 83 | # comment 84 | *.cut 85 | 86 | # cprotect 87 | *.cpt 88 | 89 | # elsarticle (documentclass of Elsevier journals) 90 | *.spl 91 | 92 | # endnotes 93 | *.ent 94 | 95 | # fixme 96 | *.lox 97 | 98 | # feynmf/feynmp 99 | *.mf 100 | *.mp 101 | *.t[1-9] 102 | *.t[1-9][0-9] 103 | *.tfm 104 | 105 | #(r)(e)ledmac/(r)(e)ledpar 106 | *.end 107 | *.?end 108 | *.[1-9] 109 | *.[1-9][0-9] 110 | *.[1-9][0-9][0-9] 111 | *.[1-9]R 112 | *.[1-9][0-9]R 113 | *.[1-9][0-9][0-9]R 114 | *.eledsec[1-9] 115 | *.eledsec[1-9]R 116 | *.eledsec[1-9][0-9] 117 | *.eledsec[1-9][0-9]R 118 | *.eledsec[1-9][0-9][0-9] 119 | *.eledsec[1-9][0-9][0-9]R 120 | 121 | # glossaries 122 | *.acn 123 | *.acr 124 | *.glg 125 | *.glo 126 | *.gls 127 | *.glsdefs 128 | *.lzo 129 | *.lzs 130 | 131 | # uncomment this for glossaries-extra (will ignore makeindex's style files!) 132 | # *.ist 133 | 134 | # gnuplottex 135 | *-gnuplottex-* 136 | 137 | # gregoriotex 138 | *.gaux 139 | *.gtex 140 | 141 | # htlatex 142 | *.4ct 143 | *.4tc 144 | *.idv 145 | *.lg 146 | *.trc 147 | *.xref 148 | 149 | # hyperref 150 | *.brf 151 | 152 | # knitr 153 | *-concordance.tex 154 | # TODO Comment the next line if you want to keep your tikz graphics files 155 | *.tikz 156 | *-tikzDictionary 157 | 158 | # listings 159 | *.lol 160 | 161 | # luatexja-ruby 162 | *.ltjruby 163 | 164 | # makeidx 165 | *.idx 166 | *.ilg 167 | *.ind 168 | 169 | # minitoc 170 | *.maf 171 | *.mlf 172 | *.mlt 173 | *.mtc[0-9]* 174 | *.slf[0-9]* 175 | *.slt[0-9]* 176 | *.stc[0-9]* 177 | 178 | # minted 179 | _minted* 180 | *.pyg 181 | 182 | # morewrites 183 | *.mw 184 | 185 | # nomencl 186 | *.nlg 187 | *.nlo 188 | *.nls 189 | 190 | # pax 191 | *.pax 192 | 193 | # pdfpcnotes 194 | *.pdfpc 195 | 196 | # sagetex 197 | *.sagetex.sage 198 | *.sagetex.py 199 | *.sagetex.scmd 200 | 201 | # scrwfile 202 | *.wrt 203 | 204 | # sympy 205 | *.sout 206 | *.sympy 207 | sympy-plots-for-*.tex/ 208 | 209 | # pdfcomment 210 | *.upa 211 | *.upb 212 | 213 | # pythontex 214 | *.pytxcode 215 | pythontex-files-*/ 216 | 217 | # tcolorbox 218 | *.listing 219 | 220 | # thmtools 221 | *.loe 222 | 223 | # TikZ & PGF 224 | *.dpth 225 | *.md5 226 | *.auxlock 227 | 228 | # todonotes 229 | *.tdo 230 | 231 | # vhistory 232 | *.hst 233 | *.ver 234 | 235 | # easy-todo 236 | *.lod 237 | 238 | # xcolor 239 | *.xcp 240 | 241 | # xmpincl 242 | *.xmpi 243 | 244 | # xindy 245 | *.xdy 246 | 247 | # xypic precompiled matrices and outlines 248 | *.xyc 249 | *.xyd 250 | 251 | # endfloat 252 | *.ttt 253 | *.fff 254 | 255 | # Latexian 256 | TSWLatexianTemp* 257 | 258 | ## Editors: 259 | # WinEdt 260 | *.bak 261 | *.sav 262 | 263 | # Texpad 264 | .texpadtmp 265 | 266 | # LyX 267 | *.lyx~ 268 | 269 | # Kile 270 | *.backup 271 | 272 | # gummi 273 | .*.swp 274 | 275 | # KBibTeX 276 | *~[0-9]* 277 | 278 | # TeXnicCenter 279 | *.tps 280 | 281 | # auto folder when using emacs and auctex 282 | ./auto/* 283 | *.el 284 | 285 | # expex forward references with \gathertags 286 | *-tags.tex 287 | 288 | # standalone packages 289 | *.sta 290 | 291 | # Makeindex log files 292 | *.lpz 293 | *.pdf 294 | *.pdf 295 | -------------------------------------------------------------------------------- /physics2-code-doc-intro.dtx: -------------------------------------------------------------------------------- 1 | % \part*{Introduction} 2 | % \addcontentsline{toc}{part}{Introduction} 3 | % 4 | % This is a documentation for advanced users and developers of the 5 | % \pkg{physics2} package. This document includes: 6 | % \begin{enumerate} 7 | % \item What is a module of \pkg{physics2}? 8 | % \item How to write a module? 9 | % \item The interfaces provided by \pkg{physics2} and the existing modules. 10 | % \item Code implementation of \pkg{physics2} and the existing modules. 11 | % \end{enumerate} 12 | % 13 | % \section{What is a module?} 14 | % 15 | % The \pkg{physics2} package itself provides a standard interface for loading 16 | % modules. A module is a pure text file that contains \TeX\ code, independent 17 | % of the \pkg{physics2} package. A module provides a bundle of functions. 18 | % The file name of a module is like \texttt{phys.\meta{module}.sty}. 19 | % 20 | % It's recommended that functions in a module should be aimed at \emph{one} 21 | % specific topic and share similar usage. 22 | % 23 | % \section{How to write a module?} 24 | % 25 | % The beginning of a module's content should be like 26 | % \begin{verbatim} 27 | % \ProvidesFile{phys.MODULE_NAME.sty}[YYYY/MM/DD DESCRIPTION] 28 | % \end{verbatim} 29 | % or 30 | % \begin{verbatim} 31 | % \ProvidesExplFile{phys.MODULE_NAME.sty}{YYYY/MM/DD}{VER}{DESCRIPTION} 32 | % \end{verbatim} 33 | % where \texttt{phys.MODULE_NAME.sty} is the same as the file name of the module. 34 | % 35 | % After this line comes the real content of the module. In a module's content, 36 | % you can process the options of the module, require other packages or 37 | % \pkg{physics2} modules and define functions. 38 | % 39 | % A module handles its key-value options with the new \LaTeX\ kernel interfaces 40 | % \cs{DeclareKeys}, \cs{SetKeys} and \cs{ProcessKeyOptions} (released in 2022-06-01). 41 | % For example, 42 | % \begin{verbatim}[firstnumber=last] 43 | % \DeclareKeys{bool-option.if=phy@ModBoolA} 44 | % \SetKeys{bool-option=true} 45 | % \ProcessKeyOptions 46 | % \end{verbatim} 47 | % The code above defines a boolean option \texttt{bool-option} which stores 48 | % its value in \cs{ifphy@ModBoolA}, with the default value \texttt{true}. 49 | % The usage of \cs{DeclareKeys}, etc., is introduced in \file{clsguide.pdf}. 50 | % You can run 51 | % \texttt{texdoc \href{http://mirrors.ctan.org/macros/latex/base/clsguide.pdf}{clsguide}} 52 | % to see it. 53 | % 54 | % To load other packages, just use \cs{RequirePackage} command as usual. 55 | % To load other modules, use \cs{RequirePhysicsModule}. It is equivalent to 56 | % \cs{usephysicsmodule}. Options of a module can be passed to another module 57 | % with \csref{PassOptionsToPhysicsModule}, whose syntax is the same as 58 | % \cs{PassOptionsToPackage}. Note that there is no commands like 59 | % \cs[no-index]{RequirePhysicsModuleWithOptions} to load a module with 60 | % specific options. Finally the requirement of packages and modules in a module 61 | % will look like 62 | % \begin{verbatim}[firstnumber=last] 63 | % \PassOptionsToPackage{...}{PKG} 64 | % \RequirePackage{PKG_LIST} 65 | % \PassOptionsToPhysicsModule{...}{MOD} 66 | % \RequirePhysicsModule{MOD_LIST} 67 | % \end{verbatim} 68 | % 69 | % \section{While using DocStrip} 70 | % 71 | % It's encouraged to generate the final module files with DocStrip. Run 72 | % \texttt{texdoc \href{http://mirrors.ctan.org/macros/latex/base/docstrip.pdf}{docstrip}} 73 | % to see the documentation. 74 | % 75 | % In DocStrip, an important concept ``guard'' is introduced. A guard is an 76 | % expression enclosed in \verb|<| and \verb|>|, following a \verb|%| symbol at 77 | % the beginning of a line. For example, these are guards: 78 | % \begin{verbatim} 79 | % %<*foo> 80 | % % 81 | % % 82 | % %<@@=phy> 83 | % %<@@=> 84 | % \end{verbatim} 85 | % They will be typeset as \guard{*foo}, \guard{/foo}, \guard{bar}, \guard{@@=phy} 86 | % and \guard{@@=}. Guards with format \guard{@@=\meta{module}} is special 87 | % because they handles the \texttt{@@} to \meta{module} replacement. The guard 88 | % \guard{@@=} cancels the replacement. The replacement rule is 89 | % \begin{enumerate} 90 | % \item First, deal with \texttt{@@@@} as a special case. 91 | % \item Then change all \verb|__@@| to \verb|__|\meta{module}. 92 | % \item Then change all remaining \verb|_@@| to \verb|__|\meta{module}. 93 | % \item Then change all remaining \texttt{@@} to \verb|__|\meta{module}. 94 | % \item Finally, tidy up by changing each ``disguised \texttt{@@@@}'' to \texttt{@@}. 95 | % \end{enumerate} 96 | % So the following code 97 | % \begin{verbatim} 98 | % %<@@=phy> 99 | % \@@_foo: 100 | % \end{verbatim} 101 | % will eventually become 102 | % \begin{verbatim} 103 | % \__phy_foo: 104 | % \end{verbatim} 105 | % It's useful when you are using \LaTeX3 syntax, and all the \LaTeX3 interfaces 106 | % of \pkg{physics2} and the existing modules are written with guard \guard{@@=phy}. 107 | % 108 | % If you are writing a module in \LaTeXe\ ``traditional'' syntax, avoid using 109 | % two consecutive ``\texttt{@}'' symbols in your interface, because module 110 | % authors using \LaTeX3 syntax may forget to change \texttt{@@} to \texttt{@@@@} 111 | % if they want to require your module, which may cause hard-to-debug errors. 112 | % 113 | % \section{What interfaces does \pkg{physics2} expose to me?} 114 | % 115 | % The \pkg{physics2} package and the existing modules provide interfaces for 116 | % you to use. The interfaces are listed in this document. They are introduced 117 | % in sections with name ``API''. 118 | % 119 | % Do not use those commands introduced in sections with name ``Internal commands''. 120 | % They may be changed during the development of \pkg{physics2}. 121 | % 122 | % \endinput 123 | -------------------------------------------------------------------------------- /physics2-code-utility.dtx: -------------------------------------------------------------------------------- 1 | % \DeclareSourceFile{utility} 2 | % 3 | % \section{Patch for \pkg{amsmath}}\label{sec:patch.amsmath} 4 | % 5 | % \subsection{API} 6 | % 7 | % The following functions are the same as the ones in \pkg{amsmath} and they 8 | % are required by \pkg{physics2}. If \pkg{amsmath} is not loaded, this module 9 | % will add these functions. 10 | % 11 | % \begin{function}{\lvert,\rvert,\lVert,\rVert} 12 | % The left/right specific versions of \cs{vert} and \cs{Vert}. 13 | % \end{function} 14 | % 15 | % \begin{function}{\bBigg@} 16 | % \begin{syntax} 17 | % \cs{bBigg@} \marg{factor} \meta{delimiter} 18 | % \end{syntax} 19 | % Determines the correct height of the delimiter. 20 | % For example, \cs{big}'s expansion is \cs{bBigg@}\texttt{\{1\}}. 21 | % \end{function} 22 | % 23 | % \subsection{Code implementation} 24 | % 25 | % \begin{macrocode} 26 | %<*patch.amsmath> 27 | \ProvidesFile{phys.patch.amsmath.sty}[2025/03/01 physics2 patch for amsmath] 28 | % \end{macrocode} 29 | % 30 | % \begin{macro}{\lvert,\rvert,\lVert,\rVert} 31 | % The following code comes from the (sub)section \textit{Vertical bar symbols} 32 | % of \texttt{amsmath.dtx}. 33 | % 34 | % \cs{@xp} in \pkg{amsmath} is replaced by \cs{expandafter} and 35 | % \cs{ifx}\cs{@@undefined}\cs[no-index]{\meta{cs}} is replaced by 36 | % \cs{ifdefined}\cs[no-index]{\meta{cs}}\cs{else}. 37 | % 38 | % \begin{macrocode} 39 | \def\@tempa#1#2\@nil{% 40 | \ifx\delimiter#1\@tempcnta#2\relax\else\@tempcnta\z@\fi 41 | } 42 | \expandafter\@tempa\vert\@empty\@nil 43 | \ifnum\@tempcnta>\z@ 44 | \advance\@tempcnta "4000000 45 | \protected\xdef\lvert{\delimiter\number\@tempcnta\space } 46 | \advance\@tempcnta "1000000 47 | \protected\xdef\rvert{\delimiter\number\@tempcnta\space } 48 | \else 49 | \ifdefined\lvert\else 50 | \DeclareMathDelimiter\lvert 51 | {\mathopen}{symbols}{"6A}{largesymbols}{"0C} 52 | \DeclareMathDelimiter\rvert 53 | {\mathclose}{symbols}{"6A}{largesymbols}{"0C} 54 | \fi 55 | \fi 56 | \expandafter\@tempa\Vert\@empty\@nil 57 | \ifnum\@tempcnta>\z@ 58 | \advance\@tempcnta "4000000 59 | \protected\xdef\lVert{\delimiter\number\@tempcnta\space } 60 | \advance\@tempcnta "1000000 61 | \protected\xdef\rVert{\delimiter\number\@tempcnta\space } 62 | \else 63 | \ifdefined\lVert\else 64 | \DeclareMathDelimiter\lVert 65 | {\mathopen}{symbols}{"6B}{largesymbols}{"0D} 66 | \DeclareMathDelimiter\rVert 67 | {\mathclose}{symbols}{"6B}{largesymbols}{"0D} 68 | \fi 69 | \fi 70 | % \end{macrocode} 71 | %\end{macro} 72 | % 73 | % \begin{macro}{\bBigg@} 74 | % \begin{macrocode} 75 | \newdimen\phy@patch@bigsize 76 | \newbox\phy@patch@mathstrutbox 77 | \setbox\phy@patch@mathstrutbox=\hbox{} 78 | \ifx\Umathcharnumdef\@undefined 79 | \def\resetMathstrut@{% 80 | \begingroup 81 | \setbox\z@\hbox{% 82 | \mathchardef\@tempa\mathcode`\(\relax 83 | \def\@tempb##1"##2##3{\the\textfont"##3\char"}% 84 | \expandafter\@tempb\meaning\@tempa \relax 85 | }% 86 | \edef\@tempa{% 87 | \ht\phy@patch@mathstrutbox\the\ht\z@\relax 88 | \dp\phy@patch@mathstrutbox\the\dp\z@\relax}% 89 | \expandafter\endgroup\@tempa 90 | } 91 | \else 92 | \def\resetMathstrut@{% 93 | \begingroup 94 | \Umathcharnumdef\@tempa\Umathcodenum`\(\relax 95 | \def\@tempb##1"##2"##3"##4\relax{% 96 | \endgroup 97 | \ht\phy@patch@mathstrutbox=\fontcharht\textfont"##3 "##4\relax 98 | \dp\phy@patch@mathstrutbox=\fontchardp\textfont"##3 "##4\relax}% 99 | \expandafter\@tempb\meaning\@tempa \relax 100 | } 101 | \fi 102 | \addto@hook\every@math@size{\resetMathstrut@} 103 | \addto@hook\every@math@size{% 104 | \global\phy@patch@bigsize 1.2\ht\phy@patch@mathstrutbox 105 | \global\advance\phy@patch@bigsize 1.2\dp\phy@patch@mathstrutbox } 106 | \def\@mathmeasure#1#2#3{\setbox#1\hbox{% 107 | \m@th$#2#3$}} 108 | \def\bBigg@#1#2{\leavevmode@ifvmode 109 | {\@mathmeasure\z@{\nulldelimiterspace\z@}% 110 | {\left#2\vcenter to#1\phy@patch@bigsize{}\right.}% 111 | \box\z@}} 112 | % \end{macrocode} 113 | % \end{macro} 114 | % \begin{macrocode} 115 | % 116 | % \end{macrocode} 117 | % 118 | % \section{The \modu{helper} module --- debug mode support} 119 | % 120 | % This is the module that provides the debug mode support for \pkg{physics2}. 121 | % It shouldn't be loaded by users directly. 122 | % 123 | % \subsection{API?} 124 | % 125 | % These functions are not intended to be used by developers in their own 126 | % modules. They are only used by the \modu{helper} module. They appear here 127 | % to help us understand their functionality. 128 | % 129 | % \begin{function}{\g_@@_helper_errors_int} 130 | % Records the number of errors related to \pkg{physics2}. It should be 131 | % automatically increased by one once an error is detected by the \modu{helper} 132 | % module. 133 | % \end{function} 134 | % 135 | % \begin{function}{\@@_helper_cs_src:Nn} 136 | % \begin{syntax} 137 | % \cs{@@_helper_cs_src:Nn} \meta{command} \meta{module} 138 | % \end{syntax} 139 | % Declares in which module the \meta{command} is defined. Take an example. 140 | % If you are writing a module \modu{foo} with DocStrip, and it is generated 141 | % with guard \guard{foo} from the according \file{.dtx} file, you can 142 | % organize your \file{.dtx} file like this: 143 | % \begin{verbatim} 144 | % % Some notes. 145 | % % \begin{macrocode} 146 | % %<*foo> 147 | % \DeclareDocumentCommand \foo { } { replacement text } 148 | % % 149 | % %<@@=phy> 150 | % % \@@_helper_cs_src:Nn \foo { foo } 151 | % %<@@=> 152 | % % \end{macrocode} 153 | % % \end{verbatim} 154 | % The \guard{helper} guard is used to insert the code 155 | % \end{function} 156 | % 157 | % \subsection{Code implementation} 158 | % 159 | % \begin{macrocode} 160 | %<*helper-begin> 161 | %<@@=phy> 162 | \ProvidesFile{phys.helper.sty}[2025/03/01 Debug mode support of physics2] 163 | \ExplSyntaxOn 164 | % \end{macrocode} 165 | % 166 | % 167 | % \begin{macro}[int]{\g_@@_helper_errors_int} 168 | % \begin{macrocode} 169 | \int_new:N \g_@@_helper_errors_int 170 | % \end{macrocode} 171 | % \end{macro} 172 | % 173 | % \begin{macrocode} 174 | \DeclareKeys 175 | { 176 | tightbraces .code:n = 177 | { 178 | \PackageError 179 | { physics2 } 180 | { 181 | The~`tightbraces'~key~is~removed~from~`ab'~module.\iow_newline: 182 | It~is~now~replaced~by~the~`tight-braces'~key~of~ 183 | the~`physics2'~package. \iow_newline: 184 | You~must~have~written~like~this~in~your~preamble: \iow_newline: 185 | \@spaces \token_to_str:N 186 | \usephysicsmodule[tightbraces=#1]{ab} \iow_newline: 187 | Change~it~to: \iow_newline: 188 | \@spaces \token_to_str:N 189 | \usepackage[tight-braces=#1]{physics2} \iow_newline: 190 | \@space \token_to_str:N 191 | \usephysicsmodule{ab} \iow_newline: 192 | Don't~forget~there's~a~hyphen~in~the~new \iow_newline: 193 | `tight-braces'~key. 194 | } 195 | { 196 | If~you~still~don't~know~what~to~do,~please~read \iow_newline: 197 | the~package~documentation. \iow_newline: 198 | } 199 | } 200 | } 201 | \ProcessKeyOptions \relax 202 | % \end{macrocode} 203 | % 204 | % TODO: patch to \cs{@@_ab:nN}, \cs{@@_ab_declare_ns:n} and \cs{@@_ab_use:c}. 205 | % 206 | % \begin{macrocode} 207 | \msg_new:nnnn { physics2 } { undef-cs } 208 | { 209 | Missing~required~module~`#2'! \iow_newline: 210 | The~control~sequence~\token_to_str:N #1 211 | on~line~\msg_line_number:\space 212 | is~provided~by~module~`#2',~but~you~didn't~load~it. 213 | } 214 | { 215 | Just~write~\token_to_str:N \usephysicsmodule{#2}~ 216 | after~\token_to_str:N \usepackage{physics2}~in~your~preamble. 217 | } 218 | % \end{macrocode} 219 | % 220 | % \begin{macro}{\@@_helper_cs_src:Nn} 221 | % \begin{macrocode} 222 | \cs_set:Npn \@@_helper_cs_src:Nn #1#2 223 | { 224 | \cs_if_exist:NF #1 225 | { 226 | \cs_set:Npn #1 227 | { 228 | \msg_error:nnnn { physics2 } { undef-cs } { #1 } { #2 } 229 | \int_gincr:N \g_@@_helper_errors_int 230 | } 231 | } 232 | } 233 | % \end{macrocode} 234 | % \end{macro} 235 | % 236 | % \begin{macrocode} 237 | \AddToHook { begindocument } 238 | { 239 | % 240 | % \end{macrocode} 241 | % 242 | % Here should be the code provided by other source files with the 243 | % \guard{helper} guard. See the following sections. 244 | % 245 | % \begin{macrocode} 246 | %<*helper-end> 247 | } 248 | \AddToHook { enddocument/end } 249 | { 250 | \group_begin: 251 | \def \on@line { } 252 | \int_compare:nNnTF { \g_@@_helper_errors_int } > { 0 } 253 | { 254 | \PackageWarning { physics2 } 255 | { 256 | Oops!~There~ 257 | \ifnum \g_@@_helper_errors_int = 1 258 | is~an~error~ 259 | \else 260 | are~\int_use:N \g_@@_helper_errors_int\space errors~ 261 | \fi related~to~`physics2'.\MessageBreak 262 | You~can~find~all~the~errors~in~`\c_sys_jobname_str.log' 263 | } 264 | } 265 | { 266 | \PackageWarning { physics2 } 267 | { 268 | You~are~in~the~`debug'~mode~of~`physics2'. \MessageBreak 269 | There~are~no~errors~related~to~`physics2'~in~your \MessageBreak 270 | document.~To~avoid~seeing~this~message,~please~add\MessageBreak 271 | `debug-mode-off'~option~to~`physics2'.~That~is, \MessageBreak 272 | \@spaces \token_to_str:N 273 | \usepackage[debug-mode-off]{physics2} \MessageBreak 274 | If~you~want~to~add~anything~new~to~your~document, \MessageBreak 275 | it's~recommended~to~turn~on~the~debug~mode~again 276 | } 277 | } 278 | \group_end: 279 | } 280 | \ExplSyntaxOff 281 | % 282 | %<@@=> 283 | % \end{macrocode} 284 | % \endinput 285 | -------------------------------------------------------------------------------- /physics2-code.dtx: -------------------------------------------------------------------------------- 1 | % \iffalse meta-comment 2 | % 3 | % Copyright (C) 2022-2024 by Zhang Tingxuan 4 | % 5 | % This work may be distributed and/or modified under the 6 | % conditions of the LaTeX Project Public License, either 7 | % version 1.3c of this license or (at your option) any later 8 | % version. The latest version of this license is in: 9 | % 10 | % http://www.latex-project.org/lppl.txt 11 | % 12 | % and version 1.3 or later is part of all distributions of 13 | % LaTeX version 2005/12/01 or later. 14 | % 15 | % This work has the LPPL maintenance status `maintained'. 16 | % 17 | % The Current Maintainer of this work is Zhang Tingxuan. 18 | % 19 | % This work consists of the files physics2-code.dtx, 20 | % physics2-code-*.dtx, 21 | % the derived files physics2.ins, 22 | % physics2.sty, 23 | % phys.*.sty, 24 | % the documentation files physics2.pdf, 25 | % physics2-code.pdf, 26 | % and README.md. 27 | % 28 | %<*internal> 29 | \iffalse 30 | % 31 | % 32 | %<*readme> 33 | # The `physics2` package 34 | 35 | This package defines commands for typesetting math formulae faster and 36 | more simply. `physics2` is a modularized package, each module provides its 37 | own function while the package itself only provides very few functions. 38 | You can load modules of `physics2` after loading the `physics2` package. 39 | 40 | ## Functions and usages 41 | 42 | See `physics2.pdf`. 43 | 44 | ## Build 45 | 46 | Run 47 | 48 | ``` 49 | ./build.sh 50 | ``` 51 | 52 | ## For developers and advanced users 53 | 54 | If you want to contribute to this repository, you can 55 | 56 | - pull requests [here](https://github.com/AlphaZTX/physics2/pulls); 57 | - report bugs or request enhancement [here](https://github.com/AlphaZTX/physics2/issues). 58 | 59 | Before committing, please read `physics2-code.pdf` first. 60 | 61 | ## License 62 | 63 | This work may be distributed and/or modified under the conditions of the 64 | [LaTeX Project Public License](http://www.latex-project.org/lppl.txt), 65 | either version 1.3c of this license or (at your option) any later version. 66 | 67 | This work has the LPPL maintenance status `maintained`. 68 | 69 | The Current Maintainer of this work is 70 | [Zhang Tingxuan](https://www.ctan.org/author/zhang-tx). 71 | 72 | % 73 | % 74 | %<*internal> 75 | \fi 76 | \begingroup 77 | \def\NameOfLaTeXe{LaTeX2e} 78 | \expandafter\endgroup\ifx\NameOfLaTeXe\fmtname\else 79 | \csname fi\endcsname 80 | % 81 | % 82 | %<*install> 83 | \input docstrip.tex 84 | \keepsilent 85 | 86 | \preamble 87 | 88 | Copyright (C) 2022-2024 by Zhang Tingxuan 89 | 90 | This work may be distributed and/or modified under the 91 | conditions of the LaTeX Project Public License, either 92 | version 1.3c of this license or (at your option) any later 93 | version. The latest version of this license is in: 94 | 95 | http://www.latex-project.org/lppl.txt 96 | 97 | and version 1.3 or later is part of all distributions of 98 | LaTeX version 2005/12/01 or later. 99 | 100 | This work has the LPPL maintenance status `maintained'. 101 | 102 | The Current Maintainer of this work is Zhang Tingxuan. 103 | 104 | This work consists of the files physics2-code.dtx, 105 | physics2-code-.dtx, 106 | and the derived files physics2.ins, 107 | physics2.sty, 108 | phys..sty, 109 | physics2-code.pdf, 110 | and README.md. 111 | 112 | \endpreamble 113 | 114 | \usedir{tex/latex/physics2} 115 | \generate{ 116 | \file{physics2.sty} {\from{physics2-code-base.dtx}{package}} 117 | \file{phys.patch.amsmath.sty} {\from{physics2-code-utility.dtx}{patch.amsmath}} 118 | } 119 | \generate{ 120 | \file{phys.helper.sty} {\from{physics2-code-utility.dtx}{helper-begin} 121 | \from{physics2-code-ab.dtx}{helper} 122 | \from{physics2-code-braket.dtx}{helper} 123 | \from{physics2-code-matrix.dtx}{helper} 124 | \from{physics2-code-operator.dtx}{helper} 125 | \from{physics2-code-misc.dtx}{helper} 126 | \from{physics2-code-utility.dtx}{helper-end}} 127 | } 128 | \generate{ 129 | \file{phys.ab.sty} {\from{physics2-code-ab.dtx}{ab}} 130 | \file{phys.xab.sty} {\from{physics2-code-ab.dtx}{xab}} 131 | \file{phys.ab.legacy.sty} {\from{physics2-code-ab.dtx}{ab.legacy}} 132 | \file{phys.ab.braket.sty} {\from{physics2-code-braket.dtx}{ab.braket}} 133 | \file{phys.braket.sty} {\from{physics2-code-braket.dtx}{braket}} 134 | \file{phys.xmat.sty} {\from{physics2-code-matrix.dtx}{xmat}} 135 | \file{phys.diagmat.sty} {\from{physics2-code-matrix.dtx}{diagmat}} 136 | \file{phys.doubleprod.sty} {\from{physics2-code-operator.dtx}{doubleprod}} 137 | \file{phys.diffop.sty} {\from{physics2-code-operator.dtx}{diffop}} 138 | \file{phys.nabla.legacy.sty} {\from{physics2-code-operator.dtx}{nabla.legacy}} 139 | \file{phys.op.legacy.sty} {\from{physics2-code-operator.dtx}{op.legacy}} 140 | \file{phys.bm-um.legacy.sty} {\from{physics2-code-misc.dtx}{bm-um.legacy}} 141 | \file{phys.qtext.legacy.sty} {\from{physics2-code-misc.dtx}{qtext.legacy}} 142 | } 143 | % 144 | %<*internal> 145 | \usedir{source/latex/physics2} 146 | \generate{ 147 | \file{physics2.ins} {\from{physics2-code.dtx}{install}} 148 | } 149 | % 150 | %<*install> 151 | \usedir{doc/latex/physics2} 152 | \generate{ 153 | \nopreamble\nopostamble 154 | \file{README.md} {\from{physics2-code.dtx}{readme}} 155 | } 156 | 157 | \obeyspaces 158 | \Msg{******************************************************} 159 | \Msg{* *} 160 | \Msg{* To finish the installation you have to move the *} 161 | \Msg{* following files into a directory searched by TeX: *} 162 | \Msg{* physics2.sty, *} 163 | \Msg{* phys..sty (for all modules). *} 164 | \Msg{* *} 165 | \Msg{* The recommended directory is *} 166 | \Msg{* TEXMFDIST/tex/latex/physics2 *} 167 | \Msg{* *} 168 | \Msg{* To produce the documentation, run the file *} 169 | \Msg{* physics2-code.dtx through XeLaTeX or LuaLaTeX. *} 170 | \Msg{* *} 171 | \Msg{* Happy TeXing! *} 172 | \Msg{* *} 173 | \Msg{******************************************************} 174 | 175 | \endbatchfile 176 | % 177 | % 178 | %<*internal> 179 | \fi 180 | % 181 | % 182 | %<*driver> 183 | \ProvidesFile{physics2-code.dtx}[2024/01/22 (c) Copyright 2022-2024 by Zhang Tingxuan] 184 | \documentclass{l3doc} 185 | \setlist{noitemsep} 186 | \definecolor{pkg}{RGB}{0,120,80} 187 | \definecolor{mod}{RGB}{0,0,150} 188 | \definecolor{gray}{rgb}{.5,.5,.5} 189 | \definecolor{lnk}{RGB}{232,0,0} 190 | \hypersetup{linktocpage,colorlinks=true,linkcolor=lnk} 191 | \usepackage{amsmath,fontspec,physics2} 192 | \setmonofont{cmunbtl}[Extension=.otf,ItalicFont=cmunbto,BoldFont=cmuntt,BoldItalicFont=cmunst] 193 | \fvset{gobble=2,fontsize=\small,numbers=left,numbersep=0pt,vspace=\MacrocodeTopsep,xleftmargin=\MacroIndent} 194 | \usepackage{hologo} 195 | \makeatletter 196 | \protected\def\pkg#1{\texorpdfstring{\textcolor{pkg}{\textsf{#1}}}{“#1”}} 197 | \protected\def\modu#1{\texorpdfstring{\textcolor{mod}{\textsf{#1}}}{“#1”}} 198 | \def\first@token#1#2\@nil{#1} 199 | \renewcommand\theFancyVerbLine{{\color{gray}\sffamily\tiny\ifnum\c@FancyVerbLine=1 200 | EXAMPLE\quad\fi\arabic{FancyVerbLine}}\ } 201 | \def\@getver#1/#2/#3 #4 #5\@nil{#1-#2-#3\quad#4} 202 | \xdef\@date{\expandafter\expandafter\expandafter\@getver\csname ver@physics2.sty\endcsname\@nil} 203 | \@addtoreset{CodelineNo}{section} 204 | \def\DeclareSourceFile#1{% 205 | \markright{Source file: \texttt{physics2-code-#1.dtx}}% 206 | \part{physics2-code-#1.dtx}% 207 | \markright{Source file: \texttt{physics2-code-#1.dtx}}% 208 | } 209 | \def\ps@phy{% 210 | \def\@oddfoot{\rightmark\hfil\thepage}% 211 | \let\@oddhead\relax% 212 | \let\@mkboth\markboth 213 | } 214 | \ExplSyntaxOn 215 | \seq_new:N \l__phydoc_tmpa_seq 216 | \seq_new:N \l__phydoc_tmpb_seq 217 | \tl_new:N \l__phydoc_tmpa_tl 218 | \tl_new:N \l__phydoc_tmpb_tl 219 | \cs_new:Npn \guard #1 220 | { 221 | \tl_if_head_eq_charcode:nNTF {#1} @ 222 | { \ensuremath{\langle}\texttt{#1}\ensuremath{\rangle} } 223 | { \Module{#1} } 224 | } 225 | \prg_set_conditional:Npnn \__codedoc_if_macro_internal:n #1 { p , T , F , TF } 226 | { 227 | \bool_if:NTF \l__codedoc_macro_internal_bool 228 | { \prg_return_true: } 229 | { \prg_return_false: } 230 | } 231 | \cs_new_protected:Npn \relatedint #1 232 | { 233 | \par 234 | { \small\textbf{Related~internal~command(s):}~ \relatedint_auxi:n {#1} . } 235 | \par 236 | } 237 | \cs_new:Npn \relatedint_auxi:n #1 238 | { 239 | \seq_set_from_clist:Nn \l__phydoc_tmpa_seq {#1} 240 | \seq_set_map:NNn \l__phydoc_tmpb_seq \l__phydoc_tmpa_seq 241 | { \csref {##1} } 242 | \seq_use:Nnnn \l__phydoc_tmpb_seq { ~and~ } { ,~ } { ,~and~ } 243 | } 244 | \cs_new_protected:Npn \csref #1 245 | { 246 | \tl_set:No \l__phydoc_tmpa_tl { #1 } 247 | \__codedoc_replace_at_at:N \l__phydoc_tmpa_tl 248 | \__codedoc_get_hyper_target:oN { \l__phydoc_tmpa_tl } \l__phydoc_tmpa_tl 249 | \hyperref [ \l__phydoc_tmpa_tl ] { \cs {#1} } 250 | } 251 | \ExplSyntaxOff 252 | \makeatother 253 | \title{Code documentation to the \pkg{physics2} package} 254 | \author{Zhang Tingxuan\\\url{https://www.github.com/AlphaZTX/physics2}} 255 | \parskip 2pt plus 1pt minus 0.5pt 256 | \begin{document} 257 | \maketitle 258 | \tableofcontents\newpage 259 | \pagestyle{phy} 260 | \DocInput{physics2-code-doc-intro.dtx} 261 | \DocInput{physics2-code-base.dtx} 262 | \DocInput{physics2-code-utility.dtx} 263 | \DocInput{physics2-code-ab.dtx} 264 | \DocInput{physics2-code-braket.dtx} 265 | \DocInput{physics2-code-matrix.dtx} 266 | \DocInput{physics2-code-operator.dtx} 267 | \DocInput{physics2-code-misc.dtx} 268 | \clearpage 269 | \PrintIndex 270 | \end{document} 271 | % 272 | % \fi 273 | % 274 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The LaTeX Project Public License 2 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- 3 | 4 | LPPL Version 1.3c 2008-05-04 5 | 6 | Copyright 1999 2002-2008 LaTeX3 Project 7 | Everyone is allowed to distribute verbatim copies of this 8 | license document, but modification of it is not allowed. 9 | 10 | 11 | PREAMBLE 12 | ======== 13 | 14 | The LaTeX Project Public License (LPPL) is the primary license under 15 | which the LaTeX kernel and the base LaTeX packages are distributed. 16 | 17 | You may use this license for any work of which you hold the copyright 18 | and which you wish to distribute. This license may be particularly 19 | suitable if your work is TeX-related (such as a LaTeX package), but 20 | it is written in such a way that you can use it even if your work is 21 | unrelated to TeX. 22 | 23 | The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE', 24 | below, gives instructions, examples, and recommendations for authors 25 | who are considering distributing their works under this license. 26 | 27 | This license gives conditions under which a work may be distributed 28 | and modified, as well as conditions under which modified versions of 29 | that work may be distributed. 30 | 31 | We, the LaTeX3 Project, believe that the conditions below give you 32 | the freedom to make and distribute modified versions of your work 33 | that conform with whatever technical specifications you wish while 34 | maintaining the availability, integrity, and reliability of 35 | that work. If you do not see how to achieve your goal while 36 | meeting these conditions, then read the document `cfgguide.tex' 37 | and `modguide.tex' in the base LaTeX distribution for suggestions. 38 | 39 | 40 | DEFINITIONS 41 | =========== 42 | 43 | In this license document the following terms are used: 44 | 45 | `Work' 46 | Any work being distributed under this License. 47 | 48 | `Derived Work' 49 | Any work that under any applicable law is derived from the Work. 50 | 51 | `Modification' 52 | Any procedure that produces a Derived Work under any applicable 53 | law -- for example, the production of a file containing an 54 | original file associated with the Work or a significant portion of 55 | such a file, either verbatim or with modifications and/or 56 | translated into another language. 57 | 58 | `Modify' 59 | To apply any procedure that produces a Derived Work under any 60 | applicable law. 61 | 62 | `Distribution' 63 | Making copies of the Work available from one person to another, in 64 | whole or in part. Distribution includes (but is not limited to) 65 | making any electronic components of the Work accessible by 66 | file transfer protocols such as FTP or HTTP or by shared file 67 | systems such as Sun's Network File System (NFS). 68 | 69 | `Compiled Work' 70 | A version of the Work that has been processed into a form where it 71 | is directly usable on a computer system. This processing may 72 | include using installation facilities provided by the Work, 73 | transformations of the Work, copying of components of the Work, or 74 | other activities. Note that modification of any installation 75 | facilities provided by the Work constitutes modification of the Work. 76 | 77 | `Current Maintainer' 78 | A person or persons nominated as such within the Work. If there is 79 | no such explicit nomination then it is the `Copyright Holder' under 80 | any applicable law. 81 | 82 | `Base Interpreter' 83 | A program or process that is normally needed for running or 84 | interpreting a part or the whole of the Work. 85 | 86 | A Base Interpreter may depend on external components but these 87 | are not considered part of the Base Interpreter provided that each 88 | external component clearly identifies itself whenever it is used 89 | interactively. Unless explicitly specified when applying the 90 | license to the Work, the only applicable Base Interpreter is a 91 | `LaTeX-Format' or in the case of files belonging to the 92 | `LaTeX-format' a program implementing the `TeX language'. 93 | 94 | 95 | 96 | CONDITIONS ON DISTRIBUTION AND MODIFICATION 97 | =========================================== 98 | 99 | 1. Activities other than distribution and/or modification of the Work 100 | are not covered by this license; they are outside its scope. In 101 | particular, the act of running the Work is not restricted and no 102 | requirements are made concerning any offers of support for the Work. 103 | 104 | 2. You may distribute a complete, unmodified copy of the Work as you 105 | received it. Distribution of only part of the Work is considered 106 | modification of the Work, and no right to distribute such a Derived 107 | Work may be assumed under the terms of this clause. 108 | 109 | 3. You may distribute a Compiled Work that has been generated from a 110 | complete, unmodified copy of the Work as distributed under Clause 2 111 | above, as long as that Compiled Work is distributed in such a way that 112 | the recipients may install the Compiled Work on their system exactly 113 | as it would have been installed if they generated a Compiled Work 114 | directly from the Work. 115 | 116 | 4. If you are the Current Maintainer of the Work, you may, without 117 | restriction, modify the Work, thus creating a Derived Work. You may 118 | also distribute the Derived Work without restriction, including 119 | Compiled Works generated from the Derived Work. Derived Works 120 | distributed in this manner by the Current Maintainer are considered to 121 | be updated versions of the Work. 122 | 123 | 5. If you are not the Current Maintainer of the Work, you may modify 124 | your copy of the Work, thus creating a Derived Work based on the Work, 125 | and compile this Derived Work, thus creating a Compiled Work based on 126 | the Derived Work. 127 | 128 | 6. If you are not the Current Maintainer of the Work, you may 129 | distribute a Derived Work provided the following conditions are met 130 | for every component of the Work unless that component clearly states 131 | in the copyright notice that it is exempt from that condition. Only 132 | the Current Maintainer is allowed to add such statements of exemption 133 | to a component of the Work. 134 | 135 | a. If a component of this Derived Work can be a direct replacement 136 | for a component of the Work when that component is used with the 137 | Base Interpreter, then, wherever this component of the Work 138 | identifies itself to the user when used interactively with that 139 | Base Interpreter, the replacement component of this Derived Work 140 | clearly and unambiguously identifies itself as a modified version 141 | of this component to the user when used interactively with that 142 | Base Interpreter. 143 | 144 | b. Every component of the Derived Work contains prominent notices 145 | detailing the nature of the changes to that component, or a 146 | prominent reference to another file that is distributed as part 147 | of the Derived Work and that contains a complete and accurate log 148 | of the changes. 149 | 150 | c. No information in the Derived Work implies that any persons, 151 | including (but not limited to) the authors of the original version 152 | of the Work, provide any support, including (but not limited to) 153 | the reporting and handling of errors, to recipients of the 154 | Derived Work unless those persons have stated explicitly that 155 | they do provide such support for the Derived Work. 156 | 157 | d. You distribute at least one of the following with the Derived Work: 158 | 159 | 1. A complete, unmodified copy of the Work; 160 | if your distribution of a modified component is made by 161 | offering access to copy the modified component from a 162 | designated place, then offering equivalent access to copy 163 | the Work from the same or some similar place meets this 164 | condition, even though third parties are not compelled to 165 | copy the Work along with the modified component; 166 | 167 | 2. Information that is sufficient to obtain a complete, 168 | unmodified copy of the Work. 169 | 170 | 7. If you are not the Current Maintainer of the Work, you may 171 | distribute a Compiled Work generated from a Derived Work, as long as 172 | the Derived Work is distributed to all recipients of the Compiled 173 | Work, and as long as the conditions of Clause 6, above, are met with 174 | regard to the Derived Work. 175 | 176 | 8. The conditions above are not intended to prohibit, and hence do not 177 | apply to, the modification, by any method, of any component so that it 178 | becomes identical to an updated version of that component of the Work as 179 | it is distributed by the Current Maintainer under Clause 4, above. 180 | 181 | 9. Distribution of the Work or any Derived Work in an alternative 182 | format, where the Work or that Derived Work (in whole or in part) is 183 | then produced by applying some process to that format, does not relax or 184 | nullify any sections of this license as they pertain to the results of 185 | applying that process. 186 | 187 | 10. a. A Derived Work may be distributed under a different license 188 | provided that license itself honors the conditions listed in 189 | Clause 6 above, in regard to the Work, though it does not have 190 | to honor the rest of the conditions in this license. 191 | 192 | b. If a Derived Work is distributed under a different license, that 193 | Derived Work must provide sufficient documentation as part of 194 | itself to allow each recipient of that Derived Work to honor the 195 | restrictions in Clause 6 above, concerning changes from the Work. 196 | 197 | 11. This license places no restrictions on works that are unrelated to 198 | the Work, nor does this license place any restrictions on aggregating 199 | such works with the Work by any means. 200 | 201 | 12. Nothing in this license is intended to, or may be used to, prevent 202 | complete compliance by all parties with all applicable laws. 203 | 204 | 205 | NO WARRANTY 206 | =========== 207 | 208 | There is no warranty for the Work. Except when otherwise stated in 209 | writing, the Copyright Holder provides the Work `as is', without 210 | warranty of any kind, either expressed or implied, including, but not 211 | limited to, the implied warranties of merchantability and fitness for a 212 | particular purpose. The entire risk as to the quality and performance 213 | of the Work is with you. Should the Work prove defective, you assume 214 | the cost of all necessary servicing, repair, or correction. 215 | 216 | In no event unless required by applicable law or agreed to in writing 217 | will The Copyright Holder, or any author named in the components of the 218 | Work, or any other party who may distribute and/or modify the Work as 219 | permitted above, be liable to you for damages, including any general, 220 | special, incidental or consequential damages arising out of any use of 221 | the Work or out of inability to use the Work (including, but not limited 222 | to, loss of data, data being rendered inaccurate, or losses sustained by 223 | anyone as a result of any failure of the Work to operate with any other 224 | programs), even if the Copyright Holder or said author or said other 225 | party has been advised of the possibility of such damages. 226 | 227 | 228 | MAINTENANCE OF THE WORK 229 | ======================= 230 | 231 | The Work has the status `author-maintained' if the Copyright Holder 232 | explicitly and prominently states near the primary copyright notice in 233 | the Work that the Work can only be maintained by the Copyright Holder 234 | or simply that it is `author-maintained'. 235 | 236 | The Work has the status `maintained' if there is a Current Maintainer 237 | who has indicated in the Work that they are willing to receive error 238 | reports for the Work (for example, by supplying a valid e-mail 239 | address). It is not required for the Current Maintainer to acknowledge 240 | or act upon these error reports. 241 | 242 | The Work changes from status `maintained' to `unmaintained' if there 243 | is no Current Maintainer, or the person stated to be Current 244 | Maintainer of the work cannot be reached through the indicated means 245 | of communication for a period of six months, and there are no other 246 | significant signs of active maintenance. 247 | 248 | You can become the Current Maintainer of the Work by agreement with 249 | any existing Current Maintainer to take over this role. 250 | 251 | If the Work is unmaintained, you can become the Current Maintainer of 252 | the Work through the following steps: 253 | 254 | 1. Make a reasonable attempt to trace the Current Maintainer (and 255 | the Copyright Holder, if the two differ) through the means of 256 | an Internet or similar search. 257 | 258 | 2. If this search is successful, then enquire whether the Work 259 | is still maintained. 260 | 261 | a. If it is being maintained, then ask the Current Maintainer 262 | to update their communication data within one month. 263 | 264 | b. If the search is unsuccessful or no action to resume active 265 | maintenance is taken by the Current Maintainer, then announce 266 | within the pertinent community your intention to take over 267 | maintenance. (If the Work is a LaTeX work, this could be 268 | done, for example, by posting to comp.text.tex.) 269 | 270 | 3a. If the Current Maintainer is reachable and agrees to pass 271 | maintenance of the Work to you, then this takes effect 272 | immediately upon announcement. 273 | 274 | b. If the Current Maintainer is not reachable and the Copyright 275 | Holder agrees that maintenance of the Work be passed to you, 276 | then this takes effect immediately upon announcement. 277 | 278 | 4. If you make an `intention announcement' as described in 2b. above 279 | and after three months your intention is challenged neither by 280 | the Current Maintainer nor by the Copyright Holder nor by other 281 | people, then you may arrange for the Work to be changed so as 282 | to name you as the (new) Current Maintainer. 283 | 284 | 5. If the previously unreachable Current Maintainer becomes 285 | reachable once more within three months of a change completed 286 | under the terms of 3b) or 4), then that Current Maintainer must 287 | become or remain the Current Maintainer upon request provided 288 | they then update their communication data within one month. 289 | 290 | A change in the Current Maintainer does not, of itself, alter the fact 291 | that the Work is distributed under the LPPL license. 292 | 293 | If you become the Current Maintainer of the Work, you should 294 | immediately provide, within the Work, a prominent and unambiguous 295 | statement of your status as Current Maintainer. You should also 296 | announce your new status to the same pertinent community as 297 | in 2b) above. 298 | 299 | 300 | WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE 301 | ====================================================== 302 | 303 | This section contains important instructions, examples, and 304 | recommendations for authors who are considering distributing their 305 | works under this license. These authors are addressed as `you' in 306 | this section. 307 | 308 | Choosing This License or Another License 309 | ---------------------------------------- 310 | 311 | If for any part of your work you want or need to use *distribution* 312 | conditions that differ significantly from those in this license, then 313 | do not refer to this license anywhere in your work but, instead, 314 | distribute your work under a different license. You may use the text 315 | of this license as a model for your own license, but your license 316 | should not refer to the LPPL or otherwise give the impression that 317 | your work is distributed under the LPPL. 318 | 319 | The document `modguide.tex' in the base LaTeX distribution explains 320 | the motivation behind the conditions of this license. It explains, 321 | for example, why distributing LaTeX under the GNU General Public 322 | License (GPL) was considered inappropriate. Even if your work is 323 | unrelated to LaTeX, the discussion in `modguide.tex' may still be 324 | relevant, and authors intending to distribute their works under any 325 | license are encouraged to read it. 326 | 327 | A Recommendation on Modification Without Distribution 328 | ----------------------------------------------------- 329 | 330 | It is wise never to modify a component of the Work, even for your own 331 | personal use, without also meeting the above conditions for 332 | distributing the modified component. While you might intend that such 333 | modifications will never be distributed, often this will happen by 334 | accident -- you may forget that you have modified that component; or 335 | it may not occur to you when allowing others to access the modified 336 | version that you are thus distributing it and violating the conditions 337 | of this license in ways that could have legal implications and, worse, 338 | cause problems for the community. It is therefore usually in your 339 | best interest to keep your copy of the Work identical with the public 340 | one. Many works provide ways to control the behavior of that work 341 | without altering any of its licensed components. 342 | 343 | How to Use This License 344 | ----------------------- 345 | 346 | To use this license, place in each of the components of your work both 347 | an explicit copyright notice including your name and the year the work 348 | was authored and/or last substantially modified. Include also a 349 | statement that the distribution and/or modification of that 350 | component is constrained by the conditions in this license. 351 | 352 | Here is an example of such a notice and statement: 353 | 354 | %% pig.dtx 355 | %% Copyright 2005 M. Y. Name 356 | % 357 | % This work may be distributed and/or modified under the 358 | % conditions of the LaTeX Project Public License, either version 1.3 359 | % of this license or (at your option) any later version. 360 | % The latest version of this license is in 361 | % http://www.latex-project.org/lppl.txt 362 | % and version 1.3 or later is part of all distributions of LaTeX 363 | % version 2005/12/01 or later. 364 | % 365 | % This work has the LPPL maintenance status `maintained'. 366 | % 367 | % The Current Maintainer of this work is M. Y. Name. 368 | % 369 | % This work consists of the files pig.dtx and pig.ins 370 | % and the derived file pig.sty. 371 | 372 | Given such a notice and statement in a file, the conditions 373 | given in this license document would apply, with the `Work' referring 374 | to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being 375 | generated from `pig.dtx' using `pig.ins'), the `Base Interpreter' 376 | referring to any `LaTeX-Format', and both `Copyright Holder' and 377 | `Current Maintainer' referring to the person `M. Y. Name'. 378 | 379 | If you do not want the Maintenance section of LPPL to apply to your 380 | Work, change `maintained' above into `author-maintained'. 381 | However, we recommend that you use `maintained', as the Maintenance 382 | section was added in order to ensure that your Work remains useful to 383 | the community even when you can no longer maintain and support it 384 | yourself. 385 | 386 | Derived Works That Are Not Replacements 387 | --------------------------------------- 388 | 389 | Several clauses of the LPPL specify means to provide reliability and 390 | stability for the user community. They therefore concern themselves 391 | with the case that a Derived Work is intended to be used as a 392 | (compatible or incompatible) replacement of the original Work. If 393 | this is not the case (e.g., if a few lines of code are reused for a 394 | completely different task), then clauses 6b and 6d shall not apply. 395 | 396 | 397 | Important Recommendations 398 | ------------------------- 399 | 400 | Defining What Constitutes the Work 401 | 402 | The LPPL requires that distributions of the Work contain all the 403 | files of the Work. It is therefore important that you provide a 404 | way for the licensee to determine which files constitute the Work. 405 | This could, for example, be achieved by explicitly listing all the 406 | files of the Work near the copyright notice of each file or by 407 | using a line such as: 408 | 409 | % This work consists of all files listed in manifest.txt. 410 | 411 | in that place. In the absence of an unequivocal list it might be 412 | impossible for the licensee to determine what is considered by you 413 | to comprise the Work and, in such a case, the licensee would be 414 | entitled to make reasonable conjectures as to which files comprise 415 | the Work. 416 | -------------------------------------------------------------------------------- /doc/physics2-legacy.tex: -------------------------------------------------------------------------------- 1 | %% ****************************************************** 2 | %% * This work may be distributed and/or modified under * 3 | %% * the conditions of the LaTeX Project Public License * 4 | %% * http://www.latex-project.org/lppl.txt * 5 | %% * either version 1.3c of this license or any later * 6 | %% * version. * 7 | %% ****************************************************** 8 | \documentclass[11pt,letterpaper]{article} 9 | \usepackage{amsmath} 10 | \usepackage{unicode-math} 11 | \setmainfont{Libertinus Serif} 12 | \setsansfont{Libertinus Sans} 13 | \setmonofont{NotoSansMono}[ 14 | Scale=MatchLowercase, 15 | Extension=.ttf, 16 | UprightFont=*-Light, 17 | BoldFont=*-Medium 18 | ] 19 | \setmathfont{Libertinus Math} 20 | \usepackage{physics2} 21 | \usephysicsmodule{ab} 22 | \usephysicsmodule{ab.legacy,nabla.legacy} 23 | \usephysicsmodule{op.legacy,qtext.legacy} 24 | \usephysicsmodule{ab.braket} 25 | \usephysicsmodule{diagmat} 26 | \usephysicsmodule[showleft=3,showtop=3]{xmat} 27 | \usepackage{derivative} 28 | \input{phy2docdef.tex} 29 | \title{\pkg{physics2} manual for the legacy \pkg{physics} users} 30 | \begin{document} 31 | \maketitle 32 | 33 | \begin{abstract} 34 | This short document describes \pkg*{physics2} package for those who are 35 | used to the \pkg*{physics} package. This document is only a simple reference 36 | manual for: 37 | \begin{itemize} 38 | \item Frequent users of the legacy \pkg{physics} package; 39 | \item Those who have to maintain a document written with \pkg{physics}; 40 | \item Users who failed to use \pkg*{unicode-math} with \pkg{physics}. 41 | \end{itemize} 42 | It seems no reason for any other user to read \emph{this} document instead of 43 | the \href{./physics2.pdf}{package documentation} of \pkg{physics2}, 44 | because this document cannot describe the package in detail. 45 | 46 | In this document, the modules of \pkg{physics2} will be introduced in 47 | the same order as the \pkg{physics} documentation. 48 | \end{abstract} 49 | 50 | \section*{Contents} 51 | \begin{multicols}{2} 52 | \contentsonly 53 | \end{multicols} 54 | \ifnum\value{page}=1 \vfil\clearpage\fi 55 | 56 | \section{Before you start} 57 | \subsection{Legacy problems with \pkg{physics} package} 58 | \label{subsec:physics-legacy-problems} 59 | The \pkg{physics} package provides \cs{qty} command for automatic-sizing 60 | braces. The \cs{qty} command would cause conflict with the \pkg{siunitx} 61 | package, which provides a unified method to typeset numbers and units 62 | correctly. 63 | 64 | Besides, after you loaded \pkg{physics}, when you type \cs{homework} you 65 | will get Maxwell equations and Schrödinger equation. The \cs{homework} 66 | command is ``declared'' in \texttt{physics.sty} but it was not described 67 | in the documentation. That is, if you have defined \cs{homework} before 68 | loading \pkg{physics} package, \pkg{physics} would overwrite the definition 69 | ``silently''. 70 | 71 | The vector-notation part of \pkg{physics} uses \pkg*{amsmath}'s (more exactly, 72 | \texttt{amsbsy.sty}'s) \cs{boldsymbol} command to generate bold vectors. 73 | Commands for cross/dot product are defined with \cs{boldsymbol}. 74 | \cs{boldsymbol} uses \cs{mathversion}, a \LaTeXe\ kernel command that works 75 | well with traditional TFM-based fonts but fails when using \pkg{unicode-math}. 76 | 77 | In the definition of \cs{imat}, \cs{xmat}, \cs{dmat} and \cs{admat} commands 78 | from \pkg{physics}, there is a \cs{newtoks} command which allocates a token 79 | list register and two \cs{newcount} commands allocating two count registers. 80 | Every time you write a command like \cs{imat} in your document, then one token 81 | list register and two count registers will be wasted. What's even worse is 82 | that, if you wrote really too many matrix commands from \pkg{physics} (for 83 | example, 32767 \cs{imat}s in \hologo{LuaLaTeX}), there'd be no room for a new 84 | \cs{count}. 85 | 86 | \pkg{physics} integrated all the functions in one file (\texttt{physics.sty}), 87 | that is, you cannot load one of the total seven parts of functions; you have 88 | to load the seven parts altogether, even included the extra \cs{homework} 89 | command we mentioned in the first paragraph. 90 | 91 | Moreover, the code of \texttt{physics.sty} ``abuses'' the \texttt{g}-type 92 | arguments of \pkg*{xparse} package. Therefore the syntax of \pkg{physics} package 93 | looks kind of weird. See \href{https://tex.stackexchange.com/questions/% 94 | 470819/macros-dv-and-pdv-eat-the-subsequent-parenthesis-argument/470842#470842}% 95 | {here} for more. 96 | 97 | \subsection{Loading \pkg{physics2}} 98 | The \pkg{physics2} package includes different modules, among which every module 99 | focuses on one single function. 100 | 101 | Write the following line in the preamble to load \pkg{physics2}: 102 | \begin{Verbatim} 103 | \usepackage{physics2} 104 | \end{Verbatim} 105 | But this is not enough. \pkg{physics2} contains different modules. 106 | If you want to load any module of \pkg{physics2}, write this line after loading 107 | \pkg{physics2} package: 108 | \begin{displayed} 109 | \cs{usephysicsmodule}\marg{module list} 110 | \end{displayed} 111 | For example, ``\verb|\usephysicsmodule{ab,doubleprod}|'' loads the \modu{ab} 112 | module and the \modu{doubleprod} module. 113 | 114 | You can also load a module with options: 115 | \begin{displayed} 116 | \cs{usephysicsmodule}\oarg{option list}\marg{module} 117 | \end{displayed} 118 | For example, ``\verb|\usephysicsmodule[legacy]{ab}|'' loads \modu{ab} with the 119 | option ``\opt{legacy}''. 120 | 121 | \pardanger Attention, if you used any font package in your document, remember 122 | that \pkg{physics2} requires to be loaded \emph{after} font packages. 123 | 124 | 125 | \section{List of commands} 126 | \subsection{Automatic bracing}\label{subsec:ab-and-legacy} 127 | As mentioned in \S\ref{subsec:physics-legacy-problems}, the \cs{qty} command 128 | from \pkg{physics} would cause conflicts with \pkg{siunitx}. The command for 129 | automatic braces in \pkg{physics2} is \cs{ab}, a shorthand for 130 | {\bfseries a}utomatic {\bfseries b}races. 131 | 132 | The \cs{ab} command requires the \modu{ab} module, so don't forget to write 133 | \verb|\usephysicsmodule{ab}| in the preamble after you loaded \pkg{physics2}. 134 | Always remember, \emph{do not put an \cs{ab} separately in the end of a math 135 | formula}. Take some examples: 136 | \begin{example} 137 | \[ \ab ( \frac12 ) \quad 138 | \ab [ \frac12 ] \quad 139 | \ab\{ \frac12 \} \] 140 | \end{example} 141 | \cs{ab} can modify a delimiter-braced subformula. But the delimiters should 142 | not be out of the range described by the following chart: 143 | \begin{center} 144 | \begin{tabular}{c@{\hskip2em}l@{\hskip2em}c} 145 | \opt{(},\quad\opt{)} && \\ 146 | \opt{[},\quad\opt{]} && \\ 147 | \cs{\{},\quad\cs{\}} &or& \cs{lbrace},\quad\cs{rbrace} \\ 148 | \opt{<},\quad\opt{>} &or& \cs{langle},\quad\cs{rangle} \\ 149 | \opt{|},\quad\opt{|} &or& \cs{vert},\quad\cs{vert} \\ 150 | \cs{|},\quad\cs{|} &or& \cs{Vert},\quad\cs{Vert} 151 | \end{tabular} 152 | \end{center} 153 | For example, \verb|$\ab{foo}$| and \verb|$\ab(foo]$| are illegal, but 154 | \verb|$\ab\{foo\}$| and \verb|$\ab(foo)$| are okay; \verb|$\ab([)$| 155 | is okay but \verb|$\ab(()$| is illegal. 156 | 157 | \pardanger Attention, if you want to delimit a subformula with ``\{'' and 158 | ``\}'', you can only write \verb|\{|, \verb|\}| or \cs{lbrace}, \cs{rbrace} 159 | around it. \verb|{| and \verb|}| are not supported in \modu{ab} module. 160 | 161 | Between \cs{ab} and the first delimiter can be a ``biggg'' command, that is, 162 | from \cs{big} to \cs{Bigg}. Actually, you can also write \cs{biggg} and 163 | \cs{Biggg} because \pkg{physics2} defines these after you load it. For example, 164 | \begin{example} 165 | \[ \ab\Big \| \frac12 \| \quad 166 | \ab\Bigg < \frac12 > \quad 167 | \ab\Biggg| \frac12 | \] 168 | \end{example} 169 | Between \cs{ab} and the first delimiter can also be a star (\opt{*}), which 170 | means ``use the default size of delimiters''. But in this situation, you 171 | needn't use the \cs{ab} command at all. 172 | 173 | The \pkg{physics} package provides commands like \cs{pqty}, \cs{bqty}. In 174 | the \modu{ab} module of \pkg{physics2}, these commands have changed to 175 | \cs{pab}, \cs{bab}, etc. The following example shows all the 176 | \texttt{\textbackslash}$X$\texttt{ab} commands in \modu{ab} module: 177 | \begin{example} 178 | \def\0{\frac12} 179 | \[ \pab{\0} \quad \bab{\0} 180 | \quad \Bab{\0} \] 181 | \[ \aab{\0} \quad \vab{\0} 182 | \quad \Vab{\0} \] 183 | \end{example} 184 | \texttt{\textbackslash$X$ab} can take an optional star and an optional \oarg{biggg} 185 | argument. For example, 186 | \begin{example} 187 | \def\0{\frac12} 188 | \[ \pab[Big]{\0} \quad \bab*{\0} \] 189 | \end{example} 190 | 191 | \pkg{physics} also provides the following commands: 192 | \begin{Verbatim}[fontsize=\small] 193 | \abs \norm \eval \order \comm \acomm \pb 194 | \end{Verbatim} 195 | \pardanger These commands are not originally supported by \pkg{physics2}, but 196 | the first four commands can be used through the \modu{ab.legacy} module of 197 | \pkg{physics2}: 198 | \begin{Verbatim} 199 | \usephysicsmodule{ab.legacy} 200 | \end{Verbatim} 201 | For example, 202 | \begin{example} 203 | \def\0{\frac12} 204 | \[ \abs{\0} \quad \abs[big]{\0} 205 | \quad \abs*{\0} \] 206 | \end{example} 207 | Users of the legacy \pkg{physics} package should notice that the syntax of 208 | \cs{eval} has been changed. The \modu{ab.legacy} module abandoned the 209 | \verb"\eval(foo|"-like syntax. The new \cs{eval}'s syntax is just like other 210 | commands in this module. There are also two variants of \cs{eval} --- \cs{peval} 211 | and \cs{beval}. For example, 212 | \begin{example} 213 | \def\0{1+\frac12x} 214 | \[ \eval{\0}_a^b \quad 215 | \peval*{\0}_a^b \quad 216 | \beval[big]{\0}_a^b \] 217 | \end{example} 218 | The \cs{comm}, \cs{acomm} and \cs{pb} (Poisson bracket) are not supported. 219 | But you can write like \verb|\ab[foo,baz]| or \verb|\bab{foo,baz}| instead. 220 | 221 | By the way, you can set the ``order'' symbol in \modu{ab.legacy} through 222 | the \opt{order} option like this: 223 | \begin{Verbatim} 224 | \usephysicsmodule[order=O]{ab.legacy} 225 | \end{Verbatim} 226 | Then \verb|$\order(N)$| yields $O(N)$. 227 | 228 | \subsection{Vector notation} 229 | Unfortunately, there is not a plan for \pkg{physics2} to support this part 230 | of \pkg{physics} completely, but the rest of this section will show some 231 | methods to maintain the document written with \pkg{physics}. 232 | 233 | The \cs{vb}(\opt{*}), \cs{va}(\opt{*}) and \cs{vu}(\opt{*}) are not supported 234 | in any module of \pkg{physics2}. But these commands can be defined by copying 235 | the following lines below and pasting them in the preamble: 236 | \begin{Verbatim}[fontsize=\small] 237 | \makeatletter 238 | \newcommand\vb{\@ifstar\boldsymbol\mathbf} 239 | \newcommand\va[1]{\@ifstar{\vec{#1}}{\vec{\mathrm{#1}}}} 240 | \newcommand\vu[1]{% 241 | \@ifstar{\hat{\boldsymbol{#1}}}{\hat{\mathbf{#1}}}} 242 | \makeatother 243 | \end{Verbatim} 244 | The \cs{boldsymbol} command requires the \pkg*{amsmath} or \pkg*{bm} package. 245 | If you prefer to use \pkg{bm}, you can also use the \cs{bm} command. 246 | What's more, if you tried the commands above, you might find that, 247 | the result of \cs{va} above is different from that of \pkg{physics}. 248 | This is because, if you choose to present a vector in bold, there's almost 249 | no need to put a \cs{vec} ($\vec{\mskip9mu}$) sign above it. 250 | 251 | However, the method above may not work well with \pkg*{unicode-math} 252 | because there are so many OpenType math fonts without a bold version. 253 | When using \pkg{unicode-math}, it's recommended to use \cs{symbf} and 254 | \cs{symbfit} for a separate vector. For example, \verb|$\symbf{0}$| yields 255 | $\symbf{0}$, and \verb|$\symbfit{A}$| yields $\symbfit{A}$. 256 | 257 | The \cs{vdot} and \cs{cross} commands are not supported in any module 258 | of \pkg{physics2}. Actually, there is no need to use a bold ``$\cdot$'' 259 | or ``$\times$'' for the products of two vectors. Using \cs{cdot} and 260 | \cs{times} is enough. 261 | 262 | The commands related to ``$\nabla$'' are supported through \modu{nabla.legacy} 263 | module. These commands are \cs{grad}, \cs{div} and \cs{curl}. These commands 264 | should not be put in the end of a math formula either (just like \cs{ab}). 265 | Notice that the former \cs{div} command for a ``$\divsymbol$'' (if there 266 | exists one) is redefined as \cs{divsymbol}. For example, 267 | \begin{example} 268 | % \usephysicsmodule{nabla.legacy} 269 | \[ \grad F \quad 270 | \grad(\frac G2) \] 271 | \[ \div\Bigg[X] \quad 272 | \curl*\{\frac Y2\} \] 273 | \[ 2 \divsymbol 1 \] 274 | \end{example} 275 | Actually, the nabla-related commands end with \cs{ab}. Thus, the subformula 276 | after these commands can be delimited with \verb|()|, \verb|[]| and \verb|\{\}|. 277 | 278 | The \modu{nabla.legacy} requires the \pkg*{fixdif} package at least 279 | version 2.0 (file date: 2023/01/31 or after 2023/01/31). 280 | 281 | By the way, if you are used to writing \cs{bm} for a vector but interested in 282 | \pkg{unicode-math}, the \modu{bm-um.legacy} module would be a passable 283 | alternative to \pkg{bm} package. Notice that the \cs{bm} command from the 284 | \modu{bm-um.legacy} module can only take \emph{one} letter (or \emph{one} digit) 285 | as its argument. 286 | 287 | \subsection{Operators} 288 | There's no plan for \pkg{physics2} to support this part of \pkg{physics} 289 | completely. The syntax in this part of \pkg{physics} (such as \verb|\tan[2](x)|) 290 | abuses \pkg*{xparse}. 291 | 292 | It's suggested to write like this if you used the \modu{ab} module: 293 | \begin{Verbatim}[fontsize=\small] 294 | $ \sin^2 \ab( \frac{\alpha}{2} ) $ 295 | \end{Verbatim} 296 | Rather than take the superscript as an optional argument of the command of 297 | log-like functions. 298 | 299 | The \pkg{physics} package provides a bundle of commands for log-like functions 300 | that have not been defined in the \LaTeXe\ kernel. Those log-like functions 301 | can be used with the \modu{op.legacy} module; this module does not support 302 | the syntax of \pkg{physics} either. For example: 303 | \begin{example} 304 | % \usephysicsmodule{op.legacy} 305 | \[ \asin^2 x \quad \rank \{ A \} \] 306 | \end{example} 307 | The \cs{Re} and \cs{Im} commands are redefined as operators ``$\Re$'' and 308 | ``$\Im$'', while $\Resymbol$ and $\Imsymbol$ are reserved as \cs{Resymbol} and 309 | \cs{Imsymbol}. $\Resymbol$ and $\Imsymbol$ are ordinary symbols but $\Re$ and 310 | $\Im$ are operators. 311 | 312 | \subsection{Quick quad text}\label{subsec:qtext} 313 | The \modu{qtext.legacy} module provides the \cs{q}\meta{foo} commands 314 | for \cs{quad}-wrapped texts. These commands have the same syntax as 315 | \pkg{physics}. For example, 316 | \begin{example} 317 | % \usephysicsmodule{qtext.legacy} 318 | \[ A \qq {foo bar} B \] 319 | \[ A \qq*{foo bar} B \] 320 | \[ C \qcc D \qcc* E \] 321 | \[ F \qif G \qthen H \] 322 | \end{example} 323 | All the commands described in \S2.4 of 324 | \href{http://mirrors.ctan.org/macros/latex/contrib/physics/physics.pdf}% 325 | {\textsf{physics} documentation} are supported when using \modu{qtext.legacy} 326 | module, but I don't recommend using this module unless you are maintaining a 327 | document written with \pkg{physics}'s \cs{q}\meta{foo} commands. 328 | 329 | \subsection{Derivatives} 330 | There is no plan for \pkg{physics2} to support this part of \pkg{physics}. If 331 | you want to typeset the differential operators on a better sense, you can try 332 | the \pkg*{fixdif} package; if you want an easy way to type derivatives, you 333 | can try the \pkg*{derivative} package. These two packages can be used 334 | together. For example, 335 | \begin{example} 336 | % \usepackage{fixdif,derivative} 337 | \[ \pdv{f}{x,y,z} \d x \] 338 | Math ($\d x$) v.s.\ Text (\d x) 339 | \end{example} 340 | Here are the documentations of 341 | \href{http://mirrors.ctan.org/macros/latex/contrib/fixdif/fixdif.pdf}% 342 | {\textsf{fixdif}} and 343 | \href{http://mirrors.ctan.org/macros/latex/contrib/derivative/derivative% 344 | .pdf}{\textsf{derivative}}. 345 | 346 | \pkg{fixdif}'s commands behave better in superscripts and subscripts. 347 | 348 | \subsection{Dirac bra-ket notation} 349 | There are two solutions to Dirac bra-ket in \pkg{physics2} --- \modu{ab.braket} 350 | and \modu{braket}. These two modules are \emph{not} compatible and neither of 351 | them supports \pkg{physics}'s syntax completely. 352 | Click \hyperlink{para:ab.braket}{\textcolor{cyan}{here}} to see the 353 | \modu{ab.braket} module and \hyperlink{para:braket}{\textcolor{cyan}{here}} 354 | to see the \modu{braket} module. 355 | 356 | \paragraph{The \modu{ab.braket} module} 357 | \hypertarget{para:ab.braket}{This} module provides four commands --- \cs{bra}, \cs{ket}, \cs{braket} and 358 | \cs{ketbra}. After these commands can be a star (\opt{*}) or a ``biggg'' 359 | command. These commands share similar syntaxes like \cs{ab}'s syntax. But, 360 | \emph{the bra-ket commands from \modu{ab.braket} module are completely different 361 | from \cs{ab}}. Their internal structures are different. 362 | 363 | The argument of \cs{bra} should be delimited with \opt{<} and \opt{|}, that is, 364 | \begin{center} 365 | \cs{bra} \opt{<} \meta{subformula} \opt{|} 366 | \end{center} 367 | For example, 368 | \begin{example} 369 | \[ \bra < \frac \phi 2 | \] 370 | \[ \bra*< \frac \phi 2 | \] 371 | \[ \bra\Big< \phi | \] 372 | \end{example} 373 | The argument of \cs{ket} should be delimited with \opt{|} and \opt{>}, that is, 374 | \begin{center} 375 | \cs{ket} \opt{|} \meta{subformula} \opt{>} 376 | \end{center} 377 | For example, 378 | \begin{example} 379 | \[ \ket | \frac \psi 2 > \] 380 | \[ \ket*| \frac \psi 2 > \] 381 | \[ \ket\Big| \psi > \] 382 | \end{example} 383 | \pardanger 384 | If you want to write ``$>$'' and ``$<$'' for relations in the argument of 385 | \cs{bra} and \cs{ket}, you can write \verb|\mathrel{>}| and \verb|\mathrel{<}| 386 | (although there is almost no such need). 387 | 388 | The argument of \cs{braket} should be delimited with \opt{<} and \opt{>}, 389 | that is, 390 | \begin{center} 391 | \cs{braket} \opt{<} \meta{subformula} \opt{>} 392 | \end{center} 393 | In the \meta{subformula} argument, every ``\opt{|}'' will be regarded as an 394 | extensible vertical bar. For example, 395 | \begin{example} 396 | \[ \braket< \phi > \] 397 | \[ \braket< \phi | \psi > \] 398 | \[ \braket< \phi | A | \psi > \] 399 | \end{example} 400 | \begin{example} 401 | \def\0{\frac\phi2} 402 | \[ \braket < \0 | \psi > \] 403 | \[ \braket* < \0 | \psi > \] 404 | \[ \braket\Bigg< \0 | \psi > \] 405 | \end{example} 406 | The argument of \cs{ketbra} should be delimited with \opt{|} and \opt{|}. 407 | In the argument, \opt{>} and \opt{<} will be regarded as extensible $\rangle$ 408 | and $\langle$. That is, 409 | \begin{center} 410 | \cs{ketbra} \opt{|} \meta{subformula$_1$} \opt{>} \meta{optional} 411 | \opt{<} \meta{subformula$_2$} \opt{|} 412 | \end{center} 413 | For example, 414 | \begin{example} 415 | \def\0{\frac\phi2} 416 | \[ \ketbra | \0 >< \psi | \] 417 | \[ \ketbra* | \0 >< \psi | \] 418 | \[ \ketbra\Bigg| \0 >< \psi | \] 419 | \end{example} 420 | \begin{example} 421 | \def\0{\frac\phi2} 422 | \[ \ketbra| \0 >_x^y < \psi | \] 423 | \end{example} 424 | \pardanger 425 | If you want to write ``$>$'' and ``$<$'' for relations in the argument of 426 | \cs{braket} and \cs{ketbra}, you can write \cs{>} and \cs{<} (although there 427 | is almost no such need). It is quite different from \verb|\mathrel{>}| or 428 | \verb|\mathrel{<}| because in these commands' argument, \opt{>} and \opt{<} 429 | will be redefined. 430 | 431 | \paragraph{The \modu{braket} module} 432 | \begingroup 433 | \makeatletter\def\phy@requiremodule#1{}% 434 | \def\PackageWarning#1#2{}% 435 | \input phy-braket.sty\makeatother 436 | \hypertarget{para:braket}{This} module contains four commands --- \cs{bra}, 437 | \cs{ket}, \cs{braket} and \cs{ketbra}. After these commands can be a star 438 | (\opt{*}) or a square-bracket-delimited size option, the size option can 439 | take the following values: 440 | \begin{center} 441 | \opt{big},\quad\opt{Big},\quad\opt{bigg},\quad\opt{Bigg},\quad 442 | \opt{biggg}\quad or\quad\opt{Biggg}. 443 | \end{center} 444 | Star stands for ``do not size the bra-ket automatically''. 445 | 446 | The argument(s) of these four commands are braced with \verb|{| and \verb|}|. 447 | \cs{bra} and \cs{ket} take one mandatory argument. For example, 448 | \begin{example} 449 | \def\0{\frac\phi2} 450 | \[ \bra {\0} \quad \bra* {\0} 451 | \quad \bra[Big] {\0} \] 452 | \[ \ket {\0} \quad \ket* {\0} 453 | \quad \ket[Big] {\0} \] 454 | \end{example} 455 | The \cs{braket} command, in default, can take two arguments. 456 | \begin{example} 457 | \def\0{\frac\phi2} 458 | \[ \braket {\0} {\psi} \quad 459 | \braket*{\0} {\psi} \quad 460 | \braket[big] {\0} {\psi} \] 461 | \end{example} 462 | If you want \cs{braket} to take one or three arguments, you can write the 463 | number of arguments in the square bracket. If you need to specify the size 464 | of bra-ket simultaneously, you need to separate the number and the size with 465 | a comma: 466 | \begin{example} 467 | \def\0{\frac\phi2} 468 | \[ \braket [1] {\0} \quad 469 | \braket*[1] {\0} \] 470 | \[ \braket [3] {\0}{A}{\psi} \] 471 | \[ \braket[3,big] {\0}{A}{\psi} 472 | \quad 473 | \braket[Big,3] {\0}{A}{\psi} \] 474 | \end{example} 475 | The \cs{ketbra} command takes two mandatory arguments. It can also take an 476 | optional argument between the two mandatory arguments. The optional argument 477 | will be placed between $\rangle$ and $\langle$: 478 | \begin{example} 479 | \def\0{\frac\phi2} 480 | \[ \ketbra {\0} {\psi} \quad 481 | \ketbra* {\0} {\psi} \] 482 | \[ \ketbra [Bigg] {\0} {\psi} \] 483 | \[ \ketbra {\0} [_x^y] {\psi} \] 484 | \end{example} 485 | \endgroup 486 | 487 | \subsection{Matrix macros} 488 | Unfortunately, \pkg{physics2} do not support the \cs{mqty} command from 489 | \pkg{physics}. If you are used to this command, you can write like this: 490 | \begin{Verbatim}[fontsize=\small] 491 | \newcommand\mqty[1]{\begin{matrix}#1\end{matrix}} 492 | \newcommand\pmqty[1]{\begin{pmatrix}#1\end{pmatrix}} 493 | $\ab(\mqty{foo})$ or $\pmqty{foo}$ 494 | \end{Verbatim} 495 | These are equal to physics's \verb|\mqty(foo)| (require \pkg{amsmath}). 496 | 497 | \pkg{physics2}'s \modu{diagmat} module provides \cs{diagmat} command 498 | for diagonal matrices. For example, 499 | \begin{example} 500 | \[ 501 | \diagmat { 1, 2, 3 } 502 | \] 503 | \end{example} 504 | \begin{example} 505 | \[ 506 | \pdiagmat [ empty = {} ] 507 | { a, b, c, d } 508 | \] 509 | \end{example} 510 | \cs{pdiagmat}, \cs{bdiagmat}, \cs{Bdiagmat}, \cs{vdiagmat} and \cs{Vdiagmat} 511 | are also available. 512 | 513 | \pkg{physics2}'s \modu{xmat} module provides \cs{xmat} command 514 | for matrices with formatted entries. For example, 515 | \begin{example} 516 | \[ 517 | \xmat{a}{2}{3} 518 | \] 519 | \end{example} 520 | \begin{example} 521 | % \usephysicsmodule 522 | % [showleft=3,showtop=3]{xmat} 523 | \[ 524 | \pxmat{X}{m}{n} 525 | \] 526 | \end{example} 527 | \begin{example} 528 | \[ 529 | \xmat [showleft=2,showtop=2, 530 | format=\texttt{#1[#2][#3]}] 531 | {x}{m}{n} 532 | \] 533 | \end{example} 534 | \cs{pxmat}, \cs{bxmat}, \cs{Bxmat}, \cs{vxmat} and \cs{Vxmat} are also available. 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | \end{document} -------------------------------------------------------------------------------- /physics2-code-base.dtx: -------------------------------------------------------------------------------- 1 | % \DeclareSourceFile{base} 2 | % 3 | % This file describes the \pkg{physics2} package (\file{physics2.sty}). 4 | % 5 | % \section{The \pkg{physics2} package} 6 | % 7 | % \begin{macrocode} 8 | %<@@=phy> 9 | % \end{macrocode} 10 | % 11 | % \subsection{API}\label{subsec:api.physics2} 12 | % 13 | % \begin{variable}{\phy@ModBoolA,\phy@ModBoolB, 14 | % \l_@@_module_a_bool,\l_@@_module_b_bool} 15 | % Booleans used for handling key-value options of a module. They are set false 16 | % when a module is loaded. Note that \cs{phy@ModBoolA} and \cs{l_@@_module_a_bool} 17 | % are different. \cs{phy@ModBoolA} is a \LaTeXe\ if switch, whose expansion is 18 | % either \cs{iftrue} or \cs{iffalse}. \cs{l_@@_module_a_bool} is a \LaTeX3 19 | % boolean variable, whose expansion is either \texttt{1} or \texttt{0}. 20 | % \end{variable} 21 | % 22 | % \begin{variable}{\phy@tempcnta,\phy@tempdima,\phy@tempdimb,\phy@tempskipa, 23 | % \phy@tempmuskipa,\phy@tempboxa,\ifphy@tempswa,\phy@temptoksa} 24 | % Common temporary variables that can be shared by any module. 25 | % \end{variable} 26 | % 27 | % \begin{variable}{\l_@@_tmpa_int,\l_@@_tmpb_int,\l_@@_tmpa_tl,\l_@@_tmpb_tl} 28 | % Common temporary variables (L3 style) that can be shared by any module. 29 | % \end{variable} 30 | % 31 | % \begin{function}{\usephysicsmodule,\RequirePhysicsModule} 32 | % \begin{syntax} 33 | % \cs{usephysicsmodule} \oarg{key-val options} \marg{module} \oarg{date} 34 | % \cs{RequirePhysicsModule} \oarg{key-val options} \marg{module} \oarg{date} 35 | % \end{syntax} 36 | % Loads modules. The usage is the same as \cs{RequirePackage}. 37 | % \cs{usephysicsmodule} is a user command, and \cs{RequirePhysicsModule} is a 38 | % developer command. 39 | % \relatedint{phy@modulewithdate} 40 | % \end{function} 41 | % 42 | % \begin{function}{\PassOptionsToPhysicsModule} 43 | % \begin{syntax} 44 | % \cs{PassOptionsToPhysicsModule} \marg{option list} \marg{module} 45 | % \end{syntax} 46 | % Passes options to a module. For example, 47 | % \begin{verbatim} 48 | % \PassOptionsToPhysicsModule{foo=bar}{baz} 49 | % \RequirePhysicsModule{baz} 50 | % \end{verbatim} 51 | % is equivalent to 52 | % \begin{verbatim} 53 | % \RequirePhysicsModule[foo=bar]{baz} 54 | % \end{verbatim} 55 | % \end{function} 56 | % 57 | % \begin{function}[TF]{\@@_cs_if_exist:c} 58 | % \begin{syntax} 59 | % \cs{@@_cs_if_exist:cTF} \marg{control sequence name} \marg{true code} \marg{false code} 60 | % \end{syntax} 61 | % Tests if the control sequence is currently defined, but it does not care 62 | % if its meaning is \cs{relax}. 63 | % \end{function} 64 | % 65 | % \begin{function}[TF]{\@@_if_token_eq:c} 66 | % \begin{syntax} 67 | % \cs{@@_if_token_eq:cTF} \marg{control sequence name} \marg{true code} \marg{false code} 68 | % \end{syntax} 69 | % Checks if two tokens are identical. Equivalent to \cs[no-index]{cs_if_eq:NN}. 70 | % \end{function} 71 | % 72 | % \begin{function}{\PhysicsModuleError,\PhysicsModuleWarning} 73 | % \begin{syntax} 74 | % \cs{PhysicsModuleError} \marg{module} \marg{error message} \marg{help message} 75 | % \cs{PhysicsModuleWarning} \marg{module} \marg{warning message} 76 | % \end{syntax} 77 | % Error and warning handlers for modules of this package. 78 | % \end{function} 79 | % 80 | % \begin{function}{\phy@mathvphantom,\@@_math_vphantom:n} 81 | % \begin{syntax} 82 | % \cs{phy@mathvphantom} \marg{math mode material} 83 | % \cs{@@_math_vphantom:n} \marg{math mode material} 84 | % \end{syntax} 85 | % A math mode version of \cs{vphantom}. 86 | % \relatedint{phy@mathvph@ntom} 87 | % \end{function} 88 | % 89 | % \begin{function}{\@@_reset_math_class:nnn} 90 | % \begin{syntax} 91 | % \cs{@@_reset_math_class:nnn} ???^^A\marg{charcode} \marg{previous math class} \marg{new math class} 92 | % \end{syntax} 93 | % Incomplete. 94 | % \end{function} 95 | % 96 | % \begin{function}{\delopen,\delclose} 97 | % \begin{syntax} 98 | % \cs{delopen} \meta{left delimiter} \meta{math mode material} \cs{delclose} \meta{right delimiter} 99 | % \end{syntax} 100 | % Re-packaged \cs{left} and \cs{right}. A \cs{left} and \cs{right} pair will 101 | % be treated as an inner formula, around which 3\,mu skips are inserted. If 102 | % you don't want the skips, use \cs{delopen} and \cs{delclose} instead. 103 | % \end{function} 104 | % 105 | % \begin{function}{\DeclareBiggg} 106 | % \begin{syntax} 107 | % \cs{DeclareBiggg} \meta{biggg command} \marg{factor} 108 | % \end{syntax} 109 | % Declares a biggg command whose size is determined by \meta{factor}. 110 | % The argument \meta{factor} is equivalent to the first argument of 111 | % \csref{bBigg@}. 112 | % \end{function} 113 | % 114 | % \begin{function}{\AutoDeclareBiggg} 115 | % \begin{syntax} 116 | % \cs{AutoDeclareBiggg} \meta{biggg command} 117 | % \end{syntax} 118 | % Declares a biggg command whose size is determined automatically. 119 | % Easier to use than \cs{DeclareBiggg}. 120 | % \end{function} 121 | % 122 | % \subsection{Internal commands} 123 | % 124 | % \begin{variable}{\g_@@_debug_mode_bool} 125 | % A global variable telling whether debug mode is turned on. 126 | % The \modu{helper} module will be required if we're in debug mode. 127 | % \end{variable} 128 | % 129 | % \begin{function}{\phy@modulewithdate} 130 | % \begin{syntax} 131 | % \cs{phy@modulewithdate} \oarg{keyval options} \marg{module} \oarg{date} 132 | % \end{syntax} 133 | % Loads a module with keyval options and a specific date. 134 | % \relatedint{phy@ResetModBools} 135 | % \begin{NOTE} 136 | % Hint: 137 | % \cs{@onefilewithoptions}\marg{filename}\oarg{options}\oarg{date}\marg{extension} 138 | % \end{NOTE} 139 | % \end{function} 140 | % 141 | % \begin{function}{\phy@ResetModBools} 142 | % \begin{syntax} 143 | % \cs{phy@ResetModBools} 144 | % \end{syntax} 145 | % Sets all booleans for handling modules' key-value options (like \cs{phy@ModBoolA}) 146 | % false. It's called every time a separate module is loaded. 147 | % \end{function} 148 | % 149 | % \begin{function}{\phy@mathvph@ntom} 150 | % \begin{syntax} 151 | % \cs{phy@mathvph@ntom} \meta{math style command} \marg{math mode material} 152 | % \end{syntax} 153 | % Generate a zero-width box with the height and depth of the math material in a 154 | % specific math style. \meta{math style command} is \cs[no-index]{displaystyle}, etc. 155 | % \end{function} 156 | % 157 | % \begin{function}{\@@_declare_biggg:Nn} 158 | % \begin{syntax} 159 | % \cs{@@_declare_biggg:Nn} \meta{biggg command} \marg{factor} 160 | % \end{syntax} 161 | % Internal version of \csref{DeclareBiggg}. 162 | % \end{function} 163 | % 164 | % \begin{function}{\@@_declare_biggg_auto:N} 165 | % \begin{syntax} 166 | % \cs{@@_declare_biggg_auto:N} \meta{biggg command} 167 | % \end{syntax} 168 | % Internal version of \csref{AutoDeclareBiggg}. 169 | % \relatedint{@@_declare_biggg:Nn,@@_biggg_parse:w} 170 | % \end{function} 171 | % 172 | % \begin{function}{\@@_biggg_parse:w} 173 | % \begin{syntax} 174 | % \cs{@@_biggg_parse:w} \meta{string} \cs{q_stop} 175 | % \end{syntax} 176 | % Gets the \meta{factor} of \csref{@@_declare_biggg:Nn} from \meta{string}. 177 | % \meta{string} should contain one \texttt{b} or \texttt{B}, one \texttt{i} 178 | % and a sequence of \texttt{g}. 179 | % \end{function} 180 | % 181 | % \begin{function}{\@@_declare_biggg:} 182 | % Declares all the biggg commands in the \pkg{physics2} package. 183 | % \end{function} 184 | % 185 | % \begin{function}{\@@_patch_unimath:} 186 | % See \S\ref{subsec:code.base} for details. 187 | % \end{function} 188 | % 189 | % \begin{function}{\@@_patch_no_unimath_common:} 190 | % See \S\ref{subsec:code.base} for details. 191 | % \end{function} 192 | % 193 | % \begin{function}{\@@_patch_mathtools:} 194 | % See \S\ref{subsec:code.base} for details. 195 | % \end{function} 196 | % 197 | % \begin{function}{\@@_patch_amsmath:} 198 | % See \S\ref{subsec:code.base} for details. 199 | % \end{function} 200 | % 201 | % \subsection{Code implementation}\label{subsec:code.base} 202 | % 203 | % \begin{macrocode} 204 | %<*package> 205 | \NeedsTeXFormat{LaTeX2e}[2024/11/01] 206 | \ProvidesPackage{physics2} 207 | [2025/03/01 v2.0.0 Tools for typesetting math formulae.] 208 | % \end{macrocode} 209 | % 210 | % \begin{macro}[int]{\phy@tempcnta,\phy@tempdima,\phy@tempdimb, 211 | % \phy@tempskipa,\phy@tempmuskipa,\phy@tempboxa, 212 | % \ifphy@tempswa,\phy@temptoksa} 213 | % \begin{macrocode} 214 | \newcount \phy@tempcnta 215 | \newdimen \phy@tempdima 216 | \newdimen \phy@tempdimb 217 | \newskip \phy@tempskipa 218 | \newmuskip \phy@tempmuskipa 219 | \newbox \phy@tempboxa 220 | \newif \ifphy@tempswa 221 | \newtoks \phy@temptoksa 222 | % \end{macrocode} 223 | % \end{macro} 224 | % 225 | % \begin{macro}[int]{\phy@ModBoolA,\phy@ModBoolB} 226 | % \begin{macrocode} 227 | \newif \ifphy@ModBoolA 228 | \newif \ifphy@ModBoolB 229 | % \end{macrocode} 230 | % \end{macro} 231 | % 232 | % \begin{macro}{\PhysicsModuleError} 233 | % \begin{macrocode} 234 | \gdef\PhysicsModuleError#1#2#3{% 235 | \GenericError{% 236 | (phys.#1)\@spaces\@spaces\@spaces\@spaces 237 | }{% 238 | Module #1 (of physics2) Error: #2% 239 | }{% 240 | See the physics2 package documentation (texdoc physics2) for explanation.% 241 | }{#3}% 242 | } 243 | % \end{macrocode} 244 | % \end{macro} 245 | % 246 | % \begin{macro}{\PhysicsModuleWarning} 247 | % \begin{macrocode} 248 | \def\PhysicsModuleWarning#1#2{% 249 | \GenericWarning{% 250 | (phys.#1)\@spaces\@spaces\@spaces\@spaces 251 | }{% 252 | Module #1 (of physics2) Warning: #2% 253 | }% 254 | } 255 | % \end{macrocode} 256 | % \end{macro} 257 | % 258 | % \begin{macro}{\usephysicsmodule, \RequirePhysicsModule} 259 | % \begin{macrocode} 260 | \def\usephysicsmodule{\@ifnextchar[%] 261 | {\phy@modulewithopt}{\phy@modulewithopt[]}} 262 | \let\RequirePhysicsModule\usephysicsmodule 263 | \@onlypreamble\usephysicsmodule 264 | \def\phy@modulewithopt[#1]#2{\@ifnextchar[%] 265 | {\phy@modulewithdate[{#1}]#2}{\phy@modulewithdate[{#1}]#2[]}} 266 | % \end{macrocode} 267 | % \end{macro} 268 | % 269 | % \begin{macro}{\phy@modulewithdate} 270 | % \begin{macrocode} 271 | \def\phy@modulewithdate[#1]#2[#3]{% 272 | \def\reserved@b##1,{% 273 | \ifx\@nnil##1\relax\else 274 | \ifx\@nnil##1\@nnil\else 275 | \phy@ResetModBools 276 | \noexpand\@onefilewithoptions{phys.##1}[{\unexpanded{#1}}][{#3}]% 277 | \noexpand\@pkgextension 278 | \fi 279 | \expandafter\reserved@b 280 | \fi}% 281 | \edef\reserved@a{\zap@space#2 \@empty}% 282 | \edef\reserved@a{\expandafter\reserved@b\reserved@a,\@nnil,}% 283 | \reserved@a} 284 | % \end{macrocode} 285 | % \end{macro} 286 | % 287 | % \begin{macro}{\PassOptionsToPhysicsModule} 288 | % \begin{macrocode} 289 | \def\PassOptionsToPhysicsModule#1#2{\@pass@ptions\@pkgextension{#1}{phys.#2}} 290 | % \end{macrocode} 291 | % \end{macro} 292 | % 293 | % \begin{macro}{\phy@mathvphantom,\phy@mathvph@ntom} 294 | % \begin{macrocode} 295 | \def\phy@mathvphantom#1{% 296 | \setbox\phy@tempboxa=\null% 297 | \mathpalette\phy@mathvph@ntom{#1}% 298 | } 299 | \def\phy@mathvph@ntom#1#2{% 300 | \setbox\@tempboxa\hbox{$#1#2$}% 301 | \ht\phy@tempboxa=\ht\@tempboxa 302 | \dp\phy@tempboxa=\dp\@tempboxa 303 | \box\phy@tempboxa 304 | } 305 | % \end{macrocode} 306 | % \end{macro} 307 | % 308 | % \begin{macro}{\delopen,\delclose} 309 | % \begin{macrocode} 310 | \protected\def\delopen{\mathopen{}\mathclose\bgroup\left} 311 | \protected\def\delclose{\aftergroup\egroup\right} 312 | % \end{macrocode} 313 | % \end{macro} 314 | % 315 | % \begin{macrocode} 316 | \ExplSyntaxOn 317 | % \end{macrocode} 318 | % 319 | % \begin{macro}[int]{\l_@@_tmpa_int,\l_@@_tmpb_int, 320 | % \l_@@_tmpa_tl,\l_@@_tmpb_tl, 321 | % \g_@@_debug_mode_bool, 322 | % \l_@@_module_a_bool,\l_@@_module_b_bool} 323 | % \begin{macrocode} 324 | \int_new:N \l_@@_tmpa_int 325 | \int_new:N \l_@@_tmpb_int 326 | \tl_new:N \l_@@_tmpa_tl 327 | \tl_new:N \l_@@_tmpb_tl 328 | \bool_new:N \g_@@_debug_mode_bool 329 | \bool_new:N \l_@@_module_a_bool 330 | \bool_new:N \l_@@_module_b_bool 331 | % \end{macrocode} 332 | % \end{macro} 333 | % 334 | % \begin{macro}{\phy@ResetModBools} 335 | % See \cs{phy@modulewithdate}. 336 | % \begin{macrocode} 337 | \protected \def \phy@ResetModBools 338 | { 339 | \global \phy@ModBoolAfalse 340 | \global \phy@ModBoolBfalse 341 | \bool_gset_false:N \l_@@_module_a_bool 342 | \bool_gset_false:N \l_@@_module_b_bool 343 | } 344 | % \end{macrocode} 345 | % \end{macro} 346 | % 347 | % \begin{macro}[TF]{\@@_cs_if_exist:c} 348 | % This is faster than \cs{cs_if_exist:cTF}, 20\% in \hologo{pdfTeX}, 5\% in 349 | % \hologo{LuaTeX} and 20\% in \hologo{XeTeX} (tested on 350 | % \href{https://www.texpage.com}{\TeX Page}). This command contains only one 351 | % bool check, one less than \cs{cs_if_exist:cTF}, which makes it faster. 352 | % \begin{macrocode} 353 | \prg_set_conditional:Npnn \@@_cs_if_exist:c #1 { TF } 354 | { 355 | \if_cs_exist:w #1\cs_end: 356 | \prg_return_true: \else: \prg_return_false: \fi: 357 | } 358 | % \end{macrocode} 359 | % \end{macro} 360 | % 361 | % \begin{macro}[TF]{\@@_if_token_eq:c} 362 | % An alias of \cs{cs_if_eq:NN}. 363 | % \begin{macrocode} 364 | \prg_set_conditional:Npnn \@@_if_token_eq:NN #1#2 { TF } 365 | { 366 | \if_meaning:w #1#2 367 | \prg_return_true: \else: \prg_return_false: \fi: 368 | } 369 | % \end{macrocode} 370 | % \end{macro} 371 | % 372 | % \begin{macro}{\@@_math_vphantom:n} 373 | % \begin{macrocode} 374 | \cs_set_eq:NN \@@_math_vphantom:n \phy@mathvphantom 375 | % \end{macrocode} 376 | % \end{macro} 377 | % 378 | % \begin{macro}{\DeclareBiggg,\@@_declare_biggg:Nn} 379 | % \begin{macrocode} 380 | \cs_set_nopar:Npn \DeclareBiggg #1#2 381 | { 382 | \AddToHook { begindocument/before } 383 | { \@@_declare_biggg:Nn #1 {#2} } 384 | } 385 | \cs_set_nopar:Npn \@@_declare_biggg:Nn #1#2 386 | { 387 | \cs_set_protected_nopar:Npn #1 { \bBigg@ { #2 } } 388 | \cs_set:Npe \l_@@_tmpa_tl 389 | { \exp_after:wN \use_none:n \token_to_str:N #1 } 390 | \cs_set_protected_nopar:cpn { \l_@@_tmpa_tl l } { \mathopen #1 } 391 | \cs_set_protected_nopar:cpn { \l_@@_tmpa_tl m } { \mathrel #1 } 392 | \cs_set_protected_nopar:cpn { \l_@@_tmpa_tl r } { \mathclose #1 } 393 | \cs_set_nopar:cpn { @@_chk_big_ \string #1 : } { } 394 | } 395 | % \end{macrocode} 396 | % \end{macro} 397 | % 398 | % \begin{macro}{\AutoDeclareBiggg,\@@_declare_biggg_auto:N,\@@_biggg_parse:w} 399 | % \begin{macrocode} 400 | \cs_set_nopar:Npn \AutoDeclareBiggg #1 401 | { 402 | \AddToHook { begindocument/before } 403 | { \@@_declare_biggg_auto:N {#1} } 404 | } 405 | \cs_set_nopar:Npn \@@_declare_biggg_auto:N #1 406 | { 407 | \tl_set:Ne \l_@@_tmpa_tl { \cs_to_str:N #1 } 408 | \exp_after:wN \@@_biggg_parse:w \l_@@_tmpa_tl \q_stop 409 | \exp_args:NNe \@@_declare_biggg:Nn #1 { \l_@@_tmpa_tl } 410 | } 411 | \cs_set_nopar:Npn \@@_biggg_parse:w #1#2#3 \q_stop 412 | { 413 | \int_zero:N \l_@@_tmpa_int 414 | \int_zero:N \l_@@_tmpb_int 415 | \tl_map_inline:nn { #3 } 416 | { 417 | \int_incr:N \l_@@_tmpa_int 418 | \token_if_eq_charcode:NNT ##1 g { \int_incr:N \l_@@_tmpb_int } 419 | } 420 | \bool_lazy_all:nF 421 | { 422 | { 423 | \bool_lazy_or_p:nn 424 | { \token_if_eq_charcode_p:NN #1 B } 425 | { \token_if_eq_charcode_p:NN #1 b } 426 | } 427 | { \token_if_eq_charcode_p:NN #2 i } 428 | { \int_compare_p:nNn \l_@@_tmpa_int = \l_@@_tmpb_int } 429 | } 430 | { 431 | \PackageError {physics2} 432 | { 433 | Invalid~argument~of~\string\DeclareBiggg :~#1#2#3 434 | } 435 | { 436 | The~argument~of~\string\DeclareBiggg\space should~be~like~ 437 | \string\Biggg\space or~\string\biggg. 438 | } 439 | } 440 | \tl_set:Ne \l_@@_tmpa_tl { \int_use:N \l_@@_tmpa_int } 441 | \token_if_eq_charcode:NNT #1 B { \tl_put_right:Nn \l_@@_tmpa_tl { .5 } } 442 | } 443 | % \end{macrocode} 444 | % \end{macro} 445 | % 446 | % \begin{macro}{\@@_declare_biggg:} 447 | % \begin{macrocode} 448 | \cs_set_nopar:Npn \@@_declare_biggg: 449 | { 450 | \cs_set_nopar:cpn { @@_chk_big_ \string * : } { } 451 | \@@_declare_biggg:Nn \big { 1 } 452 | \@@_declare_biggg:Nn \Big { 1.5 } 453 | \@@_declare_biggg:Nn \bigg { 2 } 454 | \@@_declare_biggg:Nn \Bigg { 2.5 } 455 | \@@_declare_biggg:Nn \biggg { 3 } 456 | \@@_declare_biggg:Nn \Biggg { 3.5 } 457 | } 458 | % \end{macrocode} 459 | % \end{macro} 460 | % 461 | % \begin{macro}{\@@_reset_math_class:nnn} 462 | % \begin{macrocode} 463 | \cs_set_nopar:Npn \@@_reset_math_class:nnn #1#2#3 464 | { } 465 | % \end{macrocode} 466 | % \end{macro} 467 | % 468 | % \begin{macro}{\@@_patch_unimath:} 469 | % \pkg{unicode-math} makes control sequences for math symbols the same as the 470 | % symbols themselves. For example, \cs{vert} and ``\texttt{\char`\|}'' are 471 | % \cs{cs_gset_eq:NN}'ed (or \cs{global}\cs{let}) to be same. 472 | % See \cs{__um_define_math_chars:} in \texttt{um-code-setchar.dtx}. 473 | % 474 | % In \modu{ab.braket} module of this package, we need \cs{vert} and 475 | % ``\texttt{\char`\|}'' to be different. So here we make \cs{vert} defined to 476 | % be a ``\texttt{\char`\|}'' with catcode 12 with \cs{xdef}. Then the meaning 477 | % of ``\texttt{\char`\|}'' is character ``\texttt{\char`\|}'' itself, and the 478 | % meaning of \cs{vert} is a \cs{protected}\cs{long} macro whose expansion is 479 | % ``\texttt{\char`\|}''. 480 | % \begin{macrocode} 481 | \cs_set_nopar:Npn \@@_patch_unimath: 482 | { 483 | \cs_gset_protected_nopar:Npe \vert { \char_generate:nn {"007C} {12} } 484 | } 485 | % \end{macrocode} 486 | % \end{macro} 487 | % 488 | % \begin{macro}{\@@_patch_no_unimath_common:} 489 | % In \LaTeXe\ kernel, \cs{vert} and \cs{|} are defined to be same, with 490 | % \cs{DeclareMathDelimiter}. In \modu{ab.braket} module of this package, we 491 | % also need \cs{vert} and \cs{|} to be different. So we use the same method 492 | % as \cs{@@_patch_unimath:}. 493 | % \begin{macrocode} 494 | \cs_set_nopar:Npn \@@_patch_no_unimath_common: 495 | { 496 | \cs_gset_protected_nopar:Npn \| { \Vert } 497 | } 498 | % \end{macrocode} 499 | % \end{macro} 500 | % 501 | % \begin{macro}{\@@_patch_amsmath:} 502 | % \begin{macrocode} 503 | \cs_set_nopar:Npn \@@_patch_amsmath: 504 | { 505 | \RequirePhysicsModule { patch.amsmath } 506 | } 507 | % \end{macrocode} 508 | % \end{macro} 509 | % 510 | % \begin{macro}{\@@_patch_mathtools:} 511 | % \cs{lparen} and \cs{rparen} are defined in \pkg{mathtools} or 512 | % \pkg{unicode-math}. If users didn't load any of them, we define them here. 513 | % The reason why we need to define them is that modules like \modu{ab} need 514 | % them. 515 | % \begin{macrocode} 516 | \cs_set_nopar:Npn \@@_patch_mathtools: 517 | { 518 | \cs_set_protected_nopar:Npe \lparen { ( } 519 | \cs_set_protected_nopar:Npe \rparen { ) } 520 | } 521 | % \end{macrocode} 522 | % \end{macro} 523 | % 524 | % The options of \pkg{physics2}. We use \cs{phy@ResetModBools} instead of 525 | % \cs{SetKeys}\marg{k-v defaults} to make it a little faster to compile. 526 | % \begin{macrocode} 527 | \DeclareKeys 528 | { 529 | debug-mode .bool_gset:N = \g_@@_debug_mode_bool , 530 | debug-mode-on .code:n = { \bool_gset_true:N \g_@@_debug_mode_bool } , 531 | debug-mode-on .value_forbidden:n = true , 532 | debug-mode-off .code:n = { \bool_gset_false:N \g_@@_debug_mode_bool } , 533 | debug-mode-off .value_forbidden:n = true , 534 | tight-braces .legacy_if_set:n = phy@ModBoolB , 535 | tight-braces .default:n = true 536 | } 537 | \SetKeys 538 | { 539 | debug-mode = true , 540 | tight-braces = true 541 | } 542 | \ProcessKeyOptions \relax 543 | \ifphy@ModBoolB 544 | \tl_set_eq:NN \g_@@_left_token \delopen 545 | \tl_set_eq:NN \g_@@_right_token \delclose 546 | \else 547 | \tl_set_eq:NN \g_@@_left_token \left 548 | \tl_set_eq:NN \g_@@_right_token \right 549 | \fi 550 | \tl_set_eq:NN \phy@left@tl \g_@@_left_token 551 | \tl_set_eq:NN \phy@right@tl \g_@@_right_token 552 | % \end{macrocode} 553 | % 554 | % Modules of \pkg{physics2} would use the following math symbol commands: 555 | % \begin{center} 556 | % \begin{minipage}{.6\textwidth} 557 | % \def\from#1{\textsuperscript{\textit{\textsf{#1}}}}% 558 | % \hfil 559 | % \begin{tabular}{lll} 560 | % \hline 561 | % & \cs{lparen}\from{m} & \cs{rparen}\from{m} \\ 562 | % & \cs{lbrack} & \cs{rbrack} \\ 563 | % & \cs{lbrace} & \cs{rbrace} \\ 564 | % & \cs{langle} & \cs{rangle} \\ 565 | % \cs{vert} & \cs{lvert}\from{a} & \cs{rvert}\from{a} \\ 566 | % \cs{Vert} & \cs{lVert}\from{a} & \cs{rVert}\from{a} \\ 567 | % \hline 568 | % \end{tabular}% 569 | % \hfil\par 570 | % \from{a}Defined in \pkg{amsmath} \par 571 | % \from{m}Defined in \pkg{mathtools} \par 572 | % \end{minipage} 573 | % \end{center} 574 | % If users load \pkg{unicode-math}, \pkg{unicode-math} would define these 575 | % commands. If not, note that we cannot use them directly because some of 576 | % them are not defined in \LaTeXe\ kernel. Some of them are defined in 577 | % \pkg{amsmath} and some are defined in \pkg{mathtools}. We need to define 578 | % those undefined in \pkg{physics2}. \pkg{mathtools} loads \pkg{amsmath} 579 | % automatically, so those defined in \pkg{amsmath} needn't be defined again 580 | % if \pkg{mathtools} is loaded. But if \pkg{amsmath} is loaded but \pkg{mathtools} 581 | % is not, we need to define those defined in \pkg{mathtools} but not in 582 | % \pkg{amsmath}. We need to make a patch for this, whose code is to define 583 | % these commands if one or some of them are not defined, that is, if at least 584 | % one of \pkg{unicode-math}, \pkg{mathtools} and \pkg{amsmath}, is not loaded. 585 | % First we need to check if \pkg{unicode-math} is loaded, then \pkg{mathtools}, 586 | % and finally \pkg{amsmath}. So we get 587 | % \begin{verbatim} 588 | % \IfPackageLoadedF { unicode-math } 589 | % { 590 | % \IfPackageLoadedF { mathtools } 591 | % { 592 | % \@@_patch_mathtools: % -> to define \lparen, \rparen 593 | % \IfPackageLoadedF { amsmath } 594 | % { 595 | % \@@_patch_amsmath: % -> to define \lvert, \rvert, \lVert, \rVert 596 | % } 597 | % } 598 | % } 599 | % \end{verbatim} 600 | % Those packages could be loaded after \pkg{physics2}, so it's better to delay 601 | % the code to the end of preamble. 602 | % 603 | % \pkg{unicode-math} can be loaded before or after \pkg{physics2}, so if we 604 | % want to check if \pkg{unicode-math} is loaded, it's better to delay the code 605 | % to the end of preamble. 606 | % 607 | % What's more, \pkg{unicode-math} delays the definition 608 | % of math symbols (\cs{__um_define_math_chars:}) after the \env{document} 609 | % environment begins. In order to make the patch work, we need to delay the 610 | % patch after \cs{__um_define_math_chars:}. That's why we use \cs{AtBeginDocument} 611 | % in the true branch of \cs{IfPackageLoadedTF} in the following code. 612 | % 613 | % If \pkg{unicode-math} is loaded, execute \cs{@@_patch_unimath:}. 614 | % \cs{@@_patch_unimath:} contains code to redefine math symbol commands, 615 | % and \pkg{unicode-math} defines math symbols with \cs{__um_define_math_chars:} 616 | % after \env{document} begins. So we need to execute \cs{@@_patch_unimath:} 617 | % after \cs{__um_define_math_chars:}. That's why we use \cs{AtBeginDocument} 618 | % in the following code. 619 | % \begin{macrocode} 620 | \AddToHook { begindocument/before } 621 | { 622 | \IfPackageLoadedTF { unicode-math } 623 | { 624 | \AddToHook { begindocument } { \@@_patch_unimath: } 625 | } 626 | { 627 | \@@_patch_no_unimath_common: 628 | \IfPackageLoadedF { mathtools } 629 | { 630 | \@@_patch_mathtools: 631 | \IfPackageLoadedF { amsmath } 632 | { 633 | \@@_patch_amsmath: 634 | } 635 | } 636 | } 637 | \@@_declare_biggg: 638 | \bool_if:NT \g_@@_debug_mode_bool 639 | { \RequirePhysicsModule { helper } } 640 | } 641 | % \end{macrocode} 642 | % 643 | % \begin{macrocode} 644 | \ExplSyntaxOff 645 | %<@@=> 646 | % 647 | % \end{macrocode} 648 | % 649 | % \endinput 650 | -------------------------------------------------------------------------------- /doc/physics2.tex: -------------------------------------------------------------------------------- 1 | %% ****************************************************** 2 | %% * This work may be distributed and/or modified under * 3 | %% * the conditions of the LaTeX Project Public License * 4 | %% * http://www.latex-project.org/lppl.txt * 5 | %% * either version 1.3c of this license or any later * 6 | %% * version. * 7 | %% ****************************************************** 8 | \documentclass[11pt,letterpaper]{article} 9 | \usepackage{amsmath} 10 | \usepackage{unicode-math} 11 | \setmainfont{Libertinus Serif} 12 | \setsansfont{Libertinus Sans} 13 | \setmonofont{NotoSansMono}[ 14 | Scale=MatchLowercase, 15 | Extension=.ttf, 16 | UprightFont=*-Light, 17 | BoldFont=*-Medium 18 | ] 19 | \setmathfont{Libertinus Math} 20 | \usepackage{physics2} 21 | \usephysicsmodule{ab,ab.braket} 22 | \usephysicsmodule{diagmat} 23 | \usephysicsmodule{doubleprod} 24 | \usephysicsmodule[showleft=3,showtop=3]{xmat} 25 | \usephysicsmodule{ab.legacy,nabla.legacy,op.legacy,qtext.legacy,bm-um.legacy} 26 | \input{phy2docdef.tex} 27 | \externaldocument[lega-]{physics2-legacy} 28 | \title{The \pkg{physics2} package} 29 | \begin{document} 30 | \maketitle 31 | 32 | \begin{abstract} 33 | This is the document for \pkg{physics2} package, which defines commands for 34 | typesetting math formulae faster and more simply. \pkg{physics2} is a 35 | modularized package, each module provides its own function. 36 | 37 | This document describes the \pkg{physics2} package in more detail. 38 | But if you are a user of the legacy \pkg{physics} package, you can click 39 | \href{./physics2-legacy.pdf}{here} to see the documentation for 40 | \pkg{physics} users before you start. If you never used \pkg{physics} package 41 | before, just read \emph{this} documentation. 42 | \end{abstract} 43 | 44 | \tableofcontents 45 | 46 | \section{Introduction} 47 | \subsection{The purpose of this package} 48 | This package aims to provide a bundle of commands for typesetting math faster 49 | in different modules. The commands provided by \pkg{physics2} and its different 50 | modules are designed to be short and easy to memorize. 51 | 52 | \subsection{Packages required} 53 | The \pkg{physics2} package itself only requires the \pkg*{keyval} package, which 54 | is part of the \pkg*{latex-graphics} bundle. Almost every \LaTeX\ distribution 55 | will include this bundle. 56 | 57 | Different modules of \pkg{physics2} might require different packages. It will 58 | be explained in the following sections that which module requires which package. 59 | 60 | The \pkg{physics2} package requires \LaTeXe\ kernel released after 2020/10. 61 | Please make sure that your \LaTeX\ distribution is not too old. 62 | 63 | \subsection{Loading \pkg{physics2} and its modules} 64 | Just like loading any package, write 65 | \begin{Verbatim} 66 | \usepackage{physics2} 67 | \end{Verbatim} 68 | in the preamble to load the \pkg{physics2} package. In the current version, 69 | \pkg{physics2} doesn't provide a package option. 70 | 71 | \pkg{physics2} itself doesn't provide many features. 72 | You need to load different modules of \pkg{physics2} to have different 73 | features applied to your document. 74 | 75 | \subsection{Loading a module of \pkg{physics2}} 76 | You can load a module of \pkg{physics2} only \emph{after} you write 77 | \verb|\usepackage{physics2}| in the preamble. Load a \pkg{physics2} module 78 | like this: 79 | \begin{center} 80 | \cs{usephysicsmodule}\marg{module} 81 | \end{center} 82 | The usage of \cs{usephysicsmodule} is similar to \cs{usepackage}, so you can 83 | load several modules in one line. For example, 84 | \begin{Verbatim} 85 | \usephysicsmodule{ab,ab.braket} 86 | \end{Verbatim} 87 | This line loads the \modu{ab} and \modu{ab.braket} modules. 88 | 89 | You can also load \emph{one} module with options. The options of a 90 | \pkg{physics2} module can be a comma-separated key-value list. For example, 91 | \begin{Verbatim} 92 | \usephysicsmodule[tightbraces=true]{ab} 93 | \usephysicsmodule{ab.braket,doubleprod} 94 | \end{Verbatim} 95 | These two lines load the \modu{ab} module with option 96 | \opt{tightbraces\:=\:true} and load \modu{ab.braket} and \modu{doubleprod} 97 | modules. 98 | 99 | The following sections introduce all the user-level modules of \pkg{physics2}. 100 | View back to the table of contents to see the names of user-level modules. 101 | 102 | \section{Modules of \pkg{physics2}} 103 | \subsection{Features of the bare \pkg{physics2} package} 104 | The following commands are available once you load \pkg{physics2} in preamble. 105 | 106 | \cs{delopen} and \cs{delclose}, followed by a math delimiter. They can be 107 | regarded as abbreviations of ``open delimiter'' and ``close delimiter''. If 108 | you had heard of the \pkg*{mleftright} package. You can regard \cs{delopen} 109 | and \cs{delclose} as a simpler version of \cs{mleft} and \cs{mright}. 110 | For example, 111 | \begin{example} 112 | \[ 0 \left(\frac12\right) 3 \] 113 | \[ 0 \delopen(\frac12\delclose) 3 \] 114 | \end{example} 115 | 116 | \cs{biggg} and \cs{Biggg}, followed by a math delimiter. They are even bigger 117 | than \cs{Bigg}. \cs{biggg} and \cs{Biggg} may be useful when you need to write 118 | something really tall in math mode, but most OpenType math font do not support 119 | \cs{langle} (or U+27E8) and \cs{rangle} (or U+27E9) in this large size. Take 120 | an example, 121 | \begin{example} 122 | \[\Biggg(\biggg(\Bigg(\bigg(\Big(\big(( 123 | )\big)\Big)\bigg)\Bigg)\biggg)\Biggg)\] 124 | \end{example} 125 | \cs{bigggl}, \cs{bigggm}, \cs{bigggr}, \cs{Bigggl}, \cs{Bigggm} and \cs{Bigggr} 126 | are also supported. 127 | 128 | \textbf{Note:} 129 | If you had heard version $0.x.y$ of \pkg{physics2}, you might know the 130 | \modu{common} module. Now the \modu{common} module is included in 131 | \pkg{physics2}.sty --- the source file of \modu{common} module is deleted 132 | but all the features of \modu{common} are reserved. Those commands above 133 | used to be provided by \modu{common} module, but now they are provided by 134 | \pkg{physics2}. 135 | 136 | \subsection{The \modu{ab} module --- automatic braces} 137 | This module provides the command \cs{ab}. The \cs{ab} command, as a shorthand 138 | of ``automatic braces'', would specify the size of the following pair of 139 | delimiters. The delimiters after \cs{ab} should not be out of the range 140 | described by the following chart: 141 | \begin{center} 142 | \begin{tabular}{c@{\hskip2em}l@{\hskip2em}c} 143 | \opt{(},\quad\opt{)} && \\ 144 | \opt{[},\quad\opt{]} && \\ 145 | \cs{\{},\quad\cs{\}} &or& \cs{lbrace},\quad\cs{rbrace} \\ 146 | \opt{<},\quad\opt{>} &or& \cs{langle},\quad\cs{rangle} \\ 147 | \opt{|},\quad\opt{|} &or& \cs{vert},\quad\cs{vert} \\ 148 | \cs{|},\quad\cs{|} &or& \cs{Vert},\quad\cs{Vert} 149 | \end{tabular} 150 | \end{center} 151 | For example, it's illegal to write an ``\verb|\ab(|'' without a ``\verb|)|''; 152 | it's also illegal to write \verb|\ab=foo=|. Take some correct examples: 153 | \begin{example} 154 | \[ \ab ( \frac12 ) \quad 155 | \ab [ \frac12 ] \quad 156 | \ab\{ \frac12 \} \] 157 | \end{example} 158 | You can also write a command from \cs{big} to \cs{Biggg} between \cs{ab} 159 | and the first delimiter, which means to specify the size of delimiters manually. 160 | Also, you can write a star (\opt{*}) between \cs{ab} and the first delimiter, 161 | to prevent \cs{ab} from setting the size of delimiters. For example, 162 | \begin{example} 163 | \[ \ab <\frac12> \quad 164 | \ab\biggg|\frac12| \quad 165 | \ab* \|\frac12\| \] 166 | \end{example} 167 | \pardanger 168 | Always remember, do not put an \cs{ab} separately at the end of math mode like 169 | \verb|$\ab$|, because \cs{ab} will try to absorb the following math shift 170 | character (\verb|$|) as its argument. 171 | 172 | \pardanger 173 | \textbf{Important Note:} The \modu{ab} module uses ``document commands'' 174 | module of \LaTeXe{} kernel (source file: ltcmd.dtx). This \LaTeXe{} kernel 175 | module provides a document-level command parser. \cs{ab} is a complex 176 | encapsulation of some internal document-level commands. Take an example, 177 | if you define a document-level command like this: 178 | \begin{Verbatim} 179 | \NewDocumentCommand \foo { r() } {::#1::} 180 | \end{Verbatim} 181 | You can write \verb|\foo(bar)| legally, but \verb|\foo(()| will be regarded 182 | illegal when you write another document-level command or end the paragraph. 183 | Similarly, things like \verb|\ab(()| will also cause errors. 184 | 185 | The \modu{ab} module also provides \texttt{\textbackslash}$X$\texttt{ab} 186 | commands, where $X$ can be \opt{p}, \opt{b}, \opt{B}, \opt{a}, \opt{v} and 187 | \opt{V}. These commands take a normal argument but not an argument delimited 188 | with paired delimiters. For example, 189 | \begin{example} 190 | \def\0{\frac12} 191 | \[ \pab{\0} \bab{\0} \Bab{\0} \] 192 | \[ \aab{\0} \vab{\0} \Vab{\0} \] 193 | \end{example} 194 | These \texttt{\textbackslash$X$ab} commands can take an optional star and 195 | an optional \oarg{biggg} argument. Star stands for using the default sizes. 196 | For example, 197 | \begin{example} 198 | \def\0{n+\frac12} 199 | \[ \pab[Big]{\0} \quad \bab*{\0} \] 200 | \end{example} 201 | 202 | \paragraph{The options of \modu{ab} module} 203 | \opt{tightbraces}, a bool type key, whose default value is \opt{true}, 204 | influences whether thin skips are reserved around the paired delimiters. 205 | It only works with the automatically sized delimiters. 206 | 207 | \subsection{The \modu{ab.braket} module --- Dirac bra-ket notation} 208 | This module provides four commands --- \cs{bra}, \cs{ket}, \cs{braket} and 209 | \cs{ketbra}. After these commands can be a star (\opt{*}) or a ``biggg'' 210 | command. These commands share similar syntaxes like \cs{ab}'s syntax. But, 211 | \emph{the bra-ket commands from \modu{ab.braket} module are completely different 212 | from \cs{ab}}. Their internal structures are different. 213 | 214 | The argument of \cs{bra} should be delimited with \opt{<} and \opt{|}, that is, 215 | \begin{center} 216 | \cs{bra} \opt{<} \meta{subformula} \opt{|} 217 | \end{center} 218 | For example, 219 | \begin{example} 220 | \[ \bra < \frac \phi 2 | \] 221 | \[ \bra*< \frac \phi 2 | \] 222 | \[ \bra\Big< \phi | \] 223 | \end{example} 224 | The argument of \cs{ket} should be delimited with \opt{|} and \opt{>}, that is, 225 | \begin{center} 226 | \cs{ket} \opt{|} \meta{subformula} \opt{>} 227 | \end{center} 228 | For example, 229 | \begin{example} 230 | \[ \ket | \frac \psi 2 > \] 231 | \[ \ket*| \frac \psi 2 > \] 232 | \[ \ket\Big| \psi > \] 233 | \end{example} 234 | \pardanger 235 | If you want to write ``$>$'' and ``$<$'' for relations in the argument of 236 | \cs{bra} and \cs{ket}, you can write \verb|\mathrel{>}| and \verb|\mathrel{<}| 237 | (although there is almost no such need). 238 | 239 | The argument of \cs{braket} should be delimited with \opt{<} and \opt{>}, 240 | that is, 241 | \begin{center} 242 | \cs{braket} \opt{<} \meta{subformula} \opt{>} 243 | \end{center} 244 | In the \meta{subformula} argument, every ``\opt{|}'' will be regarded as an 245 | extensible vertical bar. For example, 246 | \begin{example} 247 | \[ \braket< \phi > \] 248 | \[ \braket< \phi | \psi > \] 249 | \[ \braket< \phi | A | \psi > \] 250 | \end{example} 251 | \begin{example} 252 | \def\0{\frac\phi2} 253 | \[ \braket < \0 | \psi > \] 254 | \[ \braket* < \0 | \psi > \] 255 | \[ \braket\Bigg< \0 | \psi > \] 256 | \end{example} 257 | The argument of \cs{ketbra} should be delimited with \opt{|} and \opt{|}. 258 | In the argument, \opt{>} and \opt{<} will be regarded as extensible $\rangle$ 259 | and $\langle$. That is, 260 | \begin{center} 261 | \cs{ketbra} \opt{|} \meta{subformula$_1$} \opt{>} \meta{optional} 262 | \opt{<} \meta{subformula$_2$} \opt{|} 263 | \end{center} 264 | For example, 265 | \begin{example} 266 | \def\0{\frac\phi2} 267 | \[ \ketbra | \0 >< \psi | \] 268 | \[ \ketbra* | \0 >< \psi | \] 269 | \[ \ketbra\Bigg| \0 >< \psi | \] 270 | \end{example} 271 | \begin{example} 272 | \def\0{\frac\phi2} 273 | \[ \ketbra| \0 >_x^y < \psi | \] 274 | \end{example} 275 | \pardanger 276 | If you want to write ``$>$'' and ``$<$'' for relations in the argument of 277 | \cs{braket} and \cs{ketbra}, you can write \cs{>} and \cs{<} (although there 278 | is almost no such need). It is quite different from \verb|\mathrel{>}| or 279 | \verb|\mathrel{<}| because in these commands' argument, \opt{>} and \opt{<} 280 | will be redefined. 281 | 282 | \pardanger 283 | \textbf{Important Notes:} Commands provided by \modu{ab.braket} should NOT 284 | be placed barely in \meta{subformula} of \cs{ab}\texttt|\meta{subformula}\texttt|. 285 | Errors will arise if you write such code. To avoid the errors, you can write 286 | like this: 287 | \begin{example} 288 | \[ 289 | \ab| { \braket<\psi|\hat H|\psi> } | 290 | \] 291 | \end{example} 292 | Just add the braces. 293 | 294 | Next, the \modu{braket} module will be introduced. Please notice that 295 | \modu{braket} is conflict with \modu{ab.braket}, they cannot be used together. 296 | 297 | \subsection{The \modu{braket} module --- Dirac bra-ket notation} 298 | \begingroup 299 | \makeatletter\def\phy@requiremodule#1{}% 300 | \def\PackageWarning#1#2{}% 301 | \input phy-braket.sty\makeatother 302 | Please notice that this module is conflict with the \modu{ab.braket} module. 303 | Don't use them together. 304 | 305 | This module contains four commands --- \cs{bra}, \cs{ket}, \cs{braket} and 306 | \cs{ketbra}. After these commands can be a star (\opt{*}) or a 307 | square-bracket-delimited size option, the size option can 308 | take the following values: 309 | \begin{center} 310 | \opt{big},\quad\opt{Big},\quad\opt{bigg},\quad\opt{Bigg},\quad 311 | \opt{biggg}\quad or\quad\opt{Biggg}. 312 | \end{center} 313 | Star stands for ``do not size the bra-ket automatically''. 314 | 315 | The argument(s) of these four commands are braced with \verb|{| and \verb|}|. 316 | \cs{bra} and \cs{ket} take one mandatory argument. For example, 317 | \begin{example} 318 | \def\0{\frac\phi2} 319 | \[ \bra {\0} \quad \bra* {\0} 320 | \quad \bra[Big] {\0} \] 321 | \[ \ket {\0} \quad \ket* {\0} 322 | \quad \ket[Big] {\0} \] 323 | \end{example} 324 | The \cs{braket} command, in default, can take two arguments. 325 | \begin{example} 326 | \def\0{\frac\phi2} 327 | \[ \braket {\0} {\psi} \quad 328 | \braket*{\0} {\psi} \quad 329 | \braket[big] {\0} {\psi} \] 330 | \end{example} 331 | If you want \cs{braket} to take one or three arguments, you can write the 332 | number of arguments in the square bracket. If you need to specify the size 333 | of bra-ket simultaneously, you need to separate the number and the size with 334 | a comma: 335 | \begin{example} 336 | \def\0{\frac\phi2} 337 | \[ \braket [1] {\0} \quad 338 | \braket*[1] {\0} \] 339 | \[ \braket [3] {\0}{A}{\psi} \] 340 | \[ \braket[3,big] {\0}{A}{\psi} 341 | \quad 342 | \braket[Big,3] {\0}{A}{\psi} \] 343 | \end{example} 344 | The \cs{ketbra} command takes two mandatory arguments. It can also take an 345 | optional argument between the two mandatory arguments. The optional argument 346 | will be placed between $\rangle$ and $\langle$: 347 | \begin{example} 348 | \def\0{\frac\phi2} 349 | \[ \ketbra {\0} {\psi} \quad 350 | \ketbra* {\0} {\psi} \] 351 | \[ \ketbra [Bigg] {\0} {\psi} \] 352 | \[ \ketbra {\0} [_x^y] {\psi} \] 353 | \end{example} 354 | \endgroup 355 | 356 | \subsection{The \modu{diagmat} module --- simple diagonal matrices} 357 | This module provides \cs{diagmat} command: 358 | \begin{center} 359 | \cs{diagmat}\opt{[empty\:=\:}\meta{empty entry}\opt{]}\marg{diag} 360 | \end{center} 361 | where \meta{diag} is the diagonal of the diagonal matrix. The entries should 362 | be separated by commas. The \opt{empty} option is optional, with default value 363 | \opt{0}. For example, 364 | \begin{example} 365 | \[ 366 | \diagmat { 1, \sqrt2, \sqrt[3]4 } 367 | \] 368 | \end{example} 369 | \cs{pdiagmat}, \cs{bdiagmat}, \cs{Bdiagmat}, \cs{vdiagmat} and \cs{Vdiagmat} 370 | are also available. Prefixes like \opt{p}, \opt{b}, \opt{B} have the same 371 | meaning as the \opt{p}, \opt{b}, \opt{B} in \pkg{amsmath}'s \opt{pmatrix}, 372 | \opt{bmatrix} and \opt{Bmatrix}. For example, 373 | \begin{example} 374 | \[ 375 | \pdiagmat [ empty = {} ] 376 | { a, b, c, d } 377 | \] 378 | \end{example} 379 | This module requires \pkg{amsmath}. 380 | 381 | \paragraph{The options of \modu{diagmat} module} 382 | You can set the default value of \cs{diagmat}'s empty entries in the module 383 | option like this: 384 | \begin{Verbatim} 385 | \usephysicsmodule[empty={\cdot}]{diagmat} 386 | \end{Verbatim} 387 | 388 | \subsection{The \modu{doubleprod} module --- tensors' double product operator} 389 | Take an example of this module: 390 | \begin{example} 391 | $ A \doublecross B \doubledot C $ 392 | \end{example} 393 | \cs{doublecross} and \cs{doubledot} are regarded as binary operators by \TeX. 394 | 395 | \paragraph{The options of \modu{doubleprod} module} 396 | You can control the scale of ``$\times$'' and ``$\cdot$'' in \cs{doublecross} 397 | and \cs{doubledot} in module option. For example, 398 | \begin{Verbatim} 399 | \usephysicsmodule[crossscale=0.75,dotscale=1.2]{doubleprod} 400 | \end{Verbatim} 401 | The default values of \opt{crossscale} and \opt{dotscale} are \opt{0.8} and 402 | \opt{1}. You can also control the distances between the two ``$\times$''s and 403 | ``$\cdot$''s through the \opt{crossopenup} and \opt{dotopenup} options. 404 | For example, 405 | \begin{Verbatim} 406 | \usephysicsmodule[crossopenup=.05,dotopenup=.25]{doubleprod} 407 | \end{Verbatim} 408 | The default values of \opt{crossopenup} and \opt{dotopenup} are \opt{0.02} 409 | and \opt{0.2}. The value stands for the multiple of current font size. 410 | Moreover, you can change the symbols produced by \cs{doublecross} and 411 | \cs{doubledot} by setting \opt{crosssymbol} and \opt{dotsymbol} in module 412 | option. 413 | 414 | \subsection{The \modu{xmat} module --- matrices with formatted entries} 415 | The \modu{xmat} module provides \cs{xmat} command for matrices with formatted 416 | entries: 417 | \begin{center} 418 | \cs{xmat}\oarg{options}\marg{entry}\marg{rows shown}\marg{cols shown} 419 | \end{center} 420 | If \meta{rows shown} and \meta{cols shown} are digits, the value of them 421 | must be less at least 2 than the value of \pkg{amsmath}'s \opt{MaxMatrixCols} 422 | counter. For example, 423 | \begin{example} 424 | \[ 425 | \xmat{a}{2}{3} 426 | \] 427 | \end{example} 428 | \cs{pxmat}, \cs{bxmat}, \cs{Bxmat}, \cs{vxmat} and \cs{Vxmat} are also 429 | available. The meaning of \opt{p} and so on is the same as the \opt{p} 430 | in \opt{pmatrix} of \pkg{amsmath}. For example, 431 | \begin{example} 432 | \[ 433 | \pxmat{M}{3}{3} 434 | \] 435 | \end{example} 436 | If \meta{rows shown} and \meta{cols shown} contain non-digit characters, 437 | extra dots will be added. For example, 438 | \begin{example} 439 | \[ 440 | \bxmat[showleft=3,showtop=2] 441 | {X}{m}{n} 442 | \] 443 | \end{example} 444 | In this example we used the \opt{showleft} and \opt{showtop} options. The 445 | default value of them is the value of \opt{MaxMatrixCols} minus 2. You can 446 | also set them in the module option like this: 447 | \begin{Verbatim} 448 | \usephysicsmodule[showtop=3,showleft=3]{xmat} 449 | \end{Verbatim} 450 | Then every \cs{xmat} with non-digital \meta{rows shown} and \meta{cols shown} 451 | will have 2 top-most rows and 3 left-most columns shown. This will also 452 | influence ``\cs{xmat}''s with digital \meta{rows shown} and \meta{cols shown} 453 | when \meta{rows shown} and \meta{cols shown} are larger than the values 454 | corresponding to \opt{showtop} and \opt{showleft}. For example, 455 | \begin{example} 456 | % \usephysicsmodule 457 | % [showtop=3,showleft=3]{xmat} 458 | \[ \pxmat{A}{8}{8} \] 459 | \end{example} 460 | However, when \meta{rows shown} and \meta{cols shown} are 1 greater than 461 | \meta{showtop} and \meta{showleft}, for example, \meta{rows shown}$\:=4$ and 462 | \meta{cols shown}$\:=4$ in last example's settings, \cs{xmat} will still add 463 | the extra dots: 464 | \begin{example} 465 | % \usephysicsmodule 466 | % [showtop=3,showleft=3]{xmat} 467 | \[ \pxmat{A}{4}{4} \] 468 | \end{example} 469 | In such situations, we need to specify \opt{showtop} and \opt{showleft} 470 | manually. For example, 471 | \begin{example} 472 | % \usephysicsmodule 473 | % [showtop=3,showleft=3]{xmat} 474 | \[ \pxmat[showtop=4,showleft=4] 475 | {A}{4}{4} \] 476 | \end{example} 477 | 478 | The \cs{xmat} command provides the \opt{format} option, which allows users 479 | to use a new entry format. For example, 480 | \begin{example} 481 | \[ 482 | \xmat [showleft=2,showtop=2, 483 | format=\texttt{#1[#2][#3]}] 484 | {x}{m}{n} 485 | \] 486 | \end{example} 487 | In the value of \opt{format} key, \verb|#1| stands for the common entry, 488 | or the first mandatory \meta{entry} argument of \cs{xmat}; \verb|#2| 489 | stands for the row index and \verb|#3| stands for the column index. 490 | 491 | This module requires \pkg{amsmath}. 492 | 493 | \paragraph{The options of \modu{xmat} module} 494 | Only \opt{showtop} and \opt{showleft} can be used as module options. 495 | \opt{format} should be only used in the optional argument of the 496 | \cs{xmat} command. 497 | 498 | \section{The ``legacy'' modules} 499 | The legacy modules have similar names like \meta{module}\opt{.legacy}. Most of 500 | them are designed to provide solutions to maintain documents written with the 501 | legacy \pkg{physics} package. It's not suggested to use them in a new document. 502 | 503 | \subsection{The \modu{ab.legacy} module} 504 | This module provides the following commands: 505 | \begin{Verbatim}[fontsize=\small] 506 | \abs \norm \eval (\peval \beval) \order 507 | \end{Verbatim} 508 | They share the same syntax as \meta{cmd}\opt{*}\oarg{biggg}\marg{subformula}. 509 | Star and \meta{biggg} are optional. Star stands for ``use the default size''. 510 | For example, 511 | \begin{example} 512 | \def\0{1+\frac12} 513 | \[ \abs{\0} \quad 514 | \norm[Big]{\0} \quad 515 | \order*{\0} \] 516 | \end{example} 517 | \begin{example} 518 | \def\0{1+\frac12x} 519 | \[ \eval{\0}_a^b \quad 520 | \peval*{\0}_a^b \quad 521 | \beval[big]{\0}_a^b \] 522 | \end{example} 523 | You can set the ``order'' symbol in this module through 524 | the \opt{order} option like this: 525 | \begin{Verbatim} 526 | \usephysicsmodule[order=O]{ab.legacy} 527 | \end{Verbatim} 528 | For further information of this module, see \S\ref*{lega-subsec:ab-and-legacy} 529 | of \hyperref{./physics2-legacy.pdf}{}{}{physics2-legacy}. 530 | 531 | \subsection{The \modu{bm-um.legacy} module} 532 | If you are maintaining a document with plenty of ``\cs{bm}''s or 533 | ``\cs{boldsymbol}''s in it but want to use \pkg{unicode-math} package 534 | simultaneously, you could take a look at this module. 535 | 536 | The \cs{bm} command from \pkg{bm} package uses \cs{mathversion} to support 537 | its function, but there are few OpenType math fonts who released with a bold 538 | version. The \modu{bm-um.legacy} module provides a \cs{bm} command too, but 539 | this \cs{bm} can only take \emph{one} math character or a series of math 540 | characters sharing the same category code as its argument. 541 | If the argument was Latin letters or Greek letters, \cs{bm} would switch to 542 | the bold italic glyphs corresponding to them (if there exists bold italic 543 | glyphs); else \cs{bm} would switch to the bold upright glyphs. For example, 544 | \begin{example} 545 | $\bm{0}\bm{A}\bm{z} 546 | \bm{\alpha}\bm{\Omega}$ 547 | \end{example} 548 | 549 | \subsection{The \modu{nabla.legacy} module} 550 | This module provides some commands related to nabla ($\nabla$). Notice that 551 | this module requires the \pkg{fixdif} package with file date 2023/01/31 at 552 | minimum. 553 | 554 | This module defines \cs{grad} and \cs{curl} and redefines \cs{div}. For example, 555 | \begin{example} 556 | \[ \grad V \] 557 | \[ \div (x,y,z) \] 558 | \[ \curl(x,y,z) \] 559 | \end{example} 560 | The ``$\divsymbol$'' symbol was redefined as \cs{divsymbol}. 561 | 562 | \subsection{The \modu{op.legacy} module} 563 | This module provides a series of commands for log-like operators. They are 564 | \begin{Verbatim} 565 | \asin \acos \atan 566 | \acsc \asec \acot 567 | \Tr \tr \rank 568 | \erf \Res \res 569 | \PV \pv 570 | \Re \Im 571 | \end{Verbatim} 572 | where \cs{Re} and \cs{Im} are redefined. The first four lines of commands 573 | yield what they look like in math mode. For example, 574 | \begin{example} 575 | $\asin x$ \quad $\rank A$ 576 | \end{example} 577 | \cs{PV} yields ``$\PV$'' as an ordinary symbol and \cs{pv} yields ``$\pv$''. 578 | For example, 579 | \begin{example} 580 | $\PV f(z)$ \quad $\pv f(z)$ 581 | \end{example} 582 | \cs{Re} and \cs{Im} are redefined as ``$\Re$'' and ``$\Im$''. $\Resymbol$ 583 | and $\Imsymbol$ are redefined as \cs{Resymbol} and \cs{Imsymbol}, in default. 584 | 585 | This module \emph{does not} require \pkg{amsmath}. 586 | 587 | \paragraph{The options of \modu{op.legacy} module} 588 | \opt{ReIm}, a bool key with default value \opt{true}, determines whether to 589 | redefine \cs{Re} and \cs{Im}. If you want to reserve the definition of 590 | \cs{Re} and \cs{Im}, you can write like this: 591 | \begin{Verbatim} 592 | \usephysicsmodule[ReIm=false]{op.legacy} 593 | \end{Verbatim} 594 | 595 | \subsection{The \modu{qtext.legacy} module} 596 | This module was written just to offer a method to maintain documents written 597 | with the legacy \pkg{physics} package. See \S\ref*{lega-subsec:qtext} of 598 | \href{./physics2-legacy.pdf}{\texttt{texdoc physics2-legacy}} for 599 | more information. 600 | 601 | \end{document} --------------------------------------------------------------------------------