diff --git a/math/mkessler-math.sty b/math/mkessler-math.sty index 6cc8e07..5ed8838 100644 --- a/math/mkessler-math.sty +++ b/math/mkessler-math.sty @@ -15,12 +15,6 @@ %%%% Import the other custom math packages \RequirePackage{mkessler-mathfonts} % Load this first to ensure untouched fonts -\RequirePackage{mkessler-faktor} -\RequirePackage[\if@mkessler@math@english english\else german\fi]{mkessler-operators} -\RequirePackage{mkessler-mathfig} -\RequirePackage{mkessler-mathsymb} -\RequirePackage{mkessler-unicodechar} -\RequirePackage{mkessler-mathfixes} % Load this last since it renews behaviour \RequirePackage{amsmath} \RequirePackage{mathtools} @@ -36,13 +30,13 @@ \RequirePackage{IEEEtrantools} \RequirePackage[ngerman,ruled,vlined]{algorithm2e} -%%% Custom commands -%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}}} +%%% Importing other custom packages +\RequirePackage{mkessler-faktor} +\RequirePackage{mkessler-mathsymb} +\RequirePackage[basic]{mkessler-mathalias} +% mkessler-mathfonts has already been imported +\RequirePackage[\if@mkessler@math@english english\else german\fi]{mkessler-operators} +\RequirePackage{mkessler-mathfig} +\RequirePackage{mkessler-unicodechar} +\RequirePackage{mkessler-mathfixes} % Load this last since it renews behaviour diff --git a/math/mkessler-mathalias.sty b/math/mkessler-mathalias.sty new file mode 100644 index 0000000..d531651 --- /dev/null +++ b/math/mkessler-mathalias.sty @@ -0,0 +1,46 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{mkessler-mathalias}[2021/09/09 Easy aliasing for math style commands] + +%%%%%% + +\newif\ifmkessler@mathalias@basic\mkessler@mathalias@basicfalse +\DeclareOption{basic}{\mkessler@mathalias@basictrue} + +\newif\ifmkessler@mathalias@extended\mkessler@mathalias@extendedfalse +\DeclareOption{extended}{\mkessler@mathalias@extendedtrue\mkessler@mathalias@basictrue} + +\DeclareOption*{\PackageWarning{mkessler-mathalias}{Unknown '\CurrentOption'}} +\ProcessOptions\relax + +%Usage: \makealiasesforwith\{}{} +% to declare commands of form \ as \{} for each +% of the specfied letters +% +% E.g. \makealiasesforwith\mathcal{c}{ABC} will declare +% \cA \cB \cC \cD as \mathcal{A}, \mathcal{B}, \mathcal{C} +% This is also ensuring math context, so that +% \cA will be valid even in normal text. + +\def\makealiasesforwith#1#2#3{ + \def\mkessler@aliases@makealias##1{ + \expandafter\def\csname #2##1\endcsname{\ensuremath{#1{##1}}} + } + \def\mkessler@aliases@recurse##1{ + \ifx##1\mkessler@dummy\else + \mkessler@aliases@makealias{##1}\expandafter\mkessler@aliases@recurse\fi + } + \mkessler@aliases@recurse #3\mkessler@dummy +} + +\def\mkessler@mathalias@all{ABCDEFGHIJKLMNOPQRSTUVWXYZ} + +\ifmkessler@mathalias@basic + \RequirePackage{amsfonts} + \makealiasesforwith\mathbb{}{CFKNQRZ} +\fi + +\ifmkessler@mathalias@extended + \expandafter\makealiasesforwith\expandafter\mathcal\expandafter{\expandafter c\expandafter}\expandafter{\mkessler@mathalias@all} + \expandafter\makealiasesforwith\expandafter\mathfrak\expandafter{\expandafter f\expandafter}\expandafter{\mkessler@mathalias@all} +\fi +