\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mkessler-math}[2021/03/31 - Math package]
%%%%%%Provides the basic math packages used for my lecture-note write-ups

%The language to pass to babel
\newif\ifenglish\englishtrue
\DeclareOption{german}{\englishfalse}
\DeclareOption{english}{\englishtrue}

%If beamer shall be activated
\newif\ifbeamer\beamerfalse
\DeclareOption{beamer}{\beamertrue}
\DeclareOption{nobeamer}{\beamerfalse}

%Options for onehalf-spacing of lines
\newif\ifonehalfspacing\onehalfspacingfalse %default is normalspace
\DeclareOption{onehalfspacing}{\onehalfspacingtrue}
\DeclareOption{normalspacing}{\onehalfspacingfalse}

%Options for utf8 or utf8x - encoding
\newif\ifutf\utftrue %by default, utf8 is not enabled
\DeclareOption{utf8x}{\utffalse}
\DeclareOption{utf8}{\utftrue}

\DeclareOption*{\PackageWarning{mkessler-math}{Unknown '\CurrentOption'}}
\ProcessOptions\relax


\RequirePackage[\ifenglish english \else ngerman\fi]{babel}
\RequirePackage[T1]{fontenc}

% When using utf8x, we have to load ucs and inputenc with utf8x option and must exclude bibtex
% When not using utf8x (plan utf8), we must NOT load ucs, and then load inputenc with utf8-option as well as bibtex
% also, when using plain utf8, we want to load the newunicodechar package
\RequirePackage[\ifutf utf8\else utf8x\fi]{inputenc}
\ifutf
\RequirePackage{newunicodechar}
\newunicodechar{α}{\ensuremath\alpha}
\newunicodechar{β}{\ensuremath\beta}
\newunicodechar{γ}{\ensuremath\gamma}
\newunicodechar{δ}{\ensuremath\delta}
\newunicodechar{ε}{\ensuremath\epsilon}
\newunicodechar{ζ}{\ensuremath\zeta}
\newunicodechar{η}{\ensuremath\eta}
\newunicodechar{θ}{\ensuremath\theta}
\newunicodechar{ι}{\ensuremath\iota}
\newunicodechar{κ}{\ensuremath\kappa}
\newunicodechar{λ}{\ensuremath\lambda}
\newunicodechar{μ}{\ensuremath\mu}
\newunicodechar{ν}{\ensuremath\nu}
\newunicodechar{ξ}{\ensuremath\xi}
\newunicodechar{π}{\ensuremath\pi}
\newunicodechar{ρ}{\ensuremath\rho}
\newunicodechar{σ}{\ensuremath\sigma}
\newunicodechar{τ}{\ensuremath\tau}
\newunicodechar{υ}{\ensuremath\upsilon}
\newunicodechar{φ}{\ensuremath\phi}
\newunicodechar{χ}{\ensuremath\chi}
\newunicodechar{ψ}{\ensuremath\psi}
\newunicodechar{ω}{\ensuremath\omega}

\RequirePackage[backend=biber,style=alphabetic]{biblatex}
\RequirePackage{csquotes}
\else
\RequirePackage[mathletters]{ucs}
\fi

\RequirePackage{anyfontsize}
\RequirePackage{lmodern}
\RequirePackage{etoolbox}
\RequirePackage{amsmath}
\RequirePackage{mathtools}
\RequirePackage{amsthm}
\RequirePackage{amssymb}
\RequirePackage{comment}
\RequirePackage{soul}
\RequirePackage{caption}
\RequirePackage{subcaption}
\RequirePackage{latexsym}
\RequirePackage{mathrsfs}
\ifbeamer\else
\RequirePackage[shortlabels]{enumitem}
\fi
\RequirePackage{wrapfig}

%Pgfplots
\RequirePackage{pgfplots}
\pgfplotsset{compat=1.7}

% TIKZ
\RequirePackage{tikz}
\usetikzlibrary{calc, intersections, through, quotes, angles, babel, positioning, snakes}
%\RequirePackage{tkz-euclide}
\RequirePackage[export]{adjustbox}
%Commutative diagrams
\RequirePackage{tikz-cd}

%%for small diagrams, similar to tikz-cd
\usepackage{xy}        % for small diagrams, e.g. arrows
\xyoption{all}

%%Theorems needed in any case (fancy or not fancy theorems)

% Für Formeln
\RequirePackage{mathabx}
\RequirePackage{faktor}
\RequirePackage[mathscr]{eucal}

\RequirePackage{blindtext}
\RequirePackage{tabto}
\RequirePackage{lastpage} %\pageref{LastPage} for reference on the last page

% Für Tabulatoren

\RequirePackage{pdfpages} % PDF-Dateien einbinden

% Für Zeilenumbruch
\RequirePackage{microtype}
\RequirePackage{changepage}


%Für Zeilenabstand 1,5
\ifonehalfspacing
\RequirePackage[onehalfspacing]{setspace} \else
\fi

%For setting counters of itemns in \enemerate
\makeatletter
\newcommand\setItemnumber[1]{\setcounter{enum\romannumeral\@enumdepth}{\numexpr#1-1\relax}}
\makeatother

%Make circled symbols
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}

%Print a warning sign
\newcommand\Warning{%
 \makebox[1.4em][c]{%
 \makebox[0pt][c]{\raisebox{.1em}{\small!}}%
 \makebox[0pt][c]{\color{red}\Large$\bigtriangleup$}}}%

 % Add \contra symbol to denote contradiction (from Gilles Castell)
\usepackage{stmaryrd} % for \lightning
\newcommand\contra{\scalebox{1.5}{$\lightning$}}

%\def\thevocab{}
%\newcommand{\vocab}[2][\thevocab]{\renewcommand\thevocab{#2}\textbf{\color{blue} #2}\index{#1}}

\newcommand{\emphasize}[1]{{\color{red} #1}}


%Short commands for \mathbb{}
\newcommand{\C}{\ensuremath{\mathbb{C}}}
\newcommand{\F}{\ensuremath{\mathbb{F}}}
\newcommand{\K}{\ensuremath{\mathbb{K}}}
\newcommand{\N}{\ensuremath{\mathbb{N}}}
\newcommand{\Q}{\ensuremath{\mathbb{Q}}}
\newcommand{\R}{\ensuremath{\mathbb{R}}}
\newcommand{\Z}{\ensuremath{\mathbb{Z}}}

%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}
\makeatletter
\let\oldabs\abs
\def\abs{\@ifstar{\oldabs}{\oldabs*}}

\DeclarePairedDelimiter\norm{\lVert}{\rVert}
\let\oldnorm\norm
\def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
\makeatother

%Fixes of common misbehaviour
\renewcommand{\degree}{^\circ}

%Used to start an exercise and resetting the equation number
%\newcommand{\nr}[1]{\setcounter{equation}{0}\section*{\ifenglish Exercise \else Aufgabe \fi #1}~}


\RequirePackage{esint}

\RequirePackage{IEEEtrantools}

\RequirePackage[ngerman,ruled,vlined]{algorithm2e}


%%Load additional operators
\RequirePackage{mkessler-operators}

