2 % \iffalse meta-comment
4 % Copyright 1995, 1999 American Mathematical Society.
5 % Copyright 2016 LaTeX3 Project and American Mathematical Society.
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 % http://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.
15 % This work has the LPPL maintenance status `maintained'.
17 % The Current Maintainer of this work is the LaTeX3 Project.
23 \documentclass{amsdtx}
24 \def\MaintainedByLaTeXTeam#1{%
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{http://latex-project.org/bugs.html}.\end{tabular}}}\end{center}}
33 \GetFileInfo{amsopn.sty}
35 \title{The \pkg{amsopn} package}
36 \author{Michael Downes}
37 \date{Version \fileversion, \filedate}
44 % \MaintainedByLaTeXTeam{amslatex}
48 % \section{Introduction}
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},
57 % Standard file identification.
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}[2016/03/08 v2.02 operator names]
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.
68 \def\nolimits@{\@ifnextchar\limits{\nolimits\@gobble}{\nolimits}}
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.
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@}}
85 \begingroup \catcode`\"=12
86 \ifx\Umathcode\@undefined
87 \gdef\newmcodes@{\mathcode`\'39\mathcode`\*42\mathcode`\."613A%
89 % Define \cs{std@minus} for \cs{relbar} use; otherwise there are
90 % problems with arrows constructed with relbar.
92 \ifnum\mathcode`\-=45 \else
93 \mathchardef\std@minus\mathcode`\-\relax
95 \mathcode`\-45\mathcode`\/47\mathcode`\:"603A\relax}
101 \gdef\newmcodes@{\mathcode`\'39\mathcode`\*42\mathcode`\."613A%
102 \ifnum\Umathcodenum`\-=45 \else
103 \Umathcharnumdef\std@minus\Umathcodenum`\-\relax
105 \mathcode`\-45\mathcode`\/47\mathcode`\:"603A\relax}
112 % The command \cs{operatorname} prints its argument as a `math
113 % operator' like \cs{sin} or \cs{det}, with proper font and spacing.
115 \DeclareRobustCommand{\operatorname}{%
116 \@ifstar{\qopname\newmcodes@ m}%
117 {\qopname\newmcodes@ o}}%
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.
125 \DeclareRobustCommand{\qopname}[3]{%
126 \mathop{#1\kern\z@\operator@font#3}%
127 \csname n#2limits@\endcsname}
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}
136 \newcommand{\DeclareMathOperator}{%
137 \@ifstar{\@declmathop m}{\@declmathop o}}
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.
146 \long\def\@declmathop#1#2#3{%
148 \DeclareRobustCommand{#2}{\qopname\newmcodes@#1{#3}}}}
150 \@onlypreamble\DeclareMathOperator
151 \@onlypreamble\@declmathop
155 \def\arccos{\qopname\relax o{arccos}}
156 \def\arcsin{\qopname\relax o{arcsin}}
157 \def\arctan{\qopname\relax o{arctan}}
158 \def\arg{\qopname\relax o{arg}}
159 \def\cos{\qopname\relax o{cos}}
160 \def\cosh{\qopname\relax o{cosh}}
161 \def\cot{\qopname\relax o{cot}}
162 \def\coth{\qopname\relax o{coth}}
163 \def\csc{\qopname\relax o{csc}}
164 \def\deg{\qopname\relax o{deg}}
165 \def\det{\qopname\relax m{det}}
166 \def\dim{\qopname\relax o{dim}}
167 \def\exp{\qopname\relax o{exp}}
168 \def\gcd{\qopname\relax m{gcd}}
169 \def\hom{\qopname\relax o{hom}}
170 \def\inf{\qopname\relax m{inf}}
171 \def\injlim{\qopname\relax m{inj\,lim}}
172 \def\ker{\qopname\relax o{ker}}
173 \def\lg{\qopname\relax o{lg}}
174 \def\lim{\qopname\relax m{lim}}
175 \def\liminf{\qopname\relax m{lim\,inf}}
176 \def\limsup{\qopname\relax m{lim\,sup}}
177 \def\ln{\qopname\relax o{ln}}
178 \def\log{\qopname\relax o{log}}
179 \def\max{\qopname\relax m{max}}
180 \def\min{\qopname\relax m{min}}
181 \def\Pr{\qopname\relax m{Pr}}
182 \def\projlim{\qopname\relax m{proj\,lim}}
183 \def\sec{\qopname\relax o{sec}}
184 \def\sin{\qopname\relax o{sin}}
185 \def\sinh{\qopname\relax o{sinh}}
186 \def\sup{\qopname\relax m{sup}}
187 \def\tan{\qopname\relax o{tan}}
188 \def\tanh{\qopname\relax o{tanh}}
191 % \begin{macro}{\operator@font}
192 % \begin{macro}{\operatorfont}
193 % This command is provided to allow the document styles to decide in
194 % which way math operators like `max' or `log' are typeset. The
195 % default is to set them in \meta{math group} zero of the current
196 % math version. The original name was \cs{operator@font}, retained
197 % for compatibility; the second name was added to make it
198 % more accessible so that users can call this font for use in special
199 % constructs that are not ordinary operator names but conceptually
202 \def\operator@font{\mathgroup\symoperators}
203 \def\operatorfont{\operator@font}
208 % For backwards compatibility we keep this old command name for the
211 \def\operatornamewithlimits{\operatorname*}
214 % These macros use \cs{mathpalette}s so that they will change size
215 % in script and scriptscript styles, though it's hard to imagine they
216 % will ever be used there (the arrows, particularly, look bad in
217 % subscript sizes). Notice that the use of \cs{ex@} means that the
218 % vertical spacing may not be optimal in script and scriptscript
219 % sizes. Unfortunately \tex/ provides no easy way to do math mode
220 % vertical spacing that varies with current math style like mu units.
223 \vtop{\m@th\ialign{##\cr
224 \hfil$#1\operator@font lim$\hfil\cr
225 \noalign{\nointerlineskip\kern1.5\ex@}#2\cr
226 \noalign{\nointerlineskip\kern-\ex@}\cr}}%
229 \mathop{\mathpalette\varlim@{\rightarrowfill@\textstyle}}\nmlimits@
232 \mathop{\mathpalette\varlim@{\leftarrowfill@\textstyle}}\nmlimits@
234 \def\varliminf{\mathop{\mathpalette\varliminf@{}}\nmlimits@}
235 \def\varliminf@#1{\@@underline{\vrule\@depth.2\ex@\@width\z@
236 \hbox{$#1\m@th\operator@font lim$}}}
237 \def\varlimsup{\mathop{\mathpalette\varlimsup@{}}\nmlimits@}
238 \def\varlimsup@#1{\@@overline{\hbox{$#1\m@th\operator@font lim$}}}
242 \let\nmlimits@\displaylimits
243 \DeclareOption{namelimits}{\let\nmlimits@\displaylimits}
244 \DeclareOption{nonamelimits}{\let\nmlimits@\nolimits}
245 \ProcessOptions\relax
248 % If we don't load the \pkg{amsgen} package then the use of \cs{ex@}
249 % in \cs{varlim@} will lead to trouble.
251 \RequirePackage{amsgen}\relax
254 % The usual \cs{endinput} to ensure that random garbage at the end of
255 % the file doesn't get copied by \fn{docstrip}.
260 % \changes{v1.2a}{1995/02/20}{Fixed operatorname
261 % (shouldn't have same limits behavior as operatorname*)}