latex-packages-build/math/mkessler-mathop.sty
Maximilian Keßler (via gitlab runner) a12b342fa0 add mathsymbindex package
Used to define math operators with automatic indexing
    Still in development, but fully working by now

Build branch v2.5.0 (296afc0) from kesslermaximilian/LatexPackages
2022-01-11 19:16:17 +00:00

280 lines
9.4 KiB
TeX

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright © 2022 Maximilian Keßler
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the “Software”), to deal
% in the Software without restriction, including without limitation the rights
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
% copies of the Software, and to permit persons to whom the Software is
% furnished to do so, subject to the following conditions:
% The above copyright notice and this permission notice shall be included in all
% copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
% SOFTWARE.
%
% This package has been generated by PyTeX, available at
% https://github.com/kesslermaximilian/PyTeX
% and built from source file 'mathop.pysty'.
% It is STRONGLY DISCOURAGED to edit this source file directly, since local
% changes will not be versioned by Git and overwritten by the next build. Always
% edit the source file and build the package again.
%
% Build details:
% PyTeX version: v1.2.0-11-gc8deda5 (commit c8deda5)
% Source code version: v2.5.0 (commit 296afc0)
%
% This LaTeX package is free software and distributed under the MIT License. You
% may use it freely for your purposes. The latest version of the package can be
% obtained via GitHub under
% https://github.com/kesslermaximilian/LatexPackages
% For further information see the url above.
% Reportings of bugs, suggestions and improvements are welcome, see the README
% at the Git repository for further information.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mkessler-mathop}[2022/01/11 - Math Operator Package]
%Provides some commonly used Operators used in the write-ups of my lecture notes
\RequirePackage{xkeyval}
\newif\ifmkessler@mathop@english\mkessler@mathop@englishtrue
\DeclareOptionX{german}{\mkessler@mathop@englishfalse}
\DeclareOptionX{ngerman}{\mkessler@mathop@englishfalse}
\DeclareOptionX{english}{\mkessler@mathop@englishtrue}
\DeclareOptionX*{\PackageWarning{mkessler-mathop}{Unknown '\CurrentOption'}}
\ProcessOptionsX*\relax
%%%%%Package dependencies
\RequirePackage{amsmath}
\RequirePackage{bbm}
\RequirePackage{mathtools}
%%%%Different types of operator wrappers:
% For simple math operators that are just to be printed as their name
\newcommand\DeclareSimpleMathOperator[1]{
\expandafter\providecommand\csname #1\endcsname{\operatorname{#1}}
}
%%%For distributions
%Introduce synonym for \operatorname
\newcommand\mkessler@mathop@distribution[1]{\operatorname{#1}}
%Easily declare new distributions
\newcommand\DeclareDistribution[1]{\expandafter\def\csname #1\endcsname{\mkessler@mathop@distribution{#1}}}
%%%For categories
%Introduce synonym for \operatorname
\newcommand\mkessler@mathop@category[1]{\operatorname{\textbf{#1}}}
%Easily declare new categories
\newcommand\DeclareCategory[1]{\expandafter\def\csname #1\endcsname{\mkessler@mathop@category{#1}}}
%%%%%%%%%%% Operators
%Basic commands
\DeclareSimpleMathOperator{id}
\DeclareSimpleMathOperator{im}
\DeclareSimpleMathOperator{Bild}
\DeclareSimpleMathOperator{dom}
\DeclareSimpleMathOperator{Span}
\DeclareSimpleMathOperator{Aut}
\DeclareMathOperator{\rhs}{RHS} %Right hand side of equation
\DeclareMathOperator{\lhs}{LHS} %Left hand side of equation
%%Provide \ggT \gcd \kgV \lcm for 'greatest common denominator' and 'least common multiple'
% \ggT und \gcd, as well as \kgV and \lcm are synonyms and language-aware, so that
% e.g. when the german language option is loaded, even
% \lcm would print 'kgV'
% The starred versions of the four commands will ignore the language option and print their
% exact names (without the *, of course)
\DeclareMathOperator{\@mkessler@mathop@ggT}{ggT}
\DeclareMathOperator{\@@mkessler@mathop@ggT}{\if@mkessler@mathop@english gcd\else ggT\fi}
\def\ggT{\@ifstar\@mkessler@mathop@ggT\@@mkessler@mathop@ggT}
\DeclareMathOperator{\@mkessler@mathop@gcd}{gcd}
\DeclareMathOperator{\@@mkessler@mathop@gcd}{\if@mkessler@mathop@english gcd\else ggT\fi}
\def\gcd{\@ifstar\@mkessler@mathop@gcd\@@mkessler@mathop@gcd}
\DeclareMathOperator{\@mkessler@mathop@kgV}{kgV}
\DeclareMathOperator{\@@mkessler@mathop@kgV}{\if@mkessler@mathop@english lcm\else kgV\fi}
\def\kgV{\@ifstar\@mkessler@mathop@kgV\@@mkessler@mathop@kgV}
\DeclareMathOperator{\@mkessler@mathop@lcm}{lcm}
\DeclareMathOperator{\@@mkessler@mathop@lcm}{\if@mkessler@mathop@english lcm\else kgV\fi}
\def\lcm{\@ifstar\@mkessler@mathop@lcm\@@mkessler@mathop@lcm}
%Complex numbers
\DeclareMathOperator{\mkessler@mathop@impart}{Im}
\renewcommand\Im\mkessler@mathop@impart
\DeclareMathOperator{\mkessler@mathop@repart}{Re}
\renewcommand\Re\mkessler@mathop@repart
%Linear Algebra
\DeclareSimpleMathOperator{Sym}
\DeclareSimpleMathOperator{supp}
\DeclareSimpleMathOperator{sgn}
\DeclareSimpleMathOperator{coker}
\DeclareSimpleMathOperator{rank}
\DeclareSimpleMathOperator{rk}
\DeclareSimpleMathOperator{Mat}
\DeclareSimpleMathOperator{ev}
\DeclareSimpleMathOperator{tr}
\DeclareSimpleMathOperator{GL}
\DeclareSimpleMathOperator{PGL}
%Algebra
\DeclareSimpleMathOperator{Quot}
\DeclareSimpleMathOperator{rad}
\DeclareSimpleMathOperator{Spec}
\DeclareSimpleMathOperator{Frac}
\DeclareSimpleMathOperator{Gal}
\DeclareSimpleMathOperator{Ext}
\DeclareSimpleMathOperator{Tor}
\DeclareSimpleMathOperator{MaxSpec}
\DeclareSimpleMathOperator{Sh}
\DeclareSimpleMathOperator{Proj}
\DeclareSimpleMathOperator{QCoh}
\DeclareSimpleMathOperator{Fun}
\DeclareMathOperator{\Nil}{\mathcal{N}il}
\DeclareMathOperator{\Ouv}{\mathcal{O}uv}
\DeclareMathOperator{\PreSh}{Pre-Sh}
\newcommand{\tensor}{\otimes} %Synonym for tensoring
%Analysis
\DeclareSimpleMathOperator{dx}
\DeclareSimpleMathOperator{dy}
\DeclareSimpleMathOperator{dz}
\DeclareSimpleMathOperator{dt}
%Sets
\DeclareSimpleMathOperator{conv}
\DeclareSimpleMathOperator{dist}
\DeclareSimpleMathOperator{diam}
%%Stochastic (Algorithmische Mathematik II)
\DeclareDistribution{Bin}
\DeclareDistribution{Ber}
\DeclareDistribution{Geo}
\DeclareDistribution{Poi}
\DeclareDistribution{Unif}
\DeclareDistribution{Var}
\DeclareDistribution{Cov}
%Topology
\DeclareSimpleMathOperator{pr}
\def\twedge{\vee} % Semantically correct macros for wedge product
\def\tsmash{\wedge} % Semantically correct macro for smash product
\DeclareSimpleMathOperator{sing}
\DeclareSimpleMathOperator{cell}
%Category Theory
\DeclareSimpleMathOperator{Ob}
\DeclareSimpleMathOperator{Hom}
\DeclareSimpleMathOperator{Mor}
\DeclareSimpleMathOperator{End}
\DeclareSimpleMathOperator{colim}
%Categories
\DeclareCategory{Top}
\DeclareCategory{hTop}
\DeclareCategory{Set}
\DeclareCategory{CHaus}
\DeclareCategory{Grp}
\DeclareCategory{Ab}
\DeclareCategory{CRing}
\DeclareCategory{Ring}
\DeclareCategory{Vect}
\DeclareCategory{Fin}
\DeclareCategory{Ab}
\DeclareCategory{Cat}
\DeclareCategory{Mod}
\DeclareCategory{AffVar}
\DeclareCategory{Alg}
\DeclareCategory{Field}
\DeclareCategory{GrAb}
\DeclareCategory{Sch}
%Set theory
\DeclareSimpleMathOperator{card}
\DeclareSimpleMathOperator{Cd}
\DeclareSimpleMathOperator{Ord}
\DeclareSimpleMathOperator{otp}
\DeclareSimpleMathOperator{Card}
%%Galoiskohomologie
\DeclareSimpleMathOperator{Br}
\DeclareSimpleMathOperator{EXT}
\DeclareSimpleMathOperator{Ind}
\DeclareSimpleMathOperator{Char}
\DeclareSimpleMathOperator{res}
\DeclareSimpleMathOperator{inf}
\DeclareSimpleMathOperator{cov}
\newcommand{\del}{\partial} % Semantically correct operator for boundary maps
%% Algebraic geometry
\DeclareSimpleMathOperator{eq}
\DeclareSimpleMathOperator{Idem}
\DeclareSimpleMathOperator{Supp}
\DeclareSimpleMathOperator{Ann}
\DeclareSimpleMathOperator{OC}
\DeclareSimpleMathOperator{red}
\DeclareSimpleMathOperator{can}
\DeclareSimpleMathOperator{Pic}
\newcommand\leftadjoint\vdash
\newcommand\rightadjoint\dashv
% Characteristic function
\newcommand*{\cfun}{\ensuremath{\mathbbm{1}}}
\newcommand*{\One}{\cfun}
%Paired Delimiters
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
%Norm and absolute value
%Make them scaling by default and have \abs*{} as the non-scaling version of the command
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\let\oldabs\abs
\def\abs{\@ifstar{\oldabs}{\oldabs*}}
\DeclarePairedDelimiter\norm{\lVert}{\rVert}
\let\oldnorm\norm
\def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
\DeclareMathOperator{\amalgprod}{\star}
\newcommand\op{\text{op}}
\newcommand\opposite{^{\op}}
\newcommand\ab{\text{ab}}
\newcommand\abelianization{^{\ab}}
%Taken from user egreg on
% https://tex.stackexchange.com/a/22255
\newcommand\frestriction[2]{{% we make the whole thing an ordinary symbol
\left.\kern-\nulldelimiterspace % automatically resize the bar with \right
#1 % the function
\vphantom{\big|} % pretend it's a little taller at normal size
\right|_{#2} % this is the delimiter
}}
\newcommand\directlimit{\varinjlim}
\newcommand\inverselimit{\varprojlim}
\DeclareMathOperator*{\freeproduct}{\raisebox{-0.5ex}{\scalebox{2}{$\ast$}}}