| 1 |
% |
| 2 |
% \iffalse meta-comment |
| 3 |
% |
| 4 |
% Copyright (C) 1995, 1999 American Mathematical Society. |
| 5 |
% Copyright (C) 2016-2025 LaTeX Project and American Mathematical Society. |
| 6 |
% |
| 7 |
% This work may be distributed and/or modified under the |
| 8 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 9 |
% of this license or (at your option) any later version. |
| 10 |
% The latest version of this license is in |
| 11 |
% https://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 13 |
% version 2005/12/01 or later. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status `maintained'. |
| 16 |
% |
| 17 |
% The Current Maintainer of this work is the LaTeX Project. |
| 18 |
% |
| 19 |
% \fi |
| 20 |
% |
| 21 |
%\iffalse |
| 22 |
%<*driver> |
| 23 |
\documentclass{amsdtx} |
| 24 |
\def\MaintainedByLaTeXTeam#1{% |
| 25 |
\begin{center}% |
| 26 |
\fbox{\fbox{\begin{tabular}{@{}l@{}}% |
| 27 |
This file is maintained by the \LaTeX{} Project team.\\% |
| 28 |
Bug reports can be opened (category \texttt{#1}) at\\% |
| 29 |
\url{https://latex-project.org/bugs/}.\end{tabular}}}\end{center}} |
| 30 |
\let\savedarg\arg |
| 31 |
\usepackage{amsopn} |
| 32 |
\let\arg\savedarg |
| 33 |
\GetFileInfo{amsopn.sty} |
| 34 |
\begin{document} |
| 35 |
\title{The \pkg{amsopn} package} |
| 36 |
\author{Michael Downes} |
| 37 |
\date{Version \fileversion, \filedate} |
| 38 |
\DocInput{amsopn.dtx} |
| 39 |
\end{document} |
| 40 |
%</driver> |
| 41 |
%\fi |
| 42 |
% |
| 43 |
% \maketitle |
| 44 |
% \MaintainedByLaTeXTeam{amslatex} |
| 45 |
% |
| 46 |
% \MakeShortVerb\| |
| 47 |
% |
| 48 |
% \section{Introduction} |
| 49 |
% |
| 50 |
% The \pkg{amsopn} package provides a command |
| 51 |
% \cn{DeclareMathOperator} for defining new `math operator names' |
| 52 |
% similar to the standard function names \cn{sin}, \cn{lim}, |
| 53 |
% \cn{max}, etc. |
| 54 |
% |
| 55 |
% \MaybeStop{} |
| 56 |
% |
| 57 |
% Standard file identification. |
| 58 |
% \begin{macrocode} |
| 59 |
\NeedsTeXFormat{LaTeX2e}% LaTeX 2.09 can't be used (nor non-LaTeX) |
| 60 |
[1994/12/01]% LaTeX date must December 1994 or later |
| 61 |
\ProvidesPackage{amsopn}[2022/04/08 v2.04 operator names] |
| 62 |
% \end{macrocode} |
| 63 |
% |
| 64 |
% What \cs{nolimits@} does is keep a \cn{limits} typed by the user |
| 65 |
% from having any effect. This is used for operatornames whose |
| 66 |
% standard usage is never to have limits. |
| 67 |
% \begin{macrocode} |
| 68 |
\def\nolimits@{\@ifnextchar\limits{\nolimits\@gobble}{\nolimits}} |
| 69 |
% \end{macrocode} |
| 70 |
% |
| 71 |
% In operator names, it is sometimes desired to have text-mode |
| 72 |
% punctuation characters such as |*-/:'|. |
| 73 |
% Because the body of an |
| 74 |
% operator name is set in math mode, these few punctuation |
| 75 |
% characters will not come out right (wrong symbol and/or wrong |
| 76 |
% spacing). The purpose of \cs{newmcodes@} is to make them act like |
| 77 |
% their normal text versions. |
| 78 |
% |
| 79 |
% Where practical, we use decimal numbers to cut down main mem |
| 80 |
% usage (\qc{\"} not needed). |
| 81 |
% Use |\Umathcodedefnum| with xetex and LuaTeX to avoid problems |
| 82 |
% using |\mathcode| if |-| has already been defined using |\Umathcode|. |
| 83 |
% \changes{v2.02}{2016/03/08}{Unicode TeX version of \cs{newmcodes@}} |
| 84 |
% \begin{macrocode} |
| 85 |
\begingroup \catcode`\"=12 |
| 86 |
\ifx\Umathcode\@undefined |
| 87 |
\gdef\newmcodes@{\mathcode`\'39\mathcode`\*42\mathcode`\."613A% |
| 88 |
% \end{macrocode} |
| 89 |
% Define \cs{std@minus} for \cs{relbar} use; otherwise there are |
| 90 |
% problems with arrows constructed with relbar. |
| 91 |
% \begin{macrocode} |
| 92 |
\ifnum\mathcode`\-=45 \else |
| 93 |
\mathchardef\std@minus\mathcode`\-\relax |
| 94 |
\fi |
| 95 |
\mathcode`\-45\mathcode`\/47\mathcode`\:"603A\relax} |
| 96 |
% \end{macrocode} |
| 97 |
% \begin{macrocode} |
| 98 |
\else |
| 99 |
% \end{macrocode} |
| 100 |
% \begin{macrocode} |
| 101 |
\gdef\newmcodes@{\mathcode`\'39\mathcode`\*42\mathcode`\."613A% |
| 102 |
\ifnum\Umathcodenum`\-=45 \else |
| 103 |
\Umathcharnumdef\std@minus\Umathcodenum`\-\relax |
| 104 |
\fi |
| 105 |
\mathcode`\-45\mathcode`\/47\mathcode`\:"603A\relax} |
| 106 |
% \end{macrocode} |
| 107 |
% \begin{macrocode} |
| 108 |
\fi |
| 109 |
\endgroup |
| 110 |
% \end{macrocode} |
| 111 |
% |
| 112 |
% The command \cs{operatorname} prints its argument as a `math |
| 113 |
% operator' like \cs{sin} or \cs{det}, with proper font and spacing. |
| 114 |
% \begin{macrocode} |
| 115 |
\DeclareRobustCommand{\operatorname}{% |
| 116 |
\@ifstar{\qopname\newmcodes@ m}% |
| 117 |
{\qopname\newmcodes@ o}}% |
| 118 |
% \end{macrocode} |
| 119 |
% In the interior of the \cs{mathop} we need a null object (we choose |
| 120 |
% a zero kern for minimum waste of main mem) in order to guard |
| 121 |
% against the case where \arg{3} is a single letter; \tex/ will seize |
| 122 |
% it and center it on the math axis if there is nothing else inside |
| 123 |
% the \cs{mathop} atom. |
| 124 |
% \begin{macrocode} |
| 125 |
\DeclareRobustCommand{\qopname}[3]{% |
| 126 |
\mathop{#1\kern\z@\operator@font#3}% |
| 127 |
\csname n#2limits@\endcsname} |
| 128 |
% \end{macrocode} |
| 129 |
% |
| 130 |
% \begin{macro}{\DeclareMathOperator} |
| 131 |
% The command \cn{DeclareMathOperator} defines the first argument to |
| 132 |
% be an operator name whose text is the second argument. The star |
| 133 |
% form means that the operator name should take limits (like \cn{max} |
| 134 |
% or \cn{lim}). |
| 135 |
% \begin{macrocode} |
| 136 |
\newcommand{\DeclareMathOperator}{% |
| 137 |
\@ifstar{\@declmathop m}{\@declmathop o}} |
| 138 |
% \end{macrocode} |
| 139 |
% \end{macro} |
| 140 |
% |
| 141 |
% In the basic set of operator names (below) we did not use |
| 142 |
% \cn{DeclareRobustCommand} because of the hash table cost. But we |
| 143 |
% use it here to minimize the chances of trouble, since we are |
| 144 |
% producing a user-defined command. |
| 145 |
% \begin{macrocode} |
| 146 |
\long\def\@declmathop#1#2#3{% |
| 147 |
\@ifdefinable{#2}{% |
| 148 |
\DeclareRobustCommand{#2}{\qopname\newmcodes@#1{#3}}}} |
| 149 |
% |
| 150 |
\@onlypreamble\DeclareMathOperator |
| 151 |
\@onlypreamble\@declmathop |
| 152 |
% \end{macrocode} |
| 153 |
% |
| 154 |
% \changes{v2.04}{2022/04/08}{Make operators \cs{protected} (gh/123)} |
| 155 |
% \begin{macrocode} |
| 156 |
\protected\def\arccos{\qopname\relax o{arccos}} |
| 157 |
\protected\def\arcsin{\qopname\relax o{arcsin}} |
| 158 |
\protected\def\arctan{\qopname\relax o{arctan}} |
| 159 |
\protected\def\arg{\qopname\relax o{arg}} |
| 160 |
\protected\def\cos{\qopname\relax o{cos}} |
| 161 |
\protected\def\cosh{\qopname\relax o{cosh}} |
| 162 |
\protected\def\cot{\qopname\relax o{cot}} |
| 163 |
\protected\def\coth{\qopname\relax o{coth}} |
| 164 |
\protected\def\csc{\qopname\relax o{csc}} |
| 165 |
\protected\def\deg{\qopname\relax o{deg}} |
| 166 |
\protected\def\det{\qopname\relax m{det}} |
| 167 |
\protected\def\dim{\qopname\relax o{dim}} |
| 168 |
\protected\def\exp{\qopname\relax o{exp}} |
| 169 |
\protected\def\gcd{\qopname\relax m{gcd}} |
| 170 |
\protected\def\hom{\qopname\relax o{hom}} |
| 171 |
\protected\def\inf{\qopname\relax m{inf}} |
| 172 |
\protected\def\injlim{\qopname\relax m{inj\,lim}} |
| 173 |
\protected\def\ker{\qopname\relax o{ker}} |
| 174 |
\protected\def\lg{\qopname\relax o{lg}} |
| 175 |
\protected\def\lim{\qopname\relax m{lim}} |
| 176 |
\protected\def\liminf{\qopname\relax m{lim\,inf}} |
| 177 |
\protected\def\limsup{\qopname\relax m{lim\,sup}} |
| 178 |
\protected\def\ln{\qopname\relax o{ln}} |
| 179 |
\protected\def\log{\qopname\relax o{log}} |
| 180 |
\protected\def\max{\qopname\relax m{max}} |
| 181 |
\protected\def\min{\qopname\relax m{min}} |
| 182 |
\protected\def\Pr{\qopname\relax m{Pr}} |
| 183 |
\protected\def\projlim{\qopname\relax m{proj\,lim}} |
| 184 |
\protected\def\sec{\qopname\relax o{sec}} |
| 185 |
\protected\def\sin{\qopname\relax o{sin}} |
| 186 |
\protected\def\sinh{\qopname\relax o{sinh}} |
| 187 |
\protected\def\sup{\qopname\relax m{sup}} |
| 188 |
\protected\def\tan{\qopname\relax o{tan}} |
| 189 |
\protected\def\tanh{\qopname\relax o{tanh}} |
| 190 |
% \end{macrocode} |
| 191 |
% |
| 192 |
% \begin{macro}{\operator@font} |
| 193 |
% \begin{macro}{\operatorfont} |
| 194 |
% This command is provided to allow the document styles to decide in |
| 195 |
% which way math operators like `max' or `log' are typeset. The |
| 196 |
% default is to set them in \meta{math group} zero of the current |
| 197 |
% math version. The original name was \cs{operator@font}, retained |
| 198 |
% for compatibility; the second name was added to make it |
| 199 |
% more accessible so that users can call this font for use in special |
| 200 |
% constructs that are not ordinary operator names but conceptually |
| 201 |
% related. |
| 202 |
% |
| 203 |
% \cs{operator@font} is also declared by the \LaTeX{} kernel (for |
| 204 |
% at least 14 years), thus defining it here effectively means |
| 205 |
% ``resetting it'' to the kernel value, which is counterproductive |
| 206 |
% in situations where the user (or a class) has altered its |
| 207 |
% definition and at a later point \pkg{amsopn} got added. |
| 208 |
% \changes{v2.03}{2022/01/20}{Do not reset \cs{operator@font} it is |
| 209 |
% already defined in the LaTeX kernel (gh/734)} |
| 210 |
% \begin{macrocode} |
| 211 |
%\def\operator@font{\mathgroup\symoperators} % commented out in 2.03 |
| 212 |
\def\operatorfont{\operator@font} |
| 213 |
% \end{macrocode} |
| 214 |
% \end{macro} |
| 215 |
% \end{macro} |
| 216 |
% |
| 217 |
% For backwards compatibility we keep this old command name for the |
| 218 |
% time being: |
| 219 |
% \begin{macrocode} |
| 220 |
\def\operatornamewithlimits{\operatorname*} |
| 221 |
% \end{macrocode} |
| 222 |
% |
| 223 |
% These macros use \cs{mathpalette}s so that they will change size |
| 224 |
% in script and scriptscript styles, though it's hard to imagine they |
| 225 |
% will ever be used there (the arrows, particularly, look bad in |
| 226 |
% subscript sizes). Notice that the use of \cs{ex@} means that the |
| 227 |
% vertical spacing may not be optimal in script and scriptscript |
| 228 |
% sizes. Unfortunately \tex/ provides no easy way to do math mode |
| 229 |
% vertical spacing that varies with current math style like mu units. |
| 230 |
% \changes{v2.04}{2022/04/08}{Make operators \cs{protected} (gh/123)} |
| 231 |
% \begin{macrocode} |
| 232 |
\protected\def\varlim@#1#2{% |
| 233 |
\vtop{\m@th\ialign{##\cr |
| 234 |
\hfil$#1\operator@font lim$\hfil\cr |
| 235 |
\noalign{\nointerlineskip\kern1.5\ex@}#2\cr |
| 236 |
\noalign{\nointerlineskip\kern-\ex@}\cr}}% |
| 237 |
} |
| 238 |
\protected\def\varinjlim{% |
| 239 |
\mathop{\mathpalette\varlim@{\rightarrowfill@\textstyle}}\nmlimits@ |
| 240 |
} |
| 241 |
\protected\def\varprojlim{% |
| 242 |
\mathop{\mathpalette\varlim@{\leftarrowfill@\textstyle}}\nmlimits@ |
| 243 |
} |
| 244 |
\protected\def\varliminf{\mathop{\mathpalette\varliminf@{}}\nmlimits@} |
| 245 |
\def\varliminf@#1{\@@underline{\vrule\@depth.2\ex@\@width\z@ |
| 246 |
\hbox{$#1\m@th\operator@font lim$}}} |
| 247 |
\protected\def\varlimsup{\mathop{\mathpalette\varlimsup@{}}\nmlimits@} |
| 248 |
\def\varlimsup@#1{\@@overline{\hbox{$#1\m@th\operator@font lim$}}} |
| 249 |
% \end{macrocode} |
| 250 |
% |
| 251 |
% \begin{macrocode} |
| 252 |
\let\nmlimits@\displaylimits |
| 253 |
\DeclareOption{namelimits}{\let\nmlimits@\displaylimits} |
| 254 |
\DeclareOption{nonamelimits}{\let\nmlimits@\nolimits} |
| 255 |
\ProcessOptions\relax |
| 256 |
% \end{macrocode} |
| 257 |
% |
| 258 |
% If we don't load the \pkg{amsgen} package then the use of \cs{ex@} |
| 259 |
% in \cs{varlim@} will lead to trouble. |
| 260 |
% \begin{macrocode} |
| 261 |
\RequirePackage{amsgen}\relax |
| 262 |
% \end{macrocode} |
| 263 |
% |
| 264 |
% The usual \cs{endinput} to ensure that random garbage at the end of |
| 265 |
% the file doesn't get copied by \fn{docstrip}. |
| 266 |
% \begin{macrocode} |
| 267 |
\endinput |
| 268 |
% \end{macrocode} |
| 269 |
% |
| 270 |
% \changes{v1.2a}{1995/02/20}{Fixed operatorname |
| 271 |
% (shouldn't have same limits behavior as operatorname*)} |
| 272 |
% |
| 273 |
% \Finale |