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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%