-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathphysics2-code.dtx
263 lines (235 loc) · 8.98 KB
/
physics2-code.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
% \iffalse meta-comment
%
% Copyright (C) 2022-2024 by Zhang Tingxuan <[email protected]>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any later
% version. The latest version of this license is in:
%
% http://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Zhang Tingxuan.
%
% This work consists of the files physics2-code.dtx,
% physics2-code.src.<collection>.dtx,
% and the derived files physics2.ins,
% physics2.sty,
% phy-<module>.sty,
% physics2-code.pdf,
% and README.md.
%
%<*internal>
\iffalse
%</internal>
%
%<*readme>
# The `physics2` package
This package defines commands for typesetting math formulae faster and
more simply. `physics2` is a modularized package, each module provides its
own function while `physics2.sty` itself only provides very few functions.
Therefore you can load modules separately after loading `physics2`.
## Functions
Modules of `physics2` provide the following supports:
- Automatic-sized braces;
- Dirac bra-ket notation;
- Easy way to typeset diagonal matrices and matrices with similar entries;
- Double cross and double dot (binary) operators for tensors;
- Most of the legacy functions provided by `physics.sty`.
## Build
Run
```
./build.sh
```
## For developers and deep users
If you want to contribute to this repo, you can
- pull requests [here](https://github.com/AlphaZTX/physics2/pulls);
- report bugs or request enhancement [here](https://github.com/AlphaZTX/physics2/issues).
Enhancement may not get applied quickly.
## License
This work may be distributed and/or modified under the conditions of the
[LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
either version 1.3c of this license or (at your option) any later version.
This work has the LPPL maintenance status `maintained`.
The Current Maintainer of this work is
[Zhang Tingxuan](https://www.ctan.org/author/zhang-tx).
%</readme>
%
%<*internal>
\fi
\begingroup
\def\NameOfLaTeXe{LaTeX2e}
\expandafter\endgroup\ifx\NameOfLaTeXe\fmtname\else
\csname fi\endcsname
%</internal>
%
%<*install>
\input docstrip.tex
\keepsilent
\preamble
Copyright (C) 2022-2024 by Zhang Tingxuan <[email protected]>
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3c of this license or (at your option) any later
version. The latest version of this license is in:
http://www.latex-project.org/lppl.txt
and version 1.3 or later is part of all distributions of
LaTeX version 2005/12/01 or later.
This work has the LPPL maintenance status `maintained'.
The Current Maintainer of this work is Zhang Tingxuan.
This work consists of the files physics2-code.dtx,
physics2-code.src.<collection>.dtx,
and the derived files physics2.ins,
physics2.sty,
phy-<module>.sty,
physics2-code.pdf,
and README.md.
\endpreamble
\generate{
\usedir{tex/latex/physics2}
\file{physics2.sty} {\from{physics2-code.src.base.dtx}{package}}
\file{phy-ab.sty} {\from{physics2-code.src.ab.dtx}{ab}}
\file{phy-xab.sty} {\from{physics2-code.src.ab.dtx}{xab}}
\file{phy-ab.legacy.sty} {\from{physics2-code.src.ab.dtx}{ab.legacy}}
\file{phy-ab.braket.sty} {\from{physics2-code.src.braket.dtx}{ab.braket}}
\file{phy-braket.sty} {\from{physics2-code.src.braket.dtx}{braket}}
\file{phy-xmat.sty} {\from{physics2-code.src.matrix.dtx}{xmat}}
\file{phy-diagmat.sty} {\from{physics2-code.src.matrix.dtx}{diagmat}}
\file{phy-doubleprod.sty} {\from{physics2-code.src.operator.dtx}{doubleprod}}
\file{phy-difop.sty} {\from{physics2-code.src.operator.dtx}{difop}}
\file{phy-nabla.legacy.sty} {\from{physics2-code.src.operator.dtx}{nabla.legacy}}
\file{phy-op.legacy.sty} {\from{physics2-code.src.operator.dtx}{op.legacy}}
\file{phy-bm-um.legacy.sty} {\from{physics2-code.src.misc.dtx}{bm-um.legacy}}
\file{phy-qtext.legacy.sty} {\from{physics2-code.src.misc.dtx}{qtext.legacy}}
\file{phy-helper.sty} {\from{physics2-code.src.helper.dtx}{helper}}
%</install>
%<*internal>
\usedir{source/latex/physics2}
\file{physics2.ins} {\from{physics2-code.dtx}{install}}
%</internal>
%<*install>
\usedir{doc/latex/physics2}
\nopreamble\nopostamble
\file{README.md} {\from{physics2-code.dtx}{readme}}
}
\obeyspaces
\Msg{**********************************************************}
\Msg{* *}
\Msg{* To finish the installation you have to move the *}
\Msg{* following files into a directory searched by TeX: *}
\Msg{* *}
\Msg{* physics2.sty, *}
\Msg{* (for all modules) phy-<module>.sty. *}
\Msg{* *}
\Msg{* The recommended directory is *}
\Msg{* TEXMFDIST/tex/latex/physics2 *}
\Msg{* *}
\Msg{* To produce the documentation, run the file *}
\Msg{* physics2-code.dtx through XeLaTeX or LuaLaTeX. *}
\Msg{* XeLaTeX is recommended. *}
\Msg{* *}
\Msg{* Happy TeXing! *}
\Msg{* *}
\Msg{**********************************************************}
\endbatchfile
%</install>
%
%<*internal>
\fi
%</internal>
%
%<*driver>
\ProvidesFile{physics2-code.dtx}[2024/01/22 (c) Copyright 2022-2024 by Zhang Tingxuan]
\documentclass{l3doc}
\usepackage{doc}
\hypersetup{hidelinks}
\usepackage{color}
\definecolor{pkgcolor}{RGB}{0,120,80}
\definecolor{moducolor}{RGB}{0,0,150}
\definecolor{gray}{rgb}{.5,.5,.5}
\DeclareRobustCommand\pkg[1]{\texorpdfstring{\textcolor{pkgcolor}{\textsf{#1}}}{“#1”}}
\DeclareRobustCommand\modu[1]{\texorpdfstring{\textcolor{moducolor}{\textsf{#1}}}{“#1”}}
\DeclareRobustCommand\note{\textbf{Note:} }
\usepackage{amsmath}
\usepackage{fontspec}
\setmonofont{Latin Modern Mono Light}
\usepackage{fancyvrb}
\fvset{gobble=2,xleftmargin=2em}
\makeatletter
\@addtoreset{CodelineNo}{section}
\def\DeclareSourceFile#1{%
\markright{Source file: \texttt{physics2-code.src.#1.dtx}}%
\part{physics2-code.src.#1.dtx}%
\markright{Source file: \texttt{physics2-code.src.#1.dtx}}%
}
\def\ps@phy{%
\def\@oddfoot{\rightmark\hfil\thepage}%
\let\@oddhead\relax%
\let\@mkboth\markboth
}
\newbox\@tempboxb
\DeclareDocumentCommand\macrodef{O{4em}O{.6}mo+m}{\leavevmode
\ensuremath{%
\setbox\@tempboxa\hbox to #1 {\hss\cs{#3}}%
\setbox\@tempboxb\vbox{\hsize=#2\textwidth
\textwidth=\hsize
\leftskip=\z@
\parindent=\z@
\textbf{begindef}\IfValueT{#4}{ \textcolor{gray}{(#4)}}\par
\begingroup\leftskip2em\parindent-1em#5\par\endgroup
\textbf{enddef}%
}%
\dp\@tempboxb=\dimexpr\ht\@tempboxb-\ht\@tempboxa\relax
\ht\@tempboxb=\ht\@tempboxa
\box\@tempboxa\leftarrow\box\@tempboxb
}}
\protected\long\def\macroifelse#1#2#3{\par
\textbf{if} #1 \textbf{then}\par
\begingroup\advance\leftskip1em#2\par\endgroup
\textbf{else}\par
\begingroup\advance\leftskip1em#3\par\endgroup
\textbf{endif}\par
}
\protected\long\def\macroif#1#2{\par
\textbf{if} #1 \textbf{then}\par
\begingroup\advance\leftskip1em#2\par\endgroup
\textbf{endif}\par
}
\protected\def\macrocr{\par}
\newdimen\ttwd
\protected\def\updatettwd{%
\setbox\@tempboxa\hbox{\normalsize\ttfamily a}
\ttwd=\wd\@tempboxa
}
\updatettwd
\makeatother
\title{Code documentation to the \pkg{physics2} package}
\author{Zhang Tingxuan}
\date{2024/12/10 v2.0.0}
\begin{document}
\maketitle
\begin{abstract}
This document gives notes to the source code of the \pkg{physics2} package
and all modules released together with \pkg{physics2}. The rule for naming
source files is \texttt{physics2-code.src.\meta{collection}.dtx}, where one
collection can contain more than one modules that share similar topics. The
collection name of the \pkg{physics2} package itself is ``base''.
\end{abstract}
\tableofcontents\newpage
\pagestyle{phy}
\DocInput{physics2-code.src.base.dtx}
\DocInput{physics2-code.src.ab.dtx}
\DocInput{physics2-code.src.braket.dtx}
\DocInput{physics2-code.src.matrix.dtx}
\DocInput{physics2-code.src.operator.dtx}
\DocInput{physics2-code.src.misc.dtx}
\DocInput{physics2-code.src.helper.dtx}
\end{document}
%</driver>
% \fi
%