| 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} |