From 281626481cc1819f4abca9e7aa2388973e61a1d4 Mon Sep 17 00:00:00 2001 From: Christopher Spinrath Date: Thu, 28 Jun 2018 12:14:21 +0200 Subject: [PATCH] Introduce \newoperator \newoperator mimics amsamth's \DeclareMathOperator; that is, it defines a macro for an operator name which is consistent with the standard operators like \max, \lim, and \lim w.r.t. appearance and behavior. The star variant \newoperator* permits the operator to take limits like \max and \lim (e.g. \lim_{x\rightarrow\infty}) instead of a subscript. --- newnotation.sty | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/newnotation.sty b/newnotation.sty index 88d53b9..35974fd 100755 --- a/newnotation.sty +++ b/newnotation.sty @@ -671,7 +671,46 @@ \@NNAddEntry{#3}{\string#3}{#4}{#7}{#8}% } - +% ************************************* +% \newoperator +% ************************************* +% Define macro for an operator name and add entry to current group. +% +% Arguments: +% 1. star: use limits (like \max or \lim) +% 2. optional: class name +% 3. mandatory: macro name +% 4. optional: IGNORED +% 5. optional: IGNORED +% 6. mandatory: replacement +% 7. optional: description for table of notation +% 8. optional: description of arguments for table of notation +\DeclareDocumentCommand{\newoperator}{s o m O{0} o m O{} O{}}{% + % Check whether macro is already defined: + \ifdef{#3}% + {\PackageError{newnotation}{newoperator: Command '\string#3' already defined.}{Misspelled name?}}{}% + % + \@NNPrepareEntry{\string#3}% + \newrobustcmd{#3}[#4]{% + \IfNoValueTF{#2}% + % CLASS: no -------------------------------------------- + %{no class defined}{class defined} + {\IfBooleanTF{#1}% + % STAR: yes + {\ensuremath{\operatorname*{#6}}}% + % STAR: no + {\ensuremath{\operatorname{{#6}}}}}% + % CLASS: yes ------------------------------------------- + {\IfBooleanTF{#1}% + % STAR: yes + {\ensuremath{\operatorname*{\@nameuse{@NNClass#2}{#6}}}}% + % STAR: no + {\ensuremath{\operatorname{\@nameuse{@NNClass#2}{#6}}}}}% + \ifthenelse{\boolean{@NNInListMode}}{}{\protect\stepcounter{@NNCounter\string#3}}% + \xspace% + }% + \@NNAddEntry{#3}{\string#3}{0}{#7}{#8}% +} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \makeatother %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%