Skip to content

Instantly share code, notes, and snippets.

@lambdabetaeta
Last active February 27, 2024 14:37
Show Gist options
  • Save lambdabetaeta/b3dbc33a4241c47a2d423d1452398e57 to your computer and use it in GitHub Desktop.
Save lambdabetaeta/b3dbc33a4241c47a2d423d1452398e57 to your computer and use it in GitHub Desktop.
Generic mathematical macros
\RequirePackage{xparse}
\RequirePackage{mathtools}
\RequirePackage{jmsdelim}
%% Defining equality and equivalence
\NewDocumentCommand{\defeq}{}{\stackrel{\mathclap{\mbox{\tiny def}}}{=}}
\newcommand{\defequiv}{\stackrel{\mathclap{\mbox{\tiny def}}}{\equiv}}
%% Some bracket shorthands
\NewDocumentCommand{\prn}{m}{\DelimPrn{#1}}
\NewDocumentCommand{\brc}{m}{\DelimBrc{#1}}
\NewDocumentCommand{\brk}{m}{\DelimBrk{#1}}
\NewDocumentCommand{\gls}{m}{\DelimGl{#1}}
\NewDocumentCommand{\sem}{m}{\DelimBbrk{#1}}
%% Sets
\NewDocumentCommand{\FinSub}{}{\subseteq_\text{fin}}
\NewDocumentCommand{\SetComp}{mm}{\DelimBetweenSurround{\lbrace}{\vert}{\rbrace}{#1}{#2}}
\NewDocumentCommand{\Powerset}{so}{
\mathcal{P}\IfNoValueTF{#2}{}{
\IfBooleanTF{#1}{\DelimPrn{#2}}{#2}
}
}
%% Functions
\NewDocumentCommand{\FunctionSet}{smm}{
\IfBooleanTF{#1}{\DelimPrn{#2 \to #3}}{#2 \to #3}
}
\NewDocumentCommand{\Surj}{}{\twoheadrightarrow}
\NewDocumentCommand{\Image}{sm}{
\IfBooleanTF{#1}{\mathop{\text{im}}\DelimPrn{#2}}{\mathop{\text{im}} #2}
}
\NewDocumentCommand{\DepFun}{mmm}{\DelimPrn{#1 : #2} \to #3}
%% Lists
\NewDocumentCommand{\List}{sm}{\SuperscriptS{#1}{#2}{\ast}}
\NewDocumentCommand{\FinInfList}{sm}{\SuperscriptS{#1}{#2}{\infty}}
\NewDocumentCommand{\ListBrk}{m}{\DelimBrk{#1}}
\NewDocumentCommand{\ListComp}{mm}{\DelimBetweenSurround{[}{\vert}{]}{#1}{#2}}
\NewDocumentCommand{\EmptyList}{}{[\,]}
\NewDocumentCommand{\ConsList}{mm}{#1{:}#2}
\NewDocumentCommand{\ConcatOp}{}{\mathrel{+\!\!+}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment