Debian Codegraph @

texmf-dist/source/latex/math-operator/math-operator-code.dtx

raw
1 % \iffalse ---!!! FIRST META-COMMENT !!!---
2 %
3 %
4 % This file is operator-code.dtx from version 1.3a
5 % of the free and open-source LaTeX package "math-operator,"
6 % released September 2025.
7 %
8 % Running Plain TeX on math-operator-code.dtx will
9 % produce the following files:
10 %
11 % (1) the package file math-operator.sty;
12 %
13 % (2) the derived files math-operator_heading.tex
14 % and math-operator-user-guide.tex, which are
15 % used for typesetting documentation;
16 %
17 % and
18 %
19 % (3) a number of other derived files.
20 %
21 % Running LaTeX on math-operator-code.dtx will produce the
22 % files listed above as well as the following:
23 %
24 % (4) the pdf documentation file math-operator-code.pdf;
25 %
26 % and
27 %
28 % (5) a number of other derived files.
29 %
30 % To install operator on your computer, run this file
31 % through Plain TeX or LaTeX and move math-operator.sty
32 % to a directory searchable by TeX. See the associated
33 % README.txt file for installation information.
34 %
35 %
36 % \fi
37 % \iffalse ---!!! SECOND META-COMMENT !!!---
38 %
39 %
40 % This file is from version 1.3a of the free and open-source
41 % LaTeX package "math-operator," released September 2025.
42 %
43 % Copyright 2025 Conrad Kosowsky
44 %
45 % This file may be used, distributed, and modified under the
46 % terms of the LaTeX Public Project License, version 1.3c or
47 % any later version. The most recent version of this license
48 % is available online at
49 %
50 % https://www.latex-project.org/lppl/
51 %
52 % This Work has the LPPL status "maintained," and the current
53 % maintainer is the package author, Conrad Kosowsky. He can
54 % be reached at [email protected]. The Work consists
55 % of the following items:
56 %
57 % (1) the base file:
58 % math-operator-code.dtx
59 %
60 % (2) the package file:
61 % math-operator.sty
62 %
63 % (3) the pdf documentation files:
64 % math-operator-code.pdf
65 % math-operator-user-guide.pdf
66 %
67 % (4) the derived files:
68 % math-operator-user-guide.tex
69 % math-operator-heading.tex
70 %
71 % (5) all other files created by using LaTeX
72 % to produce the pdf files in point (3)
73 % above
74 %
75 % and
76 %
77 % (6) the associated README.txt file
78 %
79 % PLEASE KNOW THAT THIS FREE SOFTWARE IS PROVIDED WITHOUT
80 % ANY WARRANTY. SPECIFICALLY, THE "NO WARRANTY" SECTION OF
81 % THE LATEX PROJECT PUBLIC LICENSE STATES THE FOLLOWING:
82 %
83 % THERE IS NO WARRANTY FOR THE WORK. EXCEPT WHEN OTHERWISE
84 % STATED IN WRITING, THE COPYRIGHT HOLDER PROVIDES THE WORK
85 % `AS IS’, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
86 % OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
87 % WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
88 % PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
89 % OF THE WORK IS WITH YOU. SHOULD THE WORK PROVE DEFECTIVE,
90 % YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
91 % CORRECTION.
92 %
93 % IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED
94 % TO IN WRITING WILL THE COPYRIGHT HOLDER, OR ANY AUTHOR
95 % NAMED IN THE COMPONENTS OF THE WORK, OR ANY OTHER PARTY
96 % WHO MAY DISTRIBUTE AND/OR MODIFY THE WORK AS PERMITTED
97 % ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
98 % SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT
99 % OF ANY USE OF THE WORK OR OUT OF INABILITY TO USE THE WORK
100 % (INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA, DATA BEING
101 % RENDERED INACCURATE, OR LOSSES SUSTAINED BY ANYONE AS A
102 % RESULT OF ANY FAILURE OF THE WORK TO OPERATE WITH ANY
103 % OTHER PROGRAMS), EVEN IF THE COPYRIGHT HOLDER OR SAID
104 % AUTHOR OR SAID OTHER PARTY HAS BEEN ADVISED OF THE
105 % POSSIBILITY OF SUCH DAMAGES.
106 %
107 % For more information, see the LaTeX Project Public License.
108 % Derivative works based on this software may come with their
109 % own license or terms of use, and the package author is not
110 % responsible for any third-party software.
111 %
112 % Happy TeXing!
113 %
114 %
115 % \fi
116 % \iffalse
117 %
118 % The installation and driver files are incorporated into
119 % math-operator-code.dtx, so we do not need to generate them
120 % separately. The <batchfile> and <driver> tags are for
121 % reference.
122 %
123 %<*batchfile>
124 \begingroup
125 \input docstrip.tex
126 \keepsilent
127 \askforoverwritefalse
128 \preamble
129
130 This file is from version 1.3a of the free and open-source
131 LaTeX package "math-operator," released September 2025.
132
133 Copyright 2025 Conrad Kosowsky
134
135 This file may be used, distributed, and modified under the
136 terms of the LaTeX Public Project License, version 1.3c or
137 any later version. The most recent version of this license
138 is available online at
139
140 https://www.latex-project.org/lppl/
141
142 This work has the LPPL status "maintained," and the current
143 maintainer is the package author, Conrad Kosowsky. He can
144 be reached at [email protected].
145
146 PLEASE KNOW THAT THIS FREE SOFTWARE IS PROVIDED WITHOUT
147 ANY WARRANTY. SPECIFICALLY, THE "NO WARRANTY" SECTION OF
148 THE LATEX PROJECT PUBLIC LICENSE STATES THE FOLLOWING:
149
150 THERE IS NO WARRANTY FOR THE WORK. EXCEPT WHEN OTHERWISE
151 STATED IN WRITING, THE COPYRIGHT HOLDER PROVIDES THE WORK
152 `AS IS’, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
153 OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
154 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
155 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
156 OF THE WORK IS WITH YOU. SHOULD THE WORK PROVE DEFECTIVE,
157 YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
158 CORRECTION.
159
160 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED
161 TO IN WRITING WILL THE COPYRIGHT HOLDER, OR ANY AUTHOR
162 NAMED IN THE COMPONENTS OF THE WORK, OR ANY OTHER PARTY
163 WHO MAY DISTRIBUTE AND/OR MODIFY THE WORK AS PERMITTED
164 ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
165 SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT
166 OF ANY USE OF THE WORK OR OUT OF INABILITY TO USE THE WORK
167 (INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA, DATA BEING
168 RENDERED INACCURATE, OR LOSSES SUSTAINED BY ANYONE AS A
169 RESULT OF ANY FAILURE OF THE WORK TO OPERATE WITH ANY
170 OTHER PROGRAMS), EVEN IF THE COPYRIGHT HOLDER OR SAID
171 AUTHOR OR SAID OTHER PARTY HAS BEEN ADVISED OF THE
172 POSSIBILITY OF SUCH DAMAGES.
173
174 For more information, see the LaTeX Project Public License.
175 Derivative works based on this software may come with their
176 own license or terms of use, and the package author is not
177 responsible for any third-party software.
178
179 Happy TeXing!
180
181 \endpreamble
182 \generate{\file{math-operator.sty}{\from{math-operator-code.dtx}{code}}
183 \file{math-operator-user-guide.tex}{\from{math-operator-code.dtx}{user}}
184 \file{math-operator-heading.tex}{\from{math-operator-code.dtx}{heading}}}
185 \catcode`\ =12\relax
186 \immediate\write0{^^J%
187 ******************************************************^^J%
188 * Step 1 of the math-operator installation complete! *^^J%
189 ******************************************************^^J^^J%
190 ******************************************************^^J%
191 * To finish the installation, move math-operator.sty *^^J%
192 * to a directory searchable by TeX after *^^J%
193 * after math-operator-code.dtx is done typesetting *^^J%
194 ******************************************************^^J}
195 \endgroup
196 \ifx\LaTeX\undefined
197 \immediate\write0{Plain TeX format used; quitting now.}
198 \immediate\write0{To create math-operator-code.pdf, run^^J%
199 math-operator-code.dtx through LaTeX.^^J^^J}
200 \expandafter\end
201 \fi
202 %</batchfile>
203 %<*driver>
204 \makeatletter
205 \documentclass[12pt,letterpaper,doc2,twoside]{ltxdoc}
206 \edef\MacroFont{\unexpanded\expandafter{\MacroFont}%
207 \baselineskip=\the\baselineskip plus 0.4pt minus 0.4pt}
208 \usepackage[margin=1in]{geometry}
209 \usepackage[factor=700,stretch=14,step=1]{microtype}
210 \usepackage{enumitem}
211 \setlist{topsep=\smallskipamount,itemsep=\smallskipamount,
212 parsep=\z@,partopsep=\z@,beginpenalty=0,midpenalty=0,
213 endpenalty=0}
214 \c@IndexColumns=2
215 \c@topnumber\@ne
216 \columnsep=20pt
217 \MacroIndent=16pt
218 \let\index@prologue\relax
219 \EnableCrossrefs\CodelineIndex
220 \begin{document}
221 \baselineskip=\the\baselineskip plus 0.4pt minus 0.4pt
222 \flushbottom
223 \def\documentname{Implementation}
224 \input math-operator-heading.tex
225 \c@CodelineNo=59\relax
226 \DocInput{math-operator-code.dtx}
227 \vfil\eject
228
229 \immediate\closeout\@indexfile
230 \ifx\directlua\@undefined
231 \immediate\write18{makeindex -s gind.ist math-operator-code.idx}
232 \else
233 \directlua{os.execute("makeindex -s gind.ist math-operator-code.idx")}
234 \fi
235
236 \section*{Index}
237
238 \input math-operator-code.ind
239
240 \end{document}
241 %</driver>
242 %<*code>
243 % \fi
244 %
245 % \CheckSum{1633}
246 % \init@checksum
247 %
248 % \makeatother\CharacterTable
249 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
250 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
251 % Digits \0\1\2\3\4\5\6\7\8\9
252 % Exclamation \! Double quote \" Hash (number) \#
253 % Dollar \$ Percent \% Ampersand \&
254 % Acute accent \' Left paren \( Right paren \)
255 % Asterisk \* Plus \+ Comma \,
256 % Minus \- Point \. Solidus \/
257 % Colon \: Semicolon \; Less than \<
258 % Equals \= Greater than \> Question mark \?
259 % Commercial at \@ Left bracket \[ Backslash \\
260 % Right bracket \] Circumflex \^ Underscore \_
261 % Grave accent \` Left brace \{ Vertical bar \|
262 % Right brace \} Tilde \~}
263 % \makeatletter
264 %
265 %
266 % \DoNotIndex{\-,\@firstoftwo,\@gobble,\@ifoperator,\@ifstar,
267 % \@namedef\@nameuse,\@ne,\@nil,\@nnil,\@operator@bbfalse,
268 % \@operator@bbtrue,\@operator@cfalse,\@operator@ctrue,
269 % \@operator@jfalse,\@operator@jtrue,\advance,\ifx,\else,\fi,
270 % \@operator@lfalse,\@operator@ltrue,\@operatorinfo,
271 % \@operator@pfalse,\@operator@ptrue,\limits,\nolimits,
272 % \@operator@sfalse,\@operator@strue,\number,\operator@font,
273 % \@operator@sffalse,\@operator@sftrue,\or,\ProvidesPackage,
274 % \@operator@tfalse,\@operator@ttrue,\@undefined,
275 % \@tempa,\@tempcnta,\@tempcntb,\@tempswatrue,\@tempswafalse,
276 % \begingroup,\endgroup,\bfdefault,\count@,\csname,\endcsname,
277 % \ifcat,\noexpand,\relax,\expandafter,\edef,\f@encoding,
278 % \f@family,\f@shape,\fam,\def,\gdef,\detokenize,\divide,\hbox,
279 % \hexnumber@,\if@operator@bb,\if@operator@c,\if@operator@j,
280 % \if@operator@l,\if@operator@p,\if@operator@s,\if@operator@sf,
281 % \if@operator@t,\if@tempswa,\ifcase,\ifin@,\ifmmode,
282 % \ifnum,\in@,\ifin@,\let,\m@ne,\mathbb,\mathchar,\mathop,
283 % \MessageBreak,\mathchoice,\multiply,\NeedsTeXFormat,\newcount,
284 % \newif,\noexpand,\relax,\space,\split@name,\string,\Umathchar,
285 % \wlog,\xdef,\z@,\the,\DeclareFixedFont,\@secondoftwo,
286 % \@namedef,\PackageError,\PackageWarning,\global,\ProcessOptions,
287 % \DeclareOption,\escapechar,\kern,\@onlypreamble,\DeclareMathText,
288 % \DeclareBoldMathOperator,\DeclareBoldMathText,\DeclareMathOperator,
289 % \@ifnextchar,\@operator@ofalse,\@operator@otrue,\if@operator@o,
290 % \@tempboxa,\@tempdima,\@tempdimb,\@tempdimc,
291 % \setbox,\unhbox,\hskip,\ht,\wd,\dp,\hfil,\mathrm,\mathbf,\vrule,
292 % \mathchardef,\mathchar,\Umathchardef,\Uchar,\@bfop@false,\@bfop@true,
293 % \if@bfop@,\iffontchar,\@undefined,\@operator@robust@def,
294 % \@operator@robust@gdef,\DeclareRobustCommand,\dimen@}
295 %
296 %
297 %
298 % \noindent This file documents the code for the \textsf{math-operator} package. It is not a user guide! If you are looking for instructions on how to typeset math operators in your equations, please see |math-operator-user-guide.pdf|, which is included with the \textsf{math-operator} installation and is available on \textsc{ctan}. The first three sections of this file deal with package setup and the commands to define new operators, and the remaining sections document the operators defined in this package. Section~4 covers several blackboard-bold letters, and Section~5 discusses categories. Section~6 deals with Jacobi elliptic functions, and Section~7 defines matrix groups and linear algebra operations. Section~8 defines the command to produce an overline. Section~9 defines a number of common probability distributions. Section~10 deals with special functions, and Section~11 covers other standard operators. Finally, Section~12 defines trigonometric functions. Version history and code index appear at the end of the document.
299 %
300 %
301 %
302 %
303 % \section{Setup}
304 %
305 % \noindent We begin with package declaration. The first 59 lines of |operator.sty| are comments.
306 % \begin{macrocode}
307 \NeedsTeXFormat{LaTeX2e}
308 \ProvidesPackage{math-operator}[2025/09/10 v. 1.3a]
309 % \end{macrocode}
310 % Create booleans that we'll use for option processing. One boolean per category of operator.
311 % \begin{macrocode}
312 \newif\if@operator@bb % blackboard bold
313 \newif\if@operator@c % category theory
314 \newif\if@operator@j % Jacobi elliptic functions
315 \newif\if@operator@l % linear algebra
316 \newif\if@operator@o % overlining
317 \newif\if@operator@p % probability distributions
318 \newif\if@operator@sf % special functions
319 \newif\if@operator@s % standard operators
320 \newif\if@operator@t % trigonometry
321 % \end{macrocode}
322 % Set all options to true by default.
323 % \begin{macrocode}
324 \@operator@bbtrue
325 \@operator@ctrue
326 \@operator@jtrue
327 \@operator@ltrue
328 \@operator@otrue
329 \@operator@ptrue
330 \@operator@sftrue
331 \@operator@strue
332 \@operator@ttrue
333 % \end{macrocode}
334 % Now declare and process options.
335 % \begin{macrocode}
336 \DeclareOption{blackboard}{\@operator@bbtrue}
337 \DeclareOption{category}{\@operator@ctrue}
338 \DeclareOption{jacobi}{\@operator@jtrue}
339 \DeclareOption{linear}{\@operator@ltrue}
340 \DeclareOption{overbar}{\@operator@otrue}
341 \DeclareOption{probability}{\@operator@ptrue}
342 \DeclareOption{special}{\@operator@sftrue}
343 \DeclareOption{standard}{\@operator@strue}
344 \DeclareOption{trigonometry}{\@operator@ttrue}
345 % \end{macrocode}
346 % The |no-| options prevent the package from defining certain operators.
347 % \begin{macrocode}
348 \DeclareOption{no-blackboard}{\@operator@bbfalse}
349 \DeclareOption{no-category}{\@operator@cfalse}
350 \DeclareOption{no-jacobi}{\@operator@jfalse}
351 \DeclareOption{no-linear}{\@operator@lfalse}
352 \DeclareOption{no-overbar}{\@operator@ofalse}
353 \DeclareOption{no-probability}{\@operator@pfalse}
354 \DeclareOption{no-special}{\@operator@sffalse}
355 \DeclareOption{no-standard}{\@operator@sfalse}
356 \DeclareOption{no-trigonometry}{\@operator@tfalse}
357 \ProcessOptions*
358 % \end{macrocode}
359 % A couple bookkeeping things. The count |\operatordefmode| determines the package behavior when the user calls one of the declaration commands on a control sequence that is already defined (and not an operator). When |\operatordefmode| is negative, the package overwrites the definition. Otherwise, the package behaves as follows:
360 % \begin{itemize}
361 % \item 0: Silently ignore (message written on the |log| file)
362 % \item 1 (default): issue a warning
363 % \item 2 or greater: issue an error message
364 % \end{itemize}
365 % We implement this behavior later in |\make@newop@cmd|.
366 % \begin{macrocode}
367 \def\@operatorinfo#1{\wlog{Package operator Info: #1}}
368 \newcount\operatordefmode
369 \operatordefmode\@ne
370 % \end{macrocode}
371 % Boolean that is false in general and true whenever we are typesetting a bold operator.
372 % \begin{macrocode}
373 \newif\if@bfop@
374 \@bfop@false
375 % \end{macrocode}
376 % Commands to define protected macros. We check whether |\protected| is defined to avoid dependence on $\varepsilon$-\TeX\ in the unlikely chance that someone is using \LaTeX\ without $\varepsilon$-\TeX.
377 % \begin{macrocode}
378 \ifx\protected\@undefined
379 \let\@operator@robust@def\DeclareRobustCommand
380 \def\@operator@robust@gdef#1{%
381 \bgroup
382 \escapechar\m@ne
383 \xdef#1{\noexpand\protect
384 \expandafter\noexpand\csname\string#1 \endcsname}%
385 \expandafter
386 \egroup
387 \expandafter\gdef\csname\string#1 \endcsname}
388 \else
389 \def\@operator@robust@def{\protected\def}
390 \def\@operator@robust@gdef{\protected\gdef}
391 \fi
392 % \end{macrocode}
393 %
394 %
395 % \section{Extra User-Level Commands}
396 %
397 % Some math operators contain characters other than letters, and we define control sequences to access three expressions from the operator font:
398 % \begin{itemize}
399 % \item |\@operatorhyphen| typesets a hyphen in the |\fam|
400 % \item |\@operatortw@| typesets 2 in the |\fam|
401 % \item |\@operatorm@ne| typesets $-1$ possibly in the |\fam|
402 % \end{itemize}
403 % Later in this section, we define user-level wrappers around these control sequences, and the user-level commands for squared and inverse operators format the expression as a superscript. I am assuming that the operator font contains the appropriate glyphs in the encoding slots for hyphen, |1|, and |2|, so we can define |\@operatorhyphen| and |\@operatortw@| as |\mathalpha| characters using |\mathchardef| or |\Umathchardef|. For the case where |\Umathchar| is undefined, we have to convert encoding slots for the hyphen an two numbers into hexadecimal. We use the same approach as |\set@mathchar| from the \LaTeX\ kernel. First is the math-mode hyphen.
404 % \begin{macrocode}
405 \def\defaultinverse{-1}
406 \ifx\Umathchar\@undefined
407 \begingroup
408 \@tempcntb=\number`\-\relax
409 \count@\@tempcntb
410 \divide\count@ by 16\relax
411 \@tempcnta\count@
412 \multiply\count@ by 16\relax
413 \advance\@tempcntb by -\count@
414 \global\mathchardef\@operatorhyphen
415 "70\hexnumber@\@tempcnta\hexnumber@\@tempcntb\relax
416 % \end{macrocode}
417 % Next is 2.
418 % \begin{macrocode}
419 \@tempcntb=\number`2\relax
420 \count@\@tempcntb
421 \divide\count@ by 16\relax
422 \@tempcnta\count@
423 \multiply\count@ by 16\relax
424 \advance\@tempcntb by -\count@
425 \global\mathchardef\@operatortw@
426 "70\hexnumber@\@tempcnta\hexnumber@\@tempcntb\relax
427 \endgroup
428 % \end{macrocode}
429 % For the inverse symbol, we just use |\defaultinverse|.
430 % \begin{macrocode}
431 \def\@operatorm@ne{\begingroup\fam\m@ne\defaultinverse\endgroup}
432 % \end{macrocode}
433 % Things are simpler when we have access to Unicode.
434 % \begin{macrocode}
435 \else
436 \Umathchardef\@operatorhyphen=+7+0+`\-\relax
437 \Umathchardef\@operatortw@=+7+0+`2\relax
438 % \end{macrocode}
439 % The minus sign is tricky because it may change its location depending on the encoding. For $-1$, we first check if the |\fam| contains a glyph in slot |"2212|. If yes, we typeset $-1$ in the operator font, and if not, we forget about the operator font entirely and typeset |\defaultinverse| (which is $-1$ by default) with $|\fam|=-1$.
440 % \begin{macrocode}
441 \def\@operatorm@ne{%
442 \ifnum\fam>\m@ne
443 \mathchoice{%
444 \iffontchar\textfont\fam"2212\relax
445 \Umathchar+0+\fam"2212\relax % minus sign
446 \Umathchar+0+\fam "31\relax % 1
447 \else
448 \begingroup\fam\m@ne\defaultinverse\endgroup
449 \fi}%
450 {\iffontchar\textfont\fam"2212\relax
451 \Umathchar+0+\fam"2212\relax % minus sign
452 \Umathchar+0+\fam "31\relax % 1
453 \else
454 \begingroup\fam\m@ne\defaultinverse\endgroup
455 \fi}%
456 {\iffontchar\scriptfont\fam"2212\relax
457 \Umathchar+0+\fam"2212\relax % minus sign
458 \Umathchar+0+\fam "31\relax % 1
459 \else
460 \begingroup\fam\m@ne\defaultinverse\endgroup
461 \fi}%
462 {\iffontchar\scriptscriptfont\fam"2212\relax
463 \Umathchar+0+\fam"2212\relax % minus sign
464 \Umathchar+0+\fam "31\relax % 1
465 \else
466 \begingroup\fam\m@ne\defaultinverse\endgroup
467 \fi}%
468 \else
469 \defaultinverse
470 \fi}
471 \fi
472 % \end{macrocode}
473 % Now provide user-level access to those three control sequences. Each command has a starred version, which typesets the characters in bold if possible. The default, unstarred version can appear anywhere in an equation. The general idea behind both starred and unstarred versions is to first check whether |\if@bfop@| is true and then fill in values accordingly. When |\if@bfop@| is true, we can type a hyphen directly, and otherwise, we use |\@bfop@choices| or |\@operatorhyphen| depending on whether we want bold or medium weight.
474 % \begin{macrocode}
475 \@operator@robust@def\operatorhyphen{\@ifstar
476 \@operatorhyphen@bf\@operatorhyphen@@}
477 \def\@operatorhyphen@bf{%
478 \if@bfop@
479 -%
480 \else
481 \mathchoice{}{}{}{}
482 {\@init@bfopfont\@bfop@choices{-}}
483 \fi}
484 \def\@operatorhyphen@@{%
485 \if@bfop@
486 -%
487 \else
488 {\operator@font\@operatorhyphen}
489 \fi}
490 % \end{macrocode}
491 % Same thing for the power of 2. When |\if@bfop@| is true, we use a |\textsuperscript|, and when it is false, we expect to be in \textsc m mode and can use |^| directly.
492 % \begin{macrocode}
493 \@operator@robust@def\operatorsquared{\@ifstar
494 \@operatorsquared@bf\@operatorsquared@@}
495 \def\@operatorsquared@bf{%
496 \if@bfop@
497 \textsuperscript{2}%
498 \else
499 ^{\@init@bfopfont\@bfop@choices{2}}
500 \fi}
501 \def\@operatorsquared@@{%
502 \if@bfop@
503 \textsuperscript{2}%
504 \else
505 ^{\operator@font\@operatortw@}
506 \fi}
507 % \end{macrocode}
508 % And inverse operation. This control sequence is once again more complicated because of the issue with the minus sign. As in |\operatorsquared|, we use |\textsuperscript| and type out the $-1$ directly when |\if@bfop@| is true, and if that boolean is false, we use |^| and |\@bfop@choices| or |\@operatorm@ne|. Unlike with |\operatorsquared|, typing out $-1$ is involves checks to determine whether the font contains a minus sign in slot |"2212|. If yes, we type $-1$ with |\Uchar|, and if not, we use |\defaultinverse|.
509 % \begin{macrocode}
510 \@operator@robust@def\operatorinverse{\@ifstar
511 \@operatorinverse@bf\@operatorinverse@@}
512 \def\@operatorinverse@bf{%
513 \if@bfop@
514 \textsuperscript{%
515 \ifx\Uchar\@undefined
516 $\defaultinverse$%
517 \else
518 \iffontchar\font"2212\relax
519 \Uchar"2212\relax 1%
520 \else
521 $\defaultinverse$%
522 \fi
523 \fi}%
524 \else
525 ^{\@init@bfopfont\@bfop@choices{%
526 \ifx\Uchar\@undefined
527 $\defaultinverse$%
528 \else
529 \iffontchar\font"2212\relax
530 \Uchar"2212\relax 1%
531 \else
532 $\defaultinverse$%
533 \fi
534 \fi}}
535 \fi}
536 \def\@operatorinverse@@{%
537 \if@bfop@
538 \textsuperscript{%
539 \ifx\Uchar\@undefined
540 $\defaultinverse$%
541 \else
542 \iffontchar\font"2212\relax
543 \Uchar"2212\relax 1%
544 \else
545 $\defaultinverse$%
546 \fi
547 \fi}%
548 \else
549 ^{\operator@font\@operatorm@ne}
550 \fi}
551 % \end{macrocode}
552 % Finally, we make a new name for pilcrow symbol because \textsf{math-operator} may overwrite |\P|.
553 % \begin{macrocode}
554 \@operator@robust@def\pilcrow{\ifmmode
555 \textparagraph\else\mathparagraph\fi}
556 % \end{macrocode}
557 %
558 % \section{Defining New Operators}
559 %
560 %
561 % We begin with the user-level operator declarations. Each of these commands expects the |#1| argument to be a single control sequence, and the |#2| argument should be the text of the operator. These macros all serve as wrappers around |\make@newop@cmd|, which does the work of defining the operator and expects two arguments. The first argument is the |#1| control sequence, and the second argument is code that defines |#1| as some expression involving |#2|. (We execute this code inside |\make@newop@cmd| if |#1| is a valid operator name.) In the first user-level command here, the control sequence should expand to |{\operator@font|\meta{text}|}|, which simply typesets |#2| in the operator font. More complicated cases use different definitions.
562 % \begin{macrocode}
563 \ifx\protected\@undefined
564 \def\@tempa{\DeclareRobustCommand\DeclareMathText[2]}
565 \else
566 \def\@tempa{\protected\def\DeclareMathText##1##2}
567 \fi
568 \@tempa{\make@newop@cmd{#1}
569 {\@operator@robust@def#1{{\operator@font #2}}}}
570 % \end{macrocode}
571 % Bold is more complicated for reasons discussed later in this section. The definition of |#1| in this case has three parts. First, the |\mathchoice| ensures that we are in math mode without adding anything to the current math formula. Then |\@init@bfopfont| sets up the bold operator font, and |\@bfop@choices| typesets |#2| in boldface.
572 % \begin{macrocode}
573 \ifx\protected\@undefined
574 \def\@tempa{\DeclareRobustCommand\DeclareBoldMathText[2]}
575 \else
576 \def\@tempa{\protected\def\DeclareBoldMathText##1##2}
577 \fi
578 \@tempa{\make@newop@cmd{#1}
579 {\@operator@robust@def#1{\mathchoice{}{}{}{}\@init@bfopfont
580 {\@bfop@choices{#2}}}}}
581 % \end{macrocode}
582 % For the two commands that make a proper operator, i.e.\ a |\mathop| subformula, we allow for a starred version. A star means the operator is typeset with |\limits|, so any superscripts or subscripts will be directly above or below the operator. No star (the default version) means the operator is typeset with |\nolimits|, and any superscripts and subscripts will appear normally.
583 % \begin{macrocode}
584 \@operator@robust@def\DeclareMathOperator{\relax\@ifstar
585 \@operatorlim\@operatornolim}
586 % \end{macrocode}
587 % Operator with bold text.
588 % \begin{macrocode}
589 \@operator@robust@def\DeclareBoldMathOperator{\relax\@ifstar
590 \@bfoperatorlim\@bfoperatornolim}
591 % \end{macrocode}
592 % Next are the four commands that actually call |\make@newop@cmd| inside the previous two control sequences. They are analogous to |\DeclareMathText| and |\DeclareBoldMathText| above, except now we specify |\mathop|. We include an empty |\kern| to ensure that the subformula contains more than a single character, and this forces the baseline of the operator to line up with the rest of the equation. If \TeX\ encounters an expression like |\mathop{|\meta{single char}|}|, it will vertically center the \meta{single char} in the middle of the equation because it thinks you're typesetting something like an integral or summation sign.
593 % \begin{macrocode}
594 \def\@operatorlim#1#2{%
595 \make@newop@cmd{#1}
596 {\@operator@robust@def#1{\mathop{\operator@font\kern\z@#2}\limits}}}
597 % \end{macrocode}
598 % Same thing with |\nolimits|.
599 % \begin{macrocode}
600 \def\@operatornolim#1#2{%
601 \make@newop@cmd{#1}
602 {\@operator@robust@def#1{\mathop{\operator@font\kern\z@#2}\nolimits}}}
603 % \end{macrocode}
604 % The bold operator works the same way as |\DeclareBoldMathText|: ensure we're in math mode (and raise an error if not), then call |\@init@bfopfont| and |\@bfop@choices| to typeset the operator.
605 % \begin{macrocode}
606 \def\@bfoperatorlim#1#2{%
607 \make@newop@cmd{#1}
608 {\@operator@robust@def#1{\mathchoice{}{}{}{}\@init@bfopfont
609 \mathop{\@bfop@choices{#2}}\limits}}}
610 % \end{macrocode}
611 % Same thing with |\nolimits|.
612 % \begin{macrocode}
613 \def\@bfoperatornolim#1#2{%
614 \make@newop@cmd{#1}
615 {\@operator@robust@def#1{\mathchoice{}{}{}{}\@init@bfopfont
616 \mathop{\@bfop@choices{#2}}\nolimits}}}
617 % \end{macrocode}
618 % We store the list of control sequences that code for operators in |\operator@list|. Initially the macro contains the operator control sequences from the \LaTeX\ kernel.
619 % \begin{macrocode}
620 \def\operator@list{\log\lg\ln
621 \lim\limsup\liminf
622 \sin\arcsin\sinh
623 \cos\arccos\cosh
624 \tan\arctan\tanh
625 \cot\coth
626 \sec\csc
627 \max\min\sup\inf
628 \arg\ker\dim\hom\det
629 \exp
630 \Pr
631 \gcd\deg}
632 % \end{macrocode}
633 % Command to add to the list of operators.
634 % \begin{macrocode}
635 \def\addto@operator@list#1{\expandafter
636 \def\expandafter\operator@list\expandafter{\operator@list#1}}
637 % \end{macrocode}
638 % The macro |\@ifoperator| accepts a single control sequence and checks whether it appears in |\operator@list|.
639 % \begin{macrocode}
640 \def\@ifoperator#1{%
641 \expandafter\in@\expandafter#1\expandafter{\operator@list}%
642 \ifin@
643 \expandafter\@firstoftwo
644 \else
645 \expandafter\@secondoftwo
646 \fi}
647 % \end{macrocode}
648 % Error and warning messages for |\make@newop@cmd|.
649 % \begin{macrocode}
650 \def\OperatorBadNameError#1{%
651 \def\@tempa{#1}%
652 \@onelevel@sanitize\@tempa
653 \PackageError{math-operator}{Invalid name\MessageBreak
654 "\@tempa" for new operator}
655 {I was expecting the name of the new operator\MessageBreak
656 to be a single control sequence, but instead\MessageBreak
657 you typed "\@tempa."\MessageBreak
658 This doesn't work. To resolve this error,\MessageBreak
659 make sure the first argument of the operator\MessageBreak
660 declaration is a single control sequence.\MessageBreak}}
661 \def\OperatorCSDefWarning#1{%
662 \PackageWarning{math-operator}{Control sequence\MessageBreak
663 \string#1\space is already defined. Your\MessageBreak
664 operator declaration was\MessageBreak ignored}}
665 \def\OperatorCSDefError#1{%
666 \PackageError{math-operator}{Control sequence\MessageBreak
667 \string#1\space already defined. Your\MessageBreak
668 operator declaration was ignored}
669 {You tried to define the control sequence\MessageBreak
670 \string#1\space to be a new\MessageBreak
671 operator even though it already has a\MessageBreak
672 definition. I'm currently set to raise an\MessageBreak
673 error when that happens. To resolve the\MessageBreak
674 error, either pick a different control\MessageBreak
675 sequence or set \string\operatordefmode\space to a \MessageBreak
676 negative number to overwrite the definition.\MessageBreak}}
677 % \end{macrocode}
678 % The |\make@newop@cmd| macro does the work of defining the new operator. It accepts two arguments: |#1| a control sequence and |#2| a statement defining |#1| to be something. The previous user-level |\Declare|\meta{stuff} macros provide the appropriate definitions, so we include |#2| by itself in two places. The main job of |\make@newop@cmd| is to check whether |#1| is a single control sequence and not already defined as something besides an operator.
679 % \begin{macrocode}
680 \def\make@newop@cmd#1#2{%
681 \expandafter\ifx\expandafter\@nnil\@gobble#1\@nnil % is #1 one token?
682 \ifcat\relax\noexpand#1 % does #1 start with cs?
683 % \end{macrocode}
684 % If |#1| is already an operator, we can redefine it no problem.
685 % \begin{macrocode}
686 \@ifoperator{#1}
687 {\@operatorinfo{Redefining \string#1\space operator.}
688 #2} % <-- new definition happens here
689 % \end{macrocode}
690 % If not, we first check whether |#1| is undefined. If yes, we define it and add it to |\operator@list|.
691 % \begin{macrocode}
692 {\ifx#1\@undefined
693 \@operatorinfo{Defining new operator \string#1.}
694 \addto@operator@list{#1}
695 #2 % <-- new definition happens here
696 % \end{macrocode}
697 % Otherwise, we consult the value of |\operatordefmode|. When this count is negative, we redefine the control sequence and turn it into an operator.
698 % \begin{macrocode}
699 \else % if #1 is already defined...
700 \ifnum\operatordefmode<\z@ % case < 0: redefine
701 \@operatorinfo{Overwriting definition of \string#1.}
702 \addto@operator@list{#1}
703 #2 % <-- new definition happens here
704 % \end{macrocode}
705 % If |\operatordefmode| is nonnegative, we do not redefine |#1| and instead do nothing, issue a warning, or issue an error depending on the count value.
706 % \begin{macrocode}
707 \else
708 \@operatorinfo{Leaving \string#1\space as is.}
709 \ifcase\operatordefmode % case 0: do nothing
710 \or % case 1: warning
711 \OperatorCSDefWarning{#1}
712 \else % case >= 2: error
713 \OperatorCSDefError{#1}
714 \fi
715 \fi
716 \fi}
717 \else
718 \OperatorBadNameError{#1}
719 \fi
720 \else
721 \OperatorBadNameError{#1}
722 \fi}
723 % \end{macrocode}
724 % Bold text in math mode is complicated because \LaTeX\ doesn't provide direct access to a bold version of the operator font. My solution is to extract the operator font information from the \textsf{nfss} and then use that font family in boldface inside an |\hbox|. Doing so is an effective way to ensure that we are typesetting bold text, as opposed to bold math, in the operator font family. The other option would be to change the |\fam|, either with |\mathbf| or with a direct call to |\fam|, but that approach has two main drawbacks. First, |\mathbf| is intended to produce bold variable names, such as vectors in physics, not necessarily bold text, and the same may be true of other bold symbol fonts. In traditional \LaTeX, |\mathbf| does produce a bolded version of the operator font, but that may not be true in general. Second, it may not be obvious whether the \textsc{nfss} has even declared a bold version of the operator font as a symbol font, and I do not want to hack the \textsc{nfss} to determine this when we have an easier and more reliable alternative.
725 %
726 % To implement this approach, we need three |\font| commands (which we call |\@bfoptf|, |\@bfopsf|, and |\@bfopssf|) that switch to the bold operator font in \textsc h mode at different sizes: one size for |\textstyle| and |\displaystyle|, one size for |\scriptstyle|, and one size for |\scriptscriptstyle|. We implicitly assume that the operator font family does not change after |\begin{document}| (but it can change in the preamble), but the user may freely enlarge or shrink the text. For these three |\font| commands, we store their sizes in |\operator@tf|, |\operator@sf|, and |\operator@ssf|, and if these macros do not match the size of the current |\textfont|, |\scriptfont|, or |\scriptscriptfont| respectively, we redefine all three |\font| commands at the correct size. The idea here is that we make new |\font| commands if the surrounding text size has changed since the user's most recent bold operator. Finally, we pick the right size in the current equation by putting the operator text inside |\mathchoice|.
727 % \begin{macrocode}
728 \let\operator@tf\relax
729 \let\operator@sf\relax
730 \let\operator@ssf\relax
731 % \end{macrocode}
732 % The macro |\@init@bfopfont| (re)defines the font-change commands. We start by checking whether the sizes of |\@bfoptf|, |\@bfopsf|, and |\@bfopssf| match |\tf@size|, |\sf@size|, and |\ssf@size|. If yes, this command does nothing, and if not, we need to redefine the three |\font| commands to have the correct font size.
733 % \begin{macrocode}
734 \def\@init@bfopfont{%
735 \@tempswatrue % reset sizes by default
736 \ifx\operator@tf\tf@size
737 \ifx\operator@sf\sf@size
738 \ifx\operator@ssf\ssf@size
739 \@tempswafalse % don't reset sizes if unnecessary
740 \fi
741 \fi
742 \fi
743 % \end{macrocode}
744 % If we do need to change the font size, we switch to the operator font inside a group and get rid of the |\escapechar|, then do fun things.
745 % \begin{macrocode}
746 \if@tempswa
747 \begingroup
748 \operator@font
749 \escapechar\m@ne
750 % \end{macrocode}
751 % The macro |\set@bf@@| accepts three arguments. The |##1| argument should is a control sequence, the |##2| argument is |\textfont|, |\scriptfont|, or |\scriptscriptfont|, and the |##3| argument is a font size (a number). This is the command that finds the operator font in the \textsc{nfss} and and converts it to bold, and it defines |##1| to be the |\font| command that produces this font.
752 % \begin{macrocode}
753 \def\set@bf@@##1##2##3{%
754 \edef\@tempa{\expandafter\string\the##2\fam}
755 \expandafter\split@name\@tempa\@nil
756 \DeclareFixedFont##1\f@encoding\f@family\bfdefault\f@shape##3}
757 % \end{macrocode}
758 % Here is where we actually make the font-change commands. We call our ``text font'' |\@bfoptf|, our ``script font'' |\@bfopsf|, and our ``script script font'' |\@bfopssf|.
759 % \begin{macrocode}
760 \set@bf@@\@bfoptf\textfont\tf@size
761 \set@bf@@\@bfopsf\scriptfont\sf@size
762 \set@bf@@\@bfopssf\scriptscriptfont\ssf@size
763 % \end{macrocode}
764 % Now save the sizes of the current font-change commands for the next bold operator.
765 % \begin{macrocode}
766 \global\let\operator@tf\tf@size
767 \global\let\operator@sf\sf@size
768 \global\let\operator@ssf\ssf@size
769 \endgroup
770 \fi}
771 % \end{macrocode}
772 % The |\@bfop@choices| macro accepts a single argument, which should be the text of an operator to be typeset in bold. The |#1| argument goes inside an |\hbox| with a font-change command that depends on the current math style. To keep things working properly in the \textsc{nfss}, we also update the internal macros that store the font information. The macro |\operator@update@font| calls |\split@name| on the current |\font|. We need to set the |\escapechar| to $-1$ because |\split@name| does not expect the leading backslash from the current |\font|.
773 % \begin{macrocode}
774 \def\operator@update@font{\begingroup
775 \escapechar\m@ne
776 \expandafter\expandafter\expandafter
777 \endgroup
778 \expandafter\expandafter\expandafter
779 \split@name\expandafter\string\the\font\@nil}
780 % \end{macrocode}
781 % Now define |\@bfop@choices|. We initially set |\if@bfop@| to true. We don't have to reset it because |\@bfop@choices| always appears in a group, so this change is necessarily local.
782 % \begin{macrocode}
783 \def\@bfop@choices#1{\@bfop@true
784 \mathchoice{\hbox{\@bfoptf\operator@update@font#1}}
785 {\hbox{\@bfoptf\operator@update@font#1}}
786 {\hbox{\@bfopsf\operator@update@font#1}}
787 {\hbox{\@bfopssf\operator@update@font#1}}}
788 % \end{macrocode}
789 % Finally, we make the operator declaration commands preamble only. Is this necessary? Probably not, but operator declaration distinctly feels like something that should happen only in the preamble.
790 % \begin{macrocode}
791 \@onlypreamble\DeclareMathText
792 \@onlypreamble\DeclareBoldMathText
793 \@onlypreamble\DeclareMathOperator
794 \@onlypreamble\DeclareBoldMathOperator
795 \@onlypreamble\@operatorlim
796 \@onlypreamble\@operatornolim
797 \@onlypreamble\@bfoperatorlim
798 \@onlypreamble\@bfoperatornolim
799 \@onlypreamble\make@newop@cmd
800 % \end{macrocode}
801 %
802 %
803 %
804 % \section{Blackboard Bold}
805 %
806 % Make the blackboard-bold letters. This package isn't designed to load fonts, so we're implementing each \texttt{\textbackslash}\meta{letter} assuming the user has or will at some point request a package that defines |\mathbb|. We leave each blackboard-board letter undefined until the first time it appears in math mode. If |\mathbb| is still undefined at that point, \textsf{math-operator} raises a |\NoBBError|, and otherwise it defines \texttt{\textbackslash}\meta{letter} to be |\mathbb{|\meta{letter}|}|. For a traditional \LaTeX\ approach that implements |\mathbb| as a new math alphabet, i.e.\ by changing the font of certain letters without changing their encoding slots, it would arguably be better to find the math family that corresponds to |\mathbb| and use |\mathchardef|. However, modern Unicode-based implementations may also change the encoding slot to something from the Letterlike Symbols or Math Alphanumeric Symbols blocks by locally setting new |\Umathcode|'s for Latin letters. Without examining the underlying code, it's impossible to know which form of |\mathbb| we're looking at, so \textsf{math-operator} sticks to calling |\mathbb| for maximum compatibility with other packages. If a package defines |\mathbb| to do something besides switch to blackboard bold, that will break the control sequences here.
807 % \begin{macrocode}
808 \wlog{}
809 \if@operator@bb
810 \@operatorinfo{Defining blackboard-bold letters.}
811 \def\NoBBError#1{\PackageError{math-operator}
812 {Missing \string\mathbb\space command}
813 {It looks like you're trying to make\MessageBreak
814 a blackbold-board "#1." However, I\MessageBreak
815 can't define blackboard-bold letters\MessageBreak
816 because I don't see a definition for\MessageBreak
817 \string\mathbb, which is what I would use to\MessageBreak
818 do it. To resolve this error message,\MessageBreak
819 try loading a package that provides\MessageBreak
820 blackboard-bold font support such as\MessageBreak
821 amssymb or mathfont.\MessageBreak}}
822 % \end{macrocode}
823 % To keep the code simple, we use |\@makebbchar| for the actual definitions. Here |#1| is the letter we use.
824 % \begin{macrocode}
825 \def\@makebbchar#1{%
826 \@operatorinfo{Predefining
827 \expandafter\string\csname #1\endcsname\space
828 for use later.}
829 \expandafter\@operator@robust@def\csname #1\endcsname{%
830 \ifx\mathbb\@undefined
831 \NoBBError{#1}%
832 \else
833 \@operatorinfo{Setting up \expandafter
834 \string\csname#1\endcsname\space for use.}%
835 \expandafter\@operator@robust@gdef\csname #1\endcsname{\mathbb{#1}}%
836 \@nameuse{#1}%
837 \fi}}
838 \@makebbchar{N}
839 \@makebbchar{Z}
840 \@makebbchar{Q}
841 \@makebbchar{R}
842 \@makebbchar{C}
843 \@makebbchar{F}
844 % \end{macrocode}
845 % Defining |\H| and |\O| is more complicated because these commands already do something in text mode, and we want to preserve that definition. We take the usual approach of making them robust macros that expand differently in \textsc m mode versus \textsc h or \textsc v mode.
846 % \begin{macrocode}
847 \@operatorinfo{Predefining \string\H\space for use later.}
848 \@operatorinfo{Predefining \string\O\space for use later.}
849 \let\textH\H
850 \let\textO\O
851 \def\mathH{%
852 \ifx\mathbb\@undefined
853 \NoBBError{H}%
854 \else
855 \@operatorinfo{Setting up \string\H\space for use.}%
856 \gdef\mathH{\mathbb{H}}%
857 \mathH
858 \fi}
859 \def\mathO{%
860 \ifx\mathbb\@undefined
861 \NoBBError{O}%
862 \else
863 \@operatorinfo{Setting up \string\O\space for use.}%
864 \gdef\mathO{\mathbb{O}}%
865 \mathO
866 \fi}
867 \@operator@robust@def\O{\ifmmode\mathO\else\expandafter\textO\fi}
868 \@operator@robust@def\H{\ifmmode\mathH\else\expandafter\textH\fi}
869 % \end{macrocode}
870 % For probability and expected value operators, we take a slightly different approach because we want these characters to show up as operators rather than |\mathord| atoms. We use |\@makebbop|, which is similar to |\@makebbchar|, except that it includes a |\mathop| specification.
871 % \begin{macrocode}
872 \def\@makebbop#1{%
873 \@operatorinfo{Predefining
874 \expandafter\string\csname #1\endcsname\space
875 for use later.}
876 \expandafter\@operator@robust@def\csname#1\endcsname{%
877 \ifx\mathbb\@undefined
878 \NoBBError{#1}%
879 \else
880 \@operatorinfo{Setting up \expandafter
881 \string\csname#1\endcsname\space for use.}%
882 \expandafter\@operator@robust@gdef\csname#1\endcsname{%
883 \mathop{\kern\z@\mathbb{#1}}}%
884 \@nameuse{#1}%
885 \fi}}
886 \@makebbop{E}
887 \@makebbop{P}
888 % \end{macrocode}
889 % And add all these letters to |\operator@list|.
890 % \begin{macrocode}
891 \addto@operator@list{\N\Z\Q\R\C\F\mathO\mathH\E\P}
892 \else
893 \@operatorinfo{Skipping blackboard-bold letters.}
894 \fi
895 % \end{macrocode}
896 %
897 % \section{Categories}
898 %
899 % A selection of categories. Serious category theorists will undoubtedly want to declare their own categories beyond these.
900 % \begin{macrocode}
901 \if@operator@c
902 \wlog{}
903 \@operatorinfo{Defining category theory notation.}
904 \DeclareBoldMathText{\Ab}{Ab}
905 \DeclareBoldMathText{\Alg}{Alg}
906 \DeclareBoldMathText{\Bialg}{Bialg}
907 \DeclareBoldMathText{\Cat}{Cat}
908 \DeclareBoldMathText{\CGH}{CGH}
909 \DeclareBoldMathText{\CGWH}{CGWH}
910 \DeclareBoldMathText{\Coalg}{Coalg}
911 \DeclareBoldMathText{\Comod}{Comod}
912 \DeclareBoldMathText{\CRing}{CRing}
913 \DeclareBoldMathText{\Field}{Field}
914 \DeclareBoldMathText{\FinGrp}{FinGrp}
915 \DeclareBoldMathText{\FinHilb}{FinHilb}
916 \DeclareBoldMathText{\FinVect}{FinVect}
917 \DeclareBoldMathText{\FinSet}{FinSet}
918 \DeclareBoldMathText{\Frm}{Frm}
919 \DeclareBoldMathText{\Grp}{Grp}
920 \DeclareBoldMathText{\Haus}{Haus}
921 \DeclareBoldMathText{\HeytAlg}{HeytAlg}
922 \DeclareBoldMathText{\Hilb}{Hilb}
923 \DeclareBoldMathText{\HopfAlg}{HopfAlg}
924 \DeclareBoldMathText{\Lat}{Lat}
925 \DeclareBoldMathText{\LieAlg}{LieAlg}
926 \DeclareBoldMathText{\LieGrp}{LieGrp}
927 \DeclareBoldMathText{\Loc}{Loc}
928 \DeclareBoldMathText{\Man}{Man}
929 \DeclareBoldMathText{\Mat}{Mat}
930 \DeclareBoldMathText{\Met}{Met}
931 \DeclareBoldMathText{\Mod}{Mod}
932 \DeclareBoldMathText{\Mon}{Mon}
933 \DeclareBoldMathText{\Ord}{Ord}
934 \DeclareBoldMathText{\Pos}{Pos}
935 \DeclareBoldMathText{\Rel}{Rel}
936 \DeclareBoldMathText{\Ring}{Ring}
937 \DeclareBoldMathText{\Set}{Set}
938 \DeclareBoldMathText{\Top}{Top}
939 \DeclareBoldMathText{\Topos}{Topos}
940 \DeclareBoldMathText{\Vect}{Vect}
941 \DeclareMathOperator{\cocone}{cocone}
942 \DeclareMathOperator*{\colim}{colim}
943 \DeclareMathOperator{\cone}{cone}
944 \DeclareMathOperator{\Ho}{Ho}
945 \DeclareMathOperator{\Hom}{Hom}
946 \DeclareMathOperator{\Ob}{Ob}
947 \DeclareMathOperator{\PSh}{PSh}
948 \DeclareMathOperator{\Sh}{Sh}
949 \@operatorinfo{Defining new operator \string\op.}
950 \addto@operator@list{\op}
951 \@operator@robust@def\op{^{\operator@font op}}
952 \else
953 \@operatorinfo{Skipping category theory notation.}
954 \fi
955 % \end{macrocode}
956 %
957 %
958 % \section{Jacobi Elliptic Functions}
959 %
960 % Pretty straightforward. The standard classes define |\sc| as a legacy (deprecated) command to access small caps, and we overwrite that definition. I do not feel bad about overwriting deprecated commands.
961 % \begin{macrocode}
962 \if@operator@j
963 \wlog{}
964 \@operatorinfo{Defining Jacobi elliptic functions.}
965 \DeclareMathOperator{\cd}{cd}
966 \DeclareMathOperator{\cn}{cn}
967 \DeclareMathOperator{\cs}{cs}
968 \DeclareMathOperator{\dc}{dc}
969 \DeclareMathOperator{\dn}{dn}
970 \DeclareMathOperator{\ds}{ds}
971 \DeclareMathOperator{\nc}{nc}
972 \DeclareMathOperator{\nd}{nd}
973 \DeclareMathOperator{\ns}{ns}
974 \let\sc\@undefined
975 \DeclareMathOperator{\sc}{sc}
976 \DeclareMathOperator{\sd}{sd}
977 \DeclareMathOperator{\sn}{sn}
978 \else
979 \@operatorinfo{Skipping Jacobi elliptic functions.}
980 \fi
981 % \end{macrocode}
982 %
983 % \section{Linear Algebra}
984 %
985 % Some standard functions and operators from linear algebra. For the matrix groups defined here, we use |\DeclareMathText| rather than |\DeclareMathOperator| because these groups should be |\mathord| subformulas, not |\mathop|. We say |\spanop| instead of |\span| because |\span| is already defined. (It's a \TeX\ primitive dealing with tabular entries. Please do not redefine |\span|.)
986 % \begin{macrocode}
987 \if@operator@l
988 \wlog{}
989 \@operatorinfo{Defining operators from linear algebra.}
990 \DeclareMathOperator{\adj}{adj}
991 \DeclareMathOperator{\Cl}{Cl}
992 \DeclareMathOperator{\codim}{codim}
993 \DeclareMathOperator{\coker}{coker}
994 \DeclareMathText{\GL}{GL}
995 \DeclareMathOperator{\nullity}{nullity}
996 \DeclareMathText{\Orthogonal}{O}
997 \DeclareMathOperator{\Pin}{Pin}
998 \DeclareMathOperator{\proj}{proj}
999 \DeclareMathOperator{\rank}{rank}
1000 \DeclareMathText{\SL}{SL}
1001 \DeclareMathText{\SO}{SO}
1002 \DeclareMathText{\SU}{SU}
1003 \DeclareMathOperator{\Sp}{Sp}
1004 \DeclareMathOperator*{\spanop}{span}
1005 \DeclareMathOperator{\Spin}{Spin}
1006 \DeclareMathOperator{\tr}{tr}
1007 \@operatorinfo{Defining new operator \string\T.}
1008 \addto@operator@list{\T}
1009 \@operator@robust@def\T{^{\operator@font T}}
1010 \DeclareMathText{\Unitary}{U}
1011 \else
1012 \@operatorinfo{Skipping operators from linear algebra.}
1013 \fi
1014 % \end{macrocode}
1015 %
1016 %
1017 % \section{Overlining}
1018 %
1019 % In this section, we define the |\overbar| command, which produces an overline whose length lies somewhere between |\bar| and |\overline|. The user-level command is a short wrapper around the internal command |\@overb@r|. First, we define |\overbaroffset|, which will determine the placement of the overline over the argument of |\overbar|. As is standard in \TeX, we store |\overbaroffset| as a count, which we identify with a scale factor because we divide it by 1000 when we use its value in |\@overb@r|.
1020 % \begin{macrocode}
1021 \if@operator@o
1022 \wlog{}
1023 \@operatorinfo{Defining \string\overbar.}
1024 \newcount\overbaroffset
1025 \overbaroffset=800\relax
1026 % \end{macrocode}
1027 % Version 1.0 of this package called the count |\operatorbaroffset| instead of |\overbaroffset|. We provide access to the old name for backwards compatibility.
1028 % \begin{macrocode}
1029 \let\operatorbaroffset\overbaroffset
1030 % \end{macrocode}
1031 % Now for the user-level command. We start by checking whether we are in math mode. If the user follows |\overbar| with an asterisk, we use 500 as the placement value, and otherwise, we take the value of |\overbaroffset|. If the user does not specify an optional argument, we use the default value of 0.8.
1032 % \begin{macrocode}
1033 \@operator@robust@def\overbar{\mathchoice{}{}{}{}%
1034 \@ifstar
1035 {\@ifnextchar[%
1036 {\@overb@r{500}}
1037 {\@overb@r{500}[0.8]}}
1038 {\@ifnextchar[%
1039 {\@overb@r{\overbaroffset}}
1040 {\@overb@r{\overbaroffset}[0.8]}}}
1041 % \end{macrocode}
1042 % Now we come to the macro that does the actual work of making the overline. The command |\@overb@r| accepts three arguments: |#1| is the scale argument that determines the horizontal placement of the overline; |#2| is a decimal that determines the size of the overline; and |#3| is the subformula to be overlined. Note that |#1| is only specified internally, and the user controls |#1| indirectly through |\overbaroffset|. Just to be safe, we put the contents of |\@overb@r| inside a group since we're making liberal use of scratch registers. The general idea is that inside a |\mathchoice|, we put the subformula in an |\hbox| in the correct style and then manually position the overline using the box dimensions and the |#1| and |#2| arguments.
1043 % \begin{macrocode}
1044 \def\@overb@r#1[#2]#3{\begingroup
1045 \mathchoice
1046 {\setbox\@tempboxa\hbox{$\displaystyle#3\m@th$}
1047 \@tempdima\wd\@tempboxa
1048 \@tempdimb\ht\@tempboxa
1049 \@tempdimc\dp\@tempboxa
1050 % \end{macrocode}
1051 % We will use |\dimen@| to store the glue that we insert to the left of the |\overline| command. We start with the width of |\@tempboxa|, shrink by the width of the overbar, and then take a fraction of the remaining space based on |#1| (which is typically |\overbaroffset|). Then we subtract the width of |\@tempboxa| because we are inserting this glue right after |\unhbox|ing |\@tempboxa|.
1052 % \begin{macrocode}
1053 \dimen@\@tempdima
1054 \advance\dimen@ by -#2\@tempdima
1055 \divide\dimen@ by 1000
1056 \multiply\dimen@ by #1
1057 \advance\dimen@ by -\@tempdima
1058 % \end{macrocode}
1059 % Inside another |\hbox|, we typeset |\@tempboxa| and manually convert it into an |\rlap|. Then we add |\hskip|, the overline, and an |\hfil|. In total, this |\hbox| will have the same width as the original subformula. We do all of this inside a second |\hbox| because we want \TeX\ to treat everything as a single subformula and also to prevent extra interatom space in the unlikely event that |\Umathordordspacing| is nonzero. (Please do not set |\Umathordordspacing| to something nonzero.)
1060 % \begin{macrocode}
1061 \hbox to \@tempdima{\unhbox\@tempboxa\hskip\dimen@
1062 % \end{macrocode}
1063 % Now make a math expression that contains just an overline of the correct width above a zero-width |\vrule|, which ensures that the overline occurs at the correct height.
1064 % \begin{macrocode}
1065 $\overline{%
1066 \vrule width \z@ height \@tempdimb depth \@tempdimc
1067 \hskip#2\@tempdima}\m@th$%
1068 \hfil}}
1069 % \end{macrocode}
1070 % Same thing with |\textstyle|.
1071 % \begin{macrocode}
1072 {\setbox\@tempboxa\hbox{$\textstyle#3\m@th$}
1073 \@tempdima\wd\@tempboxa
1074 \@tempdimb\ht\@tempboxa
1075 \@tempdimc\dp\@tempboxa
1076 \dimen@\@tempdima
1077 \advance\dimen@ by -#2\@tempdima
1078 \divide\dimen@ by 1000
1079 \multiply\dimen@ by #1
1080 \advance\dimen@ by -\@tempdima
1081 \hbox to \@tempdima{\unhbox\@tempboxa\hskip\dimen@
1082 $\overline{%
1083 \vrule width \z@ height \@tempdimb depth \@tempdimc
1084 \hskip#2\@tempdima}\m@th$%
1085 \hfil}}
1086 % \end{macrocode}
1087 % And |\scriptstyle|.
1088 % \begin{macrocode}
1089 {\setbox\@tempboxa\hbox{$\scriptstyle#3\m@th$}
1090 \@tempdima\wd\@tempboxa
1091 \@tempdimb\ht\@tempboxa
1092 \@tempdimc\dp\@tempboxa
1093 \advance\dimen@ by -#2\@tempdima
1094 \divide\dimen@ by 1000
1095 \multiply\dimen@ by #1
1096 \advance\dimen@ by -\@tempdima
1097 \hbox to \@tempdima{\unhbox\@tempboxa\hskip\dimen@
1098 $\overline{%
1099 \vrule width \z@ height \@tempdimb depth \@tempdimc
1100 \hskip#2\@tempdima}\m@th$%
1101 \hfil}}
1102 % \end{macrocode}
1103 % And finally |\scriptscriptstyle|.
1104 % \begin{macrocode}
1105 {\setbox\@tempboxa\hbox{$\scriptscriptstyle#3\m@th$}
1106 \@tempdima\wd\@tempboxa
1107 \@tempdimb\ht\@tempboxa
1108 \@tempdimc\dp\@tempboxa
1109 \advance\dimen@ by -#2\@tempdima
1110 \divide\dimen@ by 1000
1111 \multiply\dimen@ by #1
1112 \advance\dimen@ by -\@tempdima
1113 \hbox to \@tempdima{\unhbox\@tempboxa\hskip\dimen@
1114 $\overline{%
1115 \vrule width \z@ height \@tempdimb depth \@tempdimc
1116 \hskip#2\@tempdima}\m@th$%
1117 \hfil}}
1118 \endgroup}
1119 \else
1120 \@operatorinfo{Skipping \string\overbar.}
1121 \fi
1122 % \end{macrocode}
1123 %
1124 %
1125 % \section{Probability Distributions}
1126 %
1127 % A selection of common probability distributions. We say |\Betaop| and |\Gammaop| instead of |\Beta| and |\Gamma| because they are or may be defined to be capital Greek letters.
1128 % \begin{macrocode}
1129 \if@operator@p
1130 \wlog{}
1131 \@operatorinfo{Defining probability distributions.}
1132 \DeclareMathOperator{\Bernoulli}{Bernoulli}
1133 \DeclareMathOperator{\Betaop}{Beta}
1134 \DeclareMathOperator{\Binomial}{Binomial}
1135 \DeclareMathOperator{\Boltzmann}{Boltzmann}
1136 \DeclareMathOperator{\Burr}{Burr}
1137 \DeclareMathOperator{\Categorical}{Categorical}
1138 \DeclareMathOperator{\Cauchy}{Cauchy}
1139 \DeclareMathOperator{\chiop}{\chi}
1140 \@operator@robust@def\ChiSq{\chiop^{\operator@font\@operatortw@}}
1141 \DeclareMathOperator{\Dagum}{Dagum}
1142 \DeclareMathOperator{\Exponential}{Exponential}
1143 \DeclareMathOperator{\Erlang}{Erlang}
1144 \DeclareMathOperator{\Gammaop}{Gamma}
1145 \DeclareMathOperator{\Gompertz}{Gompertz}
1146 \@operator@robust@def\InvChiSq{%
1147 \mathop{\operator@font
1148 Inv\@operatorhyphen\chiop}%
1149 \nolimits^{\operator@font\@operatortw@}}
1150 \DeclareMathOperator{\InvGamma}
1151 {Inv\@operatorhyphen Gamma}
1152 \DeclareMathOperator{\Kolmogorov}{Kolmogorov}
1153 \DeclareMathOperator{\LogLogistic}{Log\@operatorhyphen Logistic}
1154 \DeclareMathOperator{\LogNormal}{Log\@operatorhyphen Normal}
1155 \DeclareMathOperator{\Logistic}{Logistic}
1156 \DeclareMathOperator{\Lomax}{Lomax}
1157 \DeclareMathOperator{\MaxwellBoltzmann}
1158 {Maxwell\@operatorhyphen Boltzmann}
1159 \DeclareMathOperator{\Multinomial}{Multinomial}
1160 \DeclareMathOperator{\NegBinomial}{Neg\@operatorhyphen Binomial}
1161 % \end{macrocode}
1162 % We can't use |\N| for calligraphic $\mathcal N$ because we're already using it for natural numbers. Alas, we will settle for |\Normal|. This one is also more complicated because of the |*|-ed version of the command.
1163 % \begin{macrocode}
1164 \@operatorinfo{Defining new operator \string\Normal.}
1165 \addto@operator@list{\Normal}
1166 \def\operator@N{\mathop{\kern\z@\mathcal{N}}\nolimits}
1167 \def\operator@normal{\mathop{\operator@font Normal}\nolimits}
1168 \@operator@robust@def\Normal{%
1169 \mathchoice{}{}{}{}
1170 \@ifstar\operator@normal\operator@N}
1171 \DeclareMathOperator{\Pareto}{Pareto}
1172 \DeclareMathOperator{\Poisson}{Poisson}
1173 \DeclareMathOperator{\Weibull}{Weibull}
1174 \DeclareMathOperator{\Zipf}{Zipf}
1175 \else
1176 \@operatorinfo{Skipping probability distributions.}
1177 \fi
1178 % \end{macrocode}
1179 %
1180 %
1181 %
1182 % \section{Special Functions}
1183 %
1184 % Some common special functions.
1185 % \begin{macrocode}
1186 \if@operator@sf
1187 \wlog{}
1188 \@operatorinfo{Defining special functions.}
1189 \DeclareMathOperator{\Ai}{Ai}
1190 \DeclareMathOperator{\Bi}{Bi}
1191 \DeclareMathOperator{\Ci}{Ci}
1192 \DeclareMathOperator{\ci}{ci}
1193 \DeclareMathOperator{\Chiop}{Chi}
1194 \DeclareMathOperator{\Ei}{Ei}
1195 \DeclareMathOperator{\erf}{erf}
1196 \@operator@robust@def\erfinv{\erf^{\operator@font\@operatorm@ne}}
1197 \DeclareMathOperator{\erfc}{erfc}
1198 \@operator@robust@def\erfcinv{\erfc^{\operator@font\@operatorm@ne}}
1199 \DeclareMathOperator{\Li}{Li}
1200 \DeclareMathOperator{\li}{li}
1201 \DeclareMathOperator{\Log}{Log}
1202 \DeclareMathOperator{\sgn}{sgn}
1203 \DeclareMathOperator{\Si}{Si}
1204 \DeclareMathOperator{\si}{si}
1205 \DeclareMathOperator{\Shi}{Shi}
1206 % \end{macrocode}
1207 % Inverse error function.
1208 % \begin{macrocode}
1209 \else
1210 \@operatorinfo{Skipping special functions.}
1211 \fi
1212 % \end{macrocode}
1213 %
1214 % \section{Standard Operators}
1215 %
1216 % Some other standard (or standardish) functions and operations. Much more pure mathy than the special functions from the previous section. We say |\divop| instead of |\div| because |\div| is already defined.
1217 % \begin{macrocode}
1218 \if@operator@s
1219 \wlog{}
1220 \@operatorinfo{Defining standard operators.}
1221 \DeclareMathOperator*{\argmax}{arg\,max}
1222 \DeclareMathOperator*{\argmin}{arg\,min}
1223 \DeclareMathOperator{\Aut}{Aut}
1224 \@operatorinfo{Defining new operator \string\c.}
1225 \addto@operator@list{\mathc}
1226 \let\textc\c
1227 \def\mathc{^{\operator@font c}}
1228 \@operator@robust@def\c{\ifmmode\mathc\else\expandafter\textc\fi}
1229 \DeclareMathOperator{\cf}{cf}
1230 \DeclareMathOperator{\cl}{cl}
1231 \DeclareMathOperator{\conv}{conv}
1232 \DeclareMathOperator{\corr}{corr}
1233 \DeclareMathOperator{\cov}{cov}
1234 \DeclareMathOperator{\curl}{curl}
1235 \DeclareMathOperator{\divop}{div}
1236 \DeclareMathOperator{\Ext}{Ext}
1237 \DeclareMathOperator{\Gal}{Gal}
1238 \DeclareMathOperator{\grad}{grad}
1239 \DeclareMathOperator{\Hess}{\mathcal{H}}
1240 \DeclareMathOperator{\id}{id}
1241 \DeclareMathOperator{\img}{img}
1242 \DeclareMathOperator{\Info}{\mathcal{I}}
1243 \DeclareMathOperator{\interior}{int}
1244 \DeclareMathOperator*{\lcm}{lcm}
1245 \DeclareMathOperator{\Proj}{Proj}
1246 \DeclareMathOperator{\Res}{Res}
1247 \DeclareMathOperator{\Spec}{Spec}
1248 \DeclareMathOperator{\st}{st}
1249 \DeclareMathOperator{\supp}{supp}
1250 \DeclareMathOperator{\Tor}{Tor}
1251 \DeclareMathOperator{\Var}{Var}
1252 \addto@operator@list{\varIm\varRe\Im\Re}
1253 \@operatorinfo{Defining \string\varIm\space operator from \string\Im.}
1254 \@operatorinfo{Defining \string\varRe\space operator from \string\Re.}
1255 \let\varIm\Im
1256 \let\varRe\Re
1257 \DeclareMathOperator{\Im}{Im}
1258 \DeclareMathOperator{\Re}{Re}
1259 \else
1260 \@operatorinfo{Skipping standard operators.}
1261 \fi
1262 % \end{macrocode}
1263 %
1264 % \section{Trigonometry}
1265 %
1266 % Finally, time for some trigonometry. We start by defining hyperbolic cosecant and secant.
1267 % \begin{macrocode}
1268 \if@operator@t
1269 \wlog{}
1270 \@operatorinfo{Defining trigonometric functions.}
1271 \DeclareMathOperator{\csch}{csch}
1272 \DeclareMathOperator{\sech}{sech}
1273 % \end{macrocode}
1274 % Round out the ``arc'' versions of standard trigonometric functions, then provide ``arc'' and ``ar'' versions of hyperbolic trigonometric functions.
1275 % \begin{macrocode}
1276 \DeclareMathOperator{\arccsc}{arccsc}
1277 \DeclareMathOperator{\arcsec}{arcsec}
1278 \DeclareMathOperator{\arccot}{arccot}
1279 \DeclareMathOperator{\arcsinh}{arcsinh}
1280 \DeclareMathOperator{\arccosh}{arccosh}
1281 \DeclareMathOperator{\arctanh}{arctanh}
1282 \DeclareMathOperator{\arccsch}{arccsch}
1283 \DeclareMathOperator{\arcsech}{arcsech}
1284 \DeclareMathOperator{\arccoth}{arccoth}
1285 \DeclareMathOperator{\arsinh}{arsinh}
1286 \DeclareMathOperator{\arcosh}{arcosh}
1287 \DeclareMathOperator{\artanh}{artanh}
1288 \DeclareMathOperator{\arcsch}{arcsch}
1289 \DeclareMathOperator{\arsech}{arsech}
1290 \DeclareMathOperator{\arcoth}{arcoth}
1291 % \end{macrocode}
1292 % Inverse functions with $-1$ superscript.
1293 % \begin{macrocode}
1294 \@operator@robust@def\sininv{\sin^{\operator@font\@operatorm@ne}}
1295 \@operator@robust@def\cosinv{\cos^{\operator@font\@operatorm@ne}}
1296 \@operator@robust@def\taninv{\tan^{\operator@font\@operatorm@ne}}
1297 \@operator@robust@def\cscinv{\csc^{\operator@font\@operatorm@ne}}
1298 \@operator@robust@def\secinv{\sec^{\operator@font\@operatorm@ne}}
1299 \@operator@robust@def\cotinv{\cot^{\operator@font\@operatorm@ne}}
1300 % \end{macrocode}
1301 % And for hyperbolic trigonometric functions.
1302 % \begin{macrocode}
1303 \@operator@robust@def\sinhinv{\sinh^{\operator@font\@operatorm@ne}}
1304 \@operator@robust@def\coshinv{\cosh^{\operator@font\@operatorm@ne}}
1305 \@operator@robust@def\tanhinv{\tanh^{\operator@font\@operatorm@ne}}
1306 \@operator@robust@def\cschinv{\csch^{\operator@font\@operatorm@ne}}
1307 \@operator@robust@def\sechinv{\sech^{\operator@font\@operatorm@ne}}
1308 \@operator@robust@def\cothinv{\coth^{\operator@font\@operatorm@ne}}
1309 \else
1310 \@operatorinfo{Skipping trigonometric functions.}
1311 \fi
1312 \wlog{}
1313 % \end{macrocode}
1314 % Done!
1315 %
1316 % \vfill\eject
1317 %
1318 % \section*{Version History}
1319 %
1320 % % New features and updates with each version. Versions are chronological, and features are listed in no particular order.
1321 %
1322 % \begin{multicols*}{2}
1323 % \raggedright\parskip\z@\parindent\z@\leftskip1em\obeylines
1324 % \setbox0\hbox{\hskip 1pt.\hskip 1pt}
1325 % \def\version#1#2{\bigskip\hbox to \hsize{\textbf{#1} \cleaders\copy0\hfill\ #2}\par}
1326 % \def\item{---\kern0.2ex\relax}
1327 %
1328 % \version{1.0}{February 2025}
1329 % \item initial release
1330 %
1331 % \version{1.1}{March 2025}
1332 % \item bug fix in package declaration
1333 % \item bug fix for operators with superscripts
1334 % \item added |\operatorsquared| and |\operatorinverse|
1335 % \item added |\Hess| and |\Info|
1336 % \item changed |\operatorbaroffset| to |\overbaroffset|
1337 %
1338 % \version{1.2}{July 2025}
1339 % \item bug fix for |\operatorhyphen|
1340 % \item changed |\Chi| to |\Chiop|
1341 % \item removed dependence on $\varepsilon$-\TeX
1342 %
1343 % \version{1.2a}{July 2025}
1344 % \item bug fix for non-unicode engines
1345 %
1346 % \version{1.3}{August 2025}
1347 % \item added about 30 control sequences to various classes of operators, mostly in category theory
1348 % \item removed a stray |\detokenize|
1349 %
1350 % \version{1.3a}{September 2025}
1351 % \item bug fix for |\F|
1352 %
1353 % \end{multicols*}
1354 %
1355 %
1356 %
1357 %
1358 %
1359 % \iffalse
1360 %</code>
1361 %<*user>
1362 %
1363 \documentclass[12pt,twoside]{article}
1364 \makeatletter
1365 \usepackage[margin=72.27pt]{geometry}
1366 \usepackage[factor=700,stretch=14,shrink=14,step=1]{microtype}
1367 \usepackage{booktabs}
1368 \usepackage{tabularx}
1369 \usepackage{enumitem}
1370 \setlist{topsep=\smallskipamount,itemsep=\z@,
1371 parsep=0pt,partopsep=0pt}
1372 \usepackage[colorlinks=true,allcolors=blue,implicit=false]{hyperref}
1373 \usepackage{amssymb}
1374 \usepackage{graphicx}
1375 \usepackage{multicol}
1376 \usepackage{shortvrb}
1377 \MakeShortVerb{|}
1378 \def\meta#1{$\langle${\rmfamily\itshape #1}$\rangle$}
1379
1380 \c@topnumber=1
1381 \c@bottomnumber=1
1382
1383 \def\showop#1#2#3{\noindent
1384 \hbox to 1.625in{\texttt{\string#1}\hfil}\hbox to 1.625in{#2\hfil}\hbox to 3.25in{#3\hfil}%
1385 \par}
1386 \topsep=\smallskipamount
1387
1388 \begin{document}
1389
1390 \def\documentname{User Guide}
1391 \newdimen\MacroIndent
1392 \input math-operator-heading.tex
1393 \def\section#1#2{\@@section*{#1}\vskip-\medskipamount#2\par\bigskip}
1394
1395
1396
1397 \noindent \LaTeX\ users will no doubt be familiar with the control sequences that produce special functions and operators such as |\sin|, |\cos|, or |\sup|. However, the \LaTeX\ kernel defines only about 30 such commands, and many less common but still widely used special functions remain undefined as a result. The \textsf{math-operator} package addresses this situation by defining control sequences for some hundred and fifty special functions and operators, divided into nine groups, and the package also provides an interface to define even more. The first pages of this user guide describe how to use the package, and the rest of the document lists the control sequences in each group. For documentation of the package code, please see |math-operator_code.pdf|, which is included with the \textsf{math-operator} installation and is available on \textsc{ctan}. I encourage users who are interested in this package to also consult the \textsf{amsopn} and \textsf{moremath} packages as they may be more useful for you.\footnote{\LaTeX3 Project and American Mathematical Society, ``amsopn---Typeset mathematical operator names,'' \href{https://ctan.org/pkg/amsopn}{\texttt{https://ctan.org/pkg/amsopn}}; Marcel Ilg, ``moremath---Additional commands for typesetting maths,'' \href{https://ctan.org/pkg/moremath}{\texttt{https://ctan.org/pkg/moremath}}.} Users who are looking specifically for operators in quantum mechanics should consult the \textsf{linop} and \textsf{phfqit} packages.\footnote{Johannes Weytjens, ``linop---Typeset linear operators as they appear in quantum theory or linear algebra,'' \href{https://ctan.org/pkg/linop}{\texttt{https://ctan.org/pkg/linop}}; Philippe Faist, ``phfqit---Macros for typesetting Quantum Information Theory,'' \href{https://ctan.org/pkg/phfqit}{\texttt{https://ctan.org/pkg/phfqit}}.}
1398
1399
1400
1401
1402 Users can load \textsf{math-operator} with the standard |\usepackage| syntax, and for each operator group, the package defines either all or no control sequences from that group during loading. Each operator group corresponds to two optional package arguments---one argument means define the control sequences of that group, and the other argument means avoid doing so. Table~1 lists the nine operator groups and their corresponding arguments. For every group, the package argument to define control sequences is a shortened version of the group name, and the package argument to avoid doing so is the same keyword prefaced by |no-|. By default, \textsf{math-operator} defines all control sequences that appear later in this document.
1403
1404
1405
1406 \begin{figure}[tb]
1407 \centerline{\bfseries\strut Table 1: Optional Arguments for \textsf{math-operator}}
1408 \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lll}\toprule
1409 Group & To define commands (default) & To avoid defining commands\\\midrule
1410 Blackboard bold & |blackboard| & |no-blackboard|\\
1411 Category theory & |category| & |no-category|\\
1412 Jacobi elliptic functions & |jacobi| & |no-jacobi|\\
1413 Linear algebra & |linear| & |no-linear|\\
1414 The command \vrb\overbar & |overbar| & |no-overbar|\\
1415 Probability distributions & |probability| & |no-probability|\\
1416 Special functions & |special| & |no-special|\\
1417 Standard math operators & |standard| & |no-standard|\\
1418 Trigonometric functions & |trigonometry| & |no-trigonometry|\\\bottomrule
1419 \end{tabular*}
1420 \end{figure}
1421
1422
1423
1424 \begin{figure}[t]
1425 \centerline{\bfseries\strut Table 2: Commands to Define New Operators}
1426 \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lll}\toprule
1427 & Medium weight & Bold weight\\\midrule
1428 Treated as \vrb\mathord & |\DeclareMathText| & |\DeclareBoldMathText|\\
1429 Treated as \vrb\mathop & |\DeclareMathOperator| & |\DeclareBoldMathOperator|\\\bottomrule
1430 \end{tabular*}
1431 \end{figure}
1432
1433
1434 Users who want to create their own operators or redefine the commands in this package should use one of the four control sequences in Table~2. The entries in Table~2 should appear only in the document preamble, and their syntax is identical and looks like
1435 \begin{trivlist}
1436 \item\ttfamily\hskip2em |\DeclareMathOperator|\meta{optional |*|}|{|%
1437 \meta{control sequence}|}{|\meta{operator text}|}|
1438 \end{trivlist}
1439 When you use one of these macros, \textsf{math-operator} defines the \meta{control sequence} to produce \meta{operator text} in math mode. The optional asterisk controls the placement of superscripts and subscripts. Without an asterisk (the default version of the command), any superscripts and subscripts will render normally, but with an asterisk, they will appear above and below the operator. For example, to make a control sequence |\erf| for the error function, the |sty| file for \textsf{math-operator} contains
1440 \begin{trivlist}
1441 \item \ttfamily \hskip 2em |\DeclareMathOperator{\erf}{erf}|
1442 \end{trivlist}
1443 The syntax and implementation of these macros is very similar to the \textsf{amsopn} package.
1444
1445 The entries of Table~2 differ in the appearance of the resulting operator. The commands in the first column produce operators with medium text, and the commands in the second column produce operators with bold text. The difference between the rows is more subtle and boils down to the automatic spacing before and after the operator.\footnote{\TeX's eight classes of math subformulas are beyond the scope of this user guide, but in summary, the horizontal position of different characters in an equation depends on their math classes. See Donald Knuth, \textit{The \TeX book} (Addison Wesley, 1986), 170; David Salomon, \textit{The Advanced \TeX book} (Springer, 1995), 256–258.} The macros from the first row instruct \TeX\ to treat the operator like an ordinary variable, so they are most appropriate for sets and categories. The macros from the second row instruct \TeX\ to horizontally position the operator like a summation or integral sign, and they are appropriate for functions and probability distributions. But if you are not fastidious, for most uses of this package other than category theory, you will probably be fine to just use |\DeclareMathOperator|.
1446
1447 The macros in Table~2 will happily redefine any operator commands, but they will not overwrite other control sequences unless you specifically tell them to do so. The count variable |\operatordefmode| controls the package behavior in this regard as follows:
1448 \begin{itemize}
1449 \item Negative: redefine the control sequence
1450 \item 0: silently ignore (message written in the |log| file)
1451 \item 1: issue a warning and do not redefine
1452 \item 2 or greater: raise an error
1453 \end{itemize}
1454 By default, \textsf{math-operator} sets |\operatordefmode| to 1, so you will see a warning on the terminal or console if you try to convert a control sequence that is already defined into a math operator. However, if you really want to redefine a control sequence to be a math operator, you can say
1455 \begin{trivlist}
1456 \item \hskip 2em\ttfamily |\operatordefmode=-1|
1457 \end{trivlist}
1458 before calling a command from Table~2.
1459
1460
1461 One operator group warrants additional explanation. The package argument |overbar| corresponds to the single control sequence |\overbar|, which adds a horizontal line above a math subformula. The line will be wider than |\bar| but narrower than |\overline|, and the syntax is
1462 \begin{trivlist}
1463 \item\hskip2em\ttfamily |\overbar|\meta{optional $*$}|[|\meta{optional decimal}|]{|\meta{math}|}|
1464 \end{trivlist}
1465 The \meta{decimal} should be between 0 and 1, and it controls the width of the overline. Specifically, |\overbar| typesets \meta{math}, creates a horizontal line that is \meta{decimal} times the width of the math subformula, and places the line above the typeset subformula. By default, \meta{decimal} is 0.8. With an asterisk, |\overbar| positions the overline halfway over the subformula. For example, the code
1466 \begin{trivlist}
1467 \item \hskip 2em\ttfamily |\overbar*[0.9]{xyz}|
1468 \end{trivlist}
1469 will put an overline above $xyz$ that is 90\% the length of $xyz$ and position it exactly halfway between the start of the $x$ and the end of the $z$.
1470
1471
1472
1473 When |\overbar| does not have an asterisk (the default version of the command), the count variable |\overbaroffset| controls the horizontal placement of the line.\footnote{Version 1.0 of this package used \vrb\operatorbaroffset\ instead of \vrb\overbaroffset. To preserve backwards compatibility, \vrb\operatorbaroffset\ still works for this purpose. But please don't use \vrb\operatorbaroffset\ because I may take it out in a few years.} As is standard in \TeX, this variable should take values between 0 and 1000, and \textsf{math-operator} divides |\overbaroffset| by 1000 to form a fraction. It then places the overline that fraction of the way across the top of the subformula. The default value is 800. For example, saying
1474 \begin{trivlist}
1475 \item \hskip 2em\ttfamily |\overbaroffset=0|
1476 \end{trivlist}
1477 will make all following |\overbar| lines appear completely on the left side of the subformula, and an asterisk is equivalent to setting |\overbaroffset| to 500.
1478
1479 %\begin{figure}[t]
1480 %\centerline{\bfseries\strut Table 3: Macros for Non-Letter Expressions}
1481 %\centering
1482 %\begin{tabular}{lc}\toprule
1483 %Command & Produces \\\midrule
1484 %|\operatorhyphen| & - \\
1485 %|\operatorsquared| & $^2$ \\
1486 %|\operatorinverse| & $^{-1}$\\\bottomrule
1487 %\end{tabular}
1488 %\end{figure}
1489
1490 Some operator names contain characters that are not letters, and \textsf{math-operator} provides three control sequences for non-letter characters: |\operatorhyphen| produces a hyphen, |\operatorsquared| produces a superscript 2, and |\operatorinverse| produces a superscript $-1$. If you use a Unicode font for the operator font, \textsf{math-operator} typesets these symbols in the operator font, and inside the bold commands from Table~2, they will be bold. Additionally, each command has a starred version that forces the characters to be bold no matter where they appear in an equation. If you do not use a Unicode font, the hyphen and the squared symbol will work the same way, but |\operatorinverse| instead typesets the contents of |\defaultinverse|, which is normally $-1$, without using the operator font and without using boldface in the starred version of the command.\footnote{This complication arises because the minus sign lives in different places depending on the encoding. In Unicode, the minus sign is U+2212, but that is not true for other font encodings in \TeX.} If you are in this situation and are unsatisfied with the formatting of your $-1$ expressions, I encourage you to redefine |\defaultinverse| to be more to your liking with |\def| or |\renewcommand|.
1491
1492 A word about superscripts: I implemented the commands from Table~2 in a way that \TeX\ treats operator names as subformulas. This means that any super or subscripts will always appear after or above or below the operator, even if you end the operator name with a super or subscript. For example, if you define an inverse projection map as
1493 \begin{trivlist}
1494 \item \hskip 2em |\DeclareMathOperator{\projinv}{proj\operatorinverse}|
1495 \end{trivlist}
1496 in your document preamble and then attach a subscript as in
1497 \begin{trivlist}
1498 \item\hskip2em |\projinv_x|
1499 \end{trivlist}
1500 you will see $\mathop{\operator@font proj^{-1}}_x$ instead of $\mathop{\operator@font proj}^{-1}_x$. If your operator name ends with a super or subscript, I recommend putting everything before the final super or subscript into the appropriate command from Table~2 and then defining a separate macro using |\def| or |\newcommand|. For example, it is better to define an inverse projection map as
1501 \begin{trivlist}
1502 \item\hskip2em |\def\projinv{\proj\operatorinv}|
1503 \end{trivlist}
1504 rather than using |\DeclareMathOperator|. I took this approach in designing \textsf{math-operator}, so to redefine operators from this package that end in superscripts, you should use |\def| or |\renewcommand| instead of a control sequence from Table~2.
1505
1506 Finally, because it may redefine |\P|, \textsf{math-operator} defines |\pilcrow| to typeset the \P\ symbol in text and math modes.
1507
1508
1509 \bigskip
1510
1511 \centerline{***}
1512
1513 \vskip-\bigskipamount
1514 \vskip-\medskipamount
1515 \vskip\z@
1516
1517 \section{Blackboard Bold}{Note: to use the blackboard-bold commands listed here, you must load a package that defines \vrb\mathbb\space such as \textsf{amssymb} or \textsf{mathfont}, and if you do not do so before using these control sequences, you'll get an error. I am assuming that \vrb\mathbb\space provides access to blackboard-bold letters.}
1518
1519
1520
1521 \showop\N{$\mathbb N$}{Natural numbers}
1522 \showop\Z{$\mathbb Z$}{Integers}
1523 \showop\Q{$\mathbb Q$}{Rational numbers}
1524 \showop\R{$\mathbb R$}{Real numbers}
1525 \showop\C{$\mathbb C$}{Complex numbers}
1526 \showop\H{$\mathbb H$}{Quaternions (or half-plane)\footnotemark}\footnotetext{In math mode only. Outside of equations, \vrb\H\ will still behave normally. If you want to change the \vrb\H\ operator somehow, you should redefine \vrb\mathH, not \vrb\H.}
1527 \showop\O{$\mathbb O$}{Octonions\footnotemark}\footnotetext{In math mode only. Outside of equations, \vrb\O\ will still behave normally. If you want to change the \vrb\O\ operator somehow, you should redefine \vrb\mathO, not \vrb\O.}
1528 \showop\F{$\mathbb F$}{Arbitrary field}
1529 \showop\P{$\mathbb P$}{Probability}
1530 \showop\E{$\mathbb E$}{Expectation}
1531
1532 \section{Categories}{In version 1.3, I doubled the number of control sequences in \textsf{math-operator} for category theory, so this list is fairly substantial. That being said, it by no means exhaustive, and serious category theorists who use this package will likely need to define more categories using \vrb\DeclareBoldMathText.}
1533
1534
1535
1536 \showop{\Ab}{\textbf{Ab}}{Category of abelian groups}
1537 \showop{\Alg}{\textbf{Alg}}{Category of algebras}
1538 \showop{\Bialg}{\textbf{Bialg}}{Category of bialgebras}
1539 \showop{\Cat}{\textbf{Cat}}{Category of small categories}
1540 \showop{\CGH}{\textbf{CGH}}{Compactly generated Hausdorff spaces}
1541 \showop{\CGWH}{\textbf{CGWH}}{Compactly generated weak Hausdorff spaces}
1542 \showop{\Coalg}{\textbf{Coalg}}{Category of coalgebras}
1543 \showop{\Comod}{\textbf{Comod}}{Category of comodules}
1544 \showop{\CRing}{\textbf{CRing}}{Category of commutative rings}
1545 \showop{\Field}{\textbf{Field}}{Category of fields}
1546 \showop{\FinGrp}{\textbf{FinGrp}}{Category of finite groups}
1547 \showop{\FinHilb}{\textbf{FinHilb}}{Category of finite-dimensional Hilbert spaces}
1548 \showop{\FinVect}{\textbf{FinVect}}{Category of finite-dimensional vector spaces}
1549 \showop{\FinSet}{\textbf{FinSet}}{Category of finite sets}
1550 \showop{\Frm}{\textbf{Frm}}{Category of frames}
1551 \showop{\Grp}{\textbf{Grp}}{Category of groups}
1552 \showop{\Haus}{\textbf{Haus}}{Category of Hausdorff spaces}
1553 \showop{\HeytAlg}{\textbf{HeytAlg}}{Category of Heyting algebras}
1554 \showop{\Hilb}{\textbf{Hilb}}{Category of Hilbert spaces}
1555 \showop{\HopfAlg}{\textbf{HopfAlg}}{Category of Hopf algebras}
1556 \showop{\Lat}{\textbf{Lat}}{Category of latices}
1557 \showop{\LieAlg}{\textbf{LieAlg}}{Category of Lie algebras}
1558 \showop{\LieGrp}{\textbf{LieGrp}}{Category of Lie groups}
1559 \showop{\Loc}{\textbf{Loc}}{Category of locales}
1560 \showop{\Man}{\textbf{Man}}{Category of manifolds}
1561 \showop{\Mat}{\textbf{Mat}}{Category of matrices}
1562 \showop{\Met}{\textbf{Met}}{Category of metric spaces}
1563 \showop{\Mod}{\textbf{Mod}}{Category of modules}
1564 \showop{\Mon}{\textbf{Mon}}{Category of monoids}
1565 \showop{\Ord}{\textbf{Ord}}{Category of preordered sets}
1566 \showop{\Pos}{\textbf{Pos}}{Category of posets}
1567 \showop{\Rel}{\textbf{Rel}}{Category of sets and binary relations}
1568 \showop{\Ring}{\textbf{Ring}}{Category of rings}
1569 \showop{\Set}{\textbf{Set}}{Category of sets}
1570 \showop{\Top}{\textbf{Top}}{Category of topological spaces}
1571 \showop{\Topos}{\textbf{Topos}}{Category of toposes}
1572 \showop{\Vect}{\textbf{Vect}}{Category of vector spaces}
1573 \showop{\cocone}{cocone}{Cocone}
1574 \showop{\colim}{colim}{Colimit}
1575 \showop{\cone}{cone}{Cone}
1576 \showop{\Ho}{Ho}{Homotopy category}
1577 \showop{\Hom}{Hom}{Collection of morphisms}
1578 \showop{\Ob}{Ob}{Collection of objects}
1579 \showop{\op}{$^{\operator@font op}$}{Opposite category}
1580 \showop{\PSh}{PSh}{Presheaf category}
1581 \showop{\Sh}{Sh}{Sheaf category}
1582
1583
1584
1585
1586 \section{Jacobi Elliptic Functions}{Pretty straightforward. If you load \textsf{math-operator} with |jacobi|, you won't be able to use \vrb\sc\ to change to a small-caps font. (But you shouldn't use \vrb\sc\ anyway because it's deprecated. Please use \vrb\textsc\ instead.)}
1587
1588
1589 \showop{\cd}{cd}{}
1590 \showop{\cn}{cn}{}
1591 \showop{\cs}{cs}{}
1592 \showop{\dc}{dc}{}
1593 \showop{\dn}{dn}{}
1594 \showop{\ds}{ds}{}
1595 \showop{\nc}{nc}{}
1596 \showop{\nd}{nd}{}
1597 \showop{\ns}{ns}{}
1598 \showop{\sc}{sc}{}
1599 \showop{\sd}{sd}{}
1600 \showop{\sn}{sn}{}
1601
1602 \section{Linear Algebra}{Some matrix groups and operations.}
1603
1604
1605
1606 \showop{\adj}{adj}{Adjugate matrix}
1607 \showop{\Cl}{Cl}{Clifford algebra}
1608 \showop{\codim}{codim}{Codimension}
1609 \showop{\coker}{coker}{Cokernel}
1610 \showop{\GL}{GL}{General linear group}
1611 \showop{\nullity}{nullity}{Nullity}
1612 \showop{\Orthogonal}{O}{Orthogonal group}
1613 \showop{\Pin}{Pin}{Pin group}
1614 \showop{\proj}{proj}{Projection (onto a vector)}
1615 \showop{\rank}{rank}{Rank}
1616 \showop{\SL}{SL}{Special linear group}
1617 \showop{\SO}{SO}{Special orthogonal group}
1618 \showop{\SU}{SU}{Special unitary group}
1619 \showop{\Sp}{Sp}{Symplectic group}
1620 \showop{\spanop}{span}{Span}
1621 \showop{\Spin}{Spin}{Spin group}
1622 \showop{\tr}{tr}{Trace}
1623 \showop{\T}{$^{\operator@font T}$}{Transpose}
1624 \showop{\Unitary}{U}{Unitary group}
1625
1626
1627 \section{Overlining}{Loading \textsf{math-operator} with the |overbar| option tells the package to define \vrb\overbar. Below are two examples of this macro with \vrb\bar\space and \vrb\overline\space for comparison.}
1628
1629
1630 \def\showbars#1#2#3#4{%
1631 \noindent
1632 \hb@xt@ 0.25\textwidth{#1\hfil}%
1633 \hb@xt@ 0.25\textwidth{#2\hfil}%
1634 \hb@xt@ 0.25\textwidth{#3\hfil}%
1635 \hb@xt@ 0.25\textwidth{#4\hfil}\par}
1636
1637 \showbars{\texttt{\string\bar\ a}}{$\bar a$}
1638 {\texttt{\string\bar\ X}}{$\bar X$}
1639
1640 \showbars{\texttt{\string\overbar\ a}}
1641 {\setbox\@tempboxa\hbox{%
1642 \setbox\@tempboxa\hbox{$a$}%
1643 \@tempdima\wd\@tempboxa
1644 \@tempdimb\ht\@tempboxa
1645 \hb@xt@\z@{\box\@tempboxa\hss}%
1646 \hskip 0.16\@tempdima
1647 $\overline{\vrule height \@tempdimb width \z@ depth \z@
1648 \hskip 0.8\@tempdima}\m@th$}%
1649 \box\@tempboxa}
1650 {\texttt{\string\overbar\ X}}
1651 {\setbox\@tempboxa\hbox{%
1652 \setbox\@tempboxa\hbox{$X$}%
1653 \@tempdima\wd\@tempboxa
1654 \@tempdimb\ht\@tempboxa
1655 \rlap{\box\@tempboxa}%
1656 \hskip 0.16\@tempdima
1657 $\overline{\vrule height \@tempdimb width \z@ depth \z@
1658 \hskip 0.8\@tempdima}\m@th$}%
1659 \box\@tempboxa}
1660
1661 \showbars{\texttt{\string\overline\ a}}{$\overline a$}
1662 {\texttt{\string\overline\ X}}{$\overline X$}
1663
1664
1665 \section{Probability Distributions}{A selection of the most common probability distributions. For the normal distribution, if you type \vrb\Normal\ without the asterisk, you will see $\mathcal N$, and if you include the asterisk after \vrb\Normal, then \textsf{math-operator} will write out ``Normal.''}
1666
1667
1668
1669 \showop{\Bernoulli}{Bernoulli}{}
1670 \showop{\Betaop}{Beta}{}
1671 \showop{\Binomial}{Binomial}{}
1672 \showop{\Boltzmann}{Boltzmann}{}
1673 \showop{\Burr}{Burr}{}
1674 \showop{\Categorical}{Categorical}{}
1675 \showop{\Cauchy}{Cauchy}{}
1676 \showop{\ChiSq}{$\chi^2$}{Chi-squared}
1677 \showop{\Dagum}{Dagum}{}
1678 \showop{\Exponential}{Exponential}{}
1679 \showop{\Erlang}{Erlang}{}
1680 \showop{\Gammaop}{Gamma}{}
1681 \showop{\Gompertz}{Gompertz}{}
1682 \showop{\InvChiSq}{Inv-$\chi^2$}{Inverse chi-squared}
1683 \showop{\InvGamma}{Inv-Gamma}{Inverse gamma}
1684 \showop{\Kolmogorov}{Kolmogorov}{}
1685 \showop{\LogLogistic}{Log-Logistic}{}
1686 \showop{\LogNormal}{Log-Normal}{}
1687 \showop{\Logistic}{Logistic}{}
1688 \showop{\Lomax}{Lomax}{}
1689 \showop{\MaxwellBoltzmann}{Maxwell-Boltzmann}{}
1690 \showop{\Multinomial}{Multinomial}{}
1691 \showop{\NegBinomial}{Neg-Binomial}{Negative binomial}
1692 \showop{\Normal\meta{optional $*$}}{$\mathcal N$ or Normal}{}
1693 \showop{\Pareto}{Pareto}{}
1694 \showop{\Poisson}{Poisson}{}
1695 \showop{\Weibull}{Weibull}{}
1696 \showop{\Zipf}{Zipf}{}
1697
1698 \section{Special Functions}{Common special functions from applied math.}
1699
1700
1701
1702 \showop{\Ai}{Ai}{Airy function of the first kind}
1703 \showop{\Bi}{Bi}{Airy function of the second kind}
1704 \showop{\Ci}{Ci}{Cosine integral function}
1705 \showop{\ci}{ci}{Cosine integral function (variant)}
1706 \showop{\Chiop}{Chi}{Hyperbolic cosine integral function}
1707 \showop{\Ei}{Ei}{Exponential integral function}
1708 \showop{\erf}{erf}{Error function}
1709 \showop{\erfinv}{erf$^{-1}$}{Inverse error function}
1710 \showop{\erfc}{erfc}{Complementary error function}
1711 \showop{\erfcinv}{erfc$^{-1}$}{Inverse complementary error function}
1712 \showop{\Li}{Li}{Polylogarithm function}
1713 \showop{\li}{li}{Logarithmic integral function}
1714 \showop{\Log}{Log}{Logarithm (principal value)}
1715 \showop{\sgn}{sgn}{Sign function}
1716 \showop{\Si}{Si}{Sine integral function}
1717 \showop{\si}{si}{Sine integral function (variant)}
1718 \showop{\Shi}{Shi}{Hyperbolic sine integral function}
1719
1720
1721 \section{Standard Operators}{Common mathematical operations. More pure mathy than the special functions.}
1722
1723
1724
1725 \showop{\argmax}{arg$\,$max}{Arguments of the maxima}
1726 \showop{\argmin}{arg$\,$min}{Arguments of the minima}
1727 \showop{\Aut}{Aut}{Automorphism group}
1728 \showop{\c}{$^{\begingroup\operator@font c\endgroup}$}{Complement\footnotemark}\footnotetext{In math mode only. Outside of equations, \vrb\c\ will still behave normally. If you want to change the \vrb\c\ operator somehow, you should redefine \vrb\mathc, not \vrb\c.}
1729 \showop{\cf}{cf}{Cofinality}
1730 \showop{\cl}{cl}{Closure}
1731 \showop{\conv}{conv}{Convex hull}
1732 \showop{\corr}{corr}{Correlation}
1733 \showop{\cov}{cov}{Covariance}
1734 \showop{\curl}{curl}{Curl}
1735 \showop{\divop}{div}{Divergence}
1736 \showop{\Ext}{Ext}{Ext (extension) functor}
1737 \showop{\Gal}{Gal}{Galois group}
1738 \showop{\grad}{grad}{Gradient}
1739 \showop{\Hess}{$\mathcal{H}$}{Hessian}
1740 \showop{\id}{id}{Identity}
1741 \showop{\Im}{Im}{Imaginary part}
1742 \showop{\varIm}{$\Im$}{Imaginary part\footnotemark}\footnotetext{In the \LaTeX\ kernel, \texttt{\string\Im} produces $\Im$, but I decided to change that since Im is more standard than $\Im$.}
1743 \showop{\img}{img}{Image}
1744 \showop{\Info}{$\mathcal{I}$}{Fisher Information}
1745 \showop{\interior}{int}{Interior}
1746 \showop{\lcm}{lcm}{Least common multiple}
1747 \showop{\Proj}{Proj}{Projective spectrum}
1748 \showop{\Re}{Re}{Real part}
1749 \showop{\varRe}{$\Re$}{Real part\footnotemark}\footnotetext{In the \LaTeX\ kernel, \texttt{\string\Re} produces $\Re$, but I decided to change that since Re is more standard than $\Re$.}
1750 \showop{\Res}{Res}{Residue}
1751 \showop{\Spec}{Spec}{Spectrum}
1752 \showop{\st}{st}{Standard part (shadow) of a hyperreal number}
1753 \showop{\supp}{supp}{Support}
1754 \showop{\Tor}{Tor}{Tor (torsion) functor}
1755 \showop{\Var}{Var}{Variance}
1756
1757
1758
1759 \section{Trigonometry}{All inverse, hyperbolic, and inverse hyperbolic trigonometric functions that are not in the \LaTeX\ kernel.}
1760
1761
1762
1763 \showop{\csch}{csch}{Hyperbolic cosecant}
1764 \showop{\sech}{sech}{Hyperbolic secant}
1765 \showop{\arccsc}{arccsc}{Inverse cosecant}
1766 \showop{\arcsec}{arcsec}{Inverse secant}
1767 \showop{\arccot}{arccot}{Inverse cotangent}
1768 \showop{\arcsinh}{arcsinh}{Inverse hyperbolic sine}
1769 \showop{\arccosh}{arccosh}{Inverse hyperbolic cosine}
1770 \showop{\arctanh}{arctanh}{Inverse hyperbolic tangent}
1771 \showop{\arccsch}{arccsch}{Inverse hyperbolic cosecant}
1772 \showop{\arcsech}{arcsech}{Inverse hyperbolic secant}
1773 \showop{\arccoth}{arccoth}{Inverse hyperbolic tangent}
1774 \showop{\arsinh}{arsinh}{Inverse hyperbolic sine}
1775 \showop{\arcosh}{arcosh}{Inverse hyperbolic cosine}
1776 \showop{\artanh}{artanh}{Inverse hyperbolic tangent}
1777 \showop{\arcsch}{arcsch}{Inverse hyperbolic cosecant}
1778 \showop{\arsech}{arsech}{Inverse hyperbolic secant}
1779 \showop{\arcoth}{arcoth}{Inverse hyperbolic cotangent}
1780 \showop{\sininv}{sin$^{-1}$}{Inverse sine}
1781 \showop{\cosinv}{cos$^{-1}$}{Inverse cosine}
1782 \showop{\taninv}{tan$^{-1}$}{Inverse tangent}
1783 \showop{\cscinv}{csc$^{-1}$}{Inverse cosecant}
1784 \showop{\secinv}{sec$^{-1}$}{Inverse secant}
1785 \showop{\cotinv}{cot$^{-1}$}{Inverse cotangent}
1786 \showop{\sinhinv}{sinh$^{-1}$}{Inverse hyperbolic sine}
1787 \showop{\coshinv}{cosh$^{-1}$}{Inverse hyperbolic cosine}
1788 \showop{\tanhinv}{tanh$^{-1}$}{Inverse hyperbolic tangent}
1789 \showop{\cschinv}{csch$^{-1}$}{Inverse hyperbolic cosecant}
1790 \showop{\sechinv}{sech$^{-1}$}{Inverse hyperbolic secant}
1791 \showop{\cothinv}{coth$^{-1}$}{Inverse hyperbolic cotangent}
1792
1793
1794
1795
1796
1797 \end{document}
1798 %
1799 %</user>
1800 %<*heading>
1801 %
1802
1803 \csname count@\endcsname\catcode`\@
1804 \makeatletter
1805
1806 % package date and edition
1807 \def\packagedate{September 2025}
1808 \def\packageversion{1.3a}
1809
1810 % header and footer commands
1811 \let\@@section\section
1812 \def\section{\relax
1813 \vskip0.8in\penalty\z@\kern\z@\vskip-0.8in\vskip\z@
1814 \@ifstar\star@sect\no@star@sect}
1815 \def\star@sect#1{\@@section*{#1}\section@name{#1}}
1816 \def\no@star@sect#1{\@@section{#1}\section@name{#1}}
1817 \def\section@name#1{\expandafter
1818 \def\csname section@\thesection\endcsname{#1}}
1819 \def\sectionname{\csname section@\thesection\endcsname}
1820
1821 \def\clap#1{\hb@xt@\z@{\hss#1\hss}}
1822 \def\@oddhead{\ifnum\count0>1\relax
1823 \rlap{}\hfil\clap{\itshape\sectionname}\hfil
1824 \llap{\the\count0}\fi}
1825 \def\@evenhead{\ifnum\count0>1\relax
1826 \rlap{\the\count0}\hfil\clap{\itshape\sectionname}\hfil
1827 \llap{}\fi}
1828 \def\@oddfoot{\hfil\ifnum\count0=1\relax1\fi\hfil}
1829 \let\@evenfoot\@empty
1830
1831 % penalties
1832 \pretolerance=20
1833 \hyphenpenalty=10
1834 \exhyphenpenalty=5
1835 \brokenpenalty=0
1836 \clubpenalty=5
1837 \widowpenalty=5
1838 \finalhyphendemerits=300
1839 \doublehyphendemerits=500
1840
1841 \flushbottom
1842
1843 % general macros
1844 \def\topfraction{1}
1845 \def\bottomfraction{1}
1846 \let\code\@undefined
1847 \newenvironment{code}
1848 {\strut\vadjust\bgroup\vskip 5pt plus 1pt minus 3pt\relax
1849 \parindent\z@\leftskip2em\relax
1850 \noindent\strut\ignorespaces}
1851 {\strut\par\vskip 5pt plus 1pt minus 3pt\relax
1852 \egroup\hfill\break\strut\ignorespacesafterend}
1853 \def\vrb#1{\expandafter\texttt\expandafter{\string#1}}
1854 \def\XeTeX{X\kern-0.1em
1855 \raise-0.5ex\hbox{\rotatebox[origin=c]{180}{E}}\kern-0.15em
1856 \TeX}
1857 \def\XeLaTeX{X\kern-0.1em
1858 \raise-0.5ex\hbox{\rotatebox[origin=c]{180}{E}}\kern-0.15em
1859 \LaTeX}
1860 \parskip=0pt
1861
1862
1863 % title information
1864 {\large
1865 \let\thefootnote\relax
1866 \footnotetext{Acknowledgements: Thanks to Andrew Baker for pointing out a bug in a previous version of \textsf{math-operator} and suggesting additional control sequences for the package.}
1867 \parindent=0pt\relax
1868 \leftskip=0pt plus 1fill\relax
1869 \rightskip=0pt plus 1fill\relax
1870 {\strut\Large Package \textsf{math-operator} v.\ \packageversion\ \documentname\par
1871 {\strut Conrad Kosowsky}\par
1872 {\strut\packagedate}\par
1873 {\strut\ttfamily [email protected]}\par}
1874
1875 \bigskip
1876
1877 {\small
1878 \leftskip=0.5in\relax
1879 \rightskip=0.5in\relax
1880 \hyphenpenalty=500
1881
1882 % abstract
1883 \centerline{\bfseries Overview\strut}
1884 \noindent The \textsf{math-operator} package defines control sequences for roughly one hundred and fifty math operators, including special functions, probability distributions, pure mathematical constructions, and a variant of |\overline|. The package also provides an interface for users to define new math operators similar to the \textsf{amsopn} package. New operators can be medium or bold weight, and they may be declared as |\mathord| or |\mathop| subformulas.\par}
1885
1886 \bigskip\bigskip\nointerlineskip
1887 \centerline{\vrule height 0.5pt width 2.5in}\bigskip\bigskip}
1888 \nointerlineskip
1889
1890
1891 \catcode`\@\count@
1892
1893
1894 %
1895 %
1896 %
1897 %
1898 %
1899 %
1900 %
1901 %</heading>
1902 % \fi
1903 %
1904 %
1905 % \check@checksum
1906 %
1907 % \endinput