LaTeX Resources

Common Requirements
\usepackage{xparse}
Algebra
alt-group
\DeclareDocumentCommand\altgroup{m}{\mathcal{A}_{#1}}
sym-group
\DeclareDocumentCommand\symgroup{m}{\mathcal{S}_{#1}}
Asymptotics
order-big-O
\DeclareDocumentCommand\orderO{o}{\mathcal{O}\IfValueTF{#1}{\left(#1\right)}{}}
order-little-o
\DeclareDocumentCommand\ordero{o}{o\IfValueTF{#1}{\left(#1\right)}}
order-omega
\DeclareDocumentCommand\orderOmega{o}{\Omega\IfValueTF{#1}{\left(#1\right)}{}}
order-poly
\DeclareDocumentCommand\orderPoly{m}{\operatorname{poly}\left(#1\right)}
order-small-omega
\DeclareDocumentCommand\orderomega{m}{\omega\left(#1\right)}
order-theta
\DeclareDocumentCommand\orderTheta{o}{\Theta\IfValueTF{#1}{\left(#1\right)}}
Basics
bincoeff
\DeclareDocumentCommand\bincoeff{mm}{\genfrac{(}{)}{0pt}{}{#1}{#2}}
card
\DeclareDocumentCommand\card{m}{\left|#1\right|}
disjoint-union
\DeclareDocumentCommand\dcup{}{\cupdot}
encoding-length
\DeclareDocumentCommand\enclen{m}{\left<#1\right>}
encoding
\DeclareDocumentCommand\encoding{m}{\llcorner#1\lrcorner}
set
\DeclareDocumentCommand\setdef{mo}{\left\{#1\IfNoValueTF{#2}{}{ : #2}\right\}}
Calculus
gradient
\DeclareDocumentCommand\grad{mm}{\operatorname{grad}_{#1}\left(#2\right)}
Complexity
complexity-MAXSNP
\DeclareDocumentCommand\cplxMAXSNP{}{\mathsf{MAXSNP}}
complexity-NP
\DeclareDocumentCommand\cplxNP{}{\mathsf{NP}}
complexity-P
\DeclareDocumentCommand\cplxP{}{\mathsf{P}}
complexity-coNP
\DeclareDocumentCommand\cplxcoNP{}{\mathsf{coNP}}
karp-reduction
\DeclareDocumentCommand\leqkarp{}{\mathop{\preceq_{\mathsf{P}}}}
Environments
tag-block
\DeclareDocumentEnvironment{tagblock}{mmo}{
  \newlength{\tagblockwidth} \newlength{\tagblocksep} \settowidth{\tagblockwidth}{(#1)}
  \IfValueTF{#3}{\setlength{\tagblocksep}{#3}}{\setlength{\tagblocksep}{0mm}}
  \par\noindent \parbox{\tagblockwidth}{\begin{align}\tag{#1}#2\end{align}}
  \hfill \begin{minipage}{\linewidth-\tagblockwidth-\tagblocksep-5mm}
}{\end{minipage} \vspace{1em}}
Graphs
in-arcs
\DeclareDocumentCommand\inarcs{m}{\delta^{\text{in}}\left(#1\right)}
in-neighbors
\DeclareDocumentCommand\inneigh{m}{\operatorname{N}^-\left(#1\right)}
neighbors
\DeclareDocumentCommand\neigh{m}{\operatorname{N}\left(#1\right)}
out-arcs
\DeclareDocumentCommand\outarcs{m}{\delta^{\text{out}}\left(#1\right)}
out-neighbors
\DeclareDocumentCommand\outneigh{m}{\operatorname{N}^+\left(#1\right)}
star-edges
\DeclareDocumentCommand\staredges{m}{\delta\left(#1\right)}
Linear Algebra
affine-hull
\DeclareDocumentCommand\aff{o}{\operatorname{aff}\IfValueTF{#1}{\left(#1\right)}{}}
boundary
\DeclareDocumentCommand\bd{o}{\operatorname{bd}\IfValueTF{#1}{\left(#1\right)}{}}
closure
\DeclareDocumentCommand\cl{o}{\operatorname{cl}\IfValueTF{#1}{\left(#1\right)}{}}
columns
\DeclareDocumentCommand\cols{o}{\operatorname{cols}\IfValueTF{#1}{\left(#1\right)}{}}
conic-hull
\DeclareDocumentCommand\cone{o}{\operatorname{cone}\IfValueTF{#1}{\left(#1\right)}{}}
convex-conic-hull
\DeclareDocumentCommand\ccone{o}{\operatorname{ccone}\IfValueTF{#1}{\left(#1\right)}{}}
convex-hull
\DeclareDocumentCommand\conv{o}{\operatorname{conv}\IfValueTF{#1}{\left(#1\right)}{}}
dehomogenize
\DeclareDocumentCommand\dehomog{o}{\operatorname{dehomog}\IfValueTF{#1}{\left(#1\right)}{}}
determinant
\DeclareDocumentCommand\det{o}{\operatorname{det}\IfValueTF{#1}{\left(#1\right)}{}}
dimension
\DeclareDocumentCommand\dim{o}{\operatorname{dim}\IfValueTF{#1}{\left(#1\right)}{}}
direction-space
\DeclareDocumentCommand\dir{o}{\operatorname{dir}\IfValueTF{#1}{\left(#1\right)}{}}
equation-set
\DeclareDocumentCommand\eqnset{om}{\IfValueTF{#1}{\mathop{\text{Eq}}_{#1}}{\mathop{\text{Eq}}}\left(#2\right)}
homogenize
\DeclareDocumentCommand\homog{o}{\operatorname{homog}\IfValueTF{#1}{\left(#1\right)}{}}
identity-matrix
\DeclareDocumentCommand\idmat{o}{\IfNoValueTF{#1}{\mathbb{I}}{\mathbb{I}_{#1}}}
image
\DeclareDocumentCommand\im{o}{\operatorname{im}\IfValueTF{#1}{\left(#1\right)}{}}
interior
\DeclareDocumentCommand\int{o}{\operatorname{int}\IfValueTF{#1}{\left(#1\right)}{}}
kernel
\DeclareDocumentCommand\ker{o}{\operatorname{ker}\IfValueTF{#1}{\left(#1\right)}{}}
lineality-space
\DeclareDocumentCommand\lineal{o}{\operatorname{lineal}\IfValueTF{#1}{\left(#1\right)}{}}
linear-hull
\DeclareDocumentCommand\lin{o}{\operatorname{lin}\IfValueTF{#1}{\left(#1\right)}{}}
one-vector
\DeclareDocumentCommand\onevec{o}{\IfNoValueTF{#1}{\mathbbm{1}}{\mathbbm{1}_{#1}}}
polar
\DeclareDocumentCommand\polar{m}{#1^{\circ}}
projection
\DeclareDocumentCommand\proj{oo}{\IfValueTF{#1}{\operatorname{proj}{}_{#1}}{%
  \operatorname{proj}{}}\IfValueTF{#2}{\left(#2\right)}{}}
psd-matrices
\DeclareDocumentCommand\psdmat{m}{\mathbbm{S}^{#1}_+}
rank
\DeclareDocumentCommand\rank{o}{\operatorname{rank}\IfValueTF{#1}{\left(#1\right)}{}}
rows
\DeclareDocumentCommand\rows{o}{\operatorname{rows}\IfValueTF{#1}{\left(#1\right)}{}}
scalar-product
\DeclareDocumentCommand\scalprod{mm}{\left<#1,#2\right>}
sec-order-cone
\DeclareDocumentCommand\socone{m}{\mathbb{L}^{#1}}
sign
\DeclareDocumentCommand\sgn{o}{\operatorname{sgn}\IfValueTF{#1}{\left(#1\right)}{}}
support
\DeclareDocumentCommand\supp{o}{\operatorname{supp}\IfValueTF{#1}{\left(#1\right)}{}}
sym-matrices
\DeclareDocumentCommand\symmat{m}{\mathbbm{S}^{#1}}
trace
\DeclareDocumentCommand\tr{o}{\operatorname{tr}\IfValueTF{#1}{\left(#1\right)}{}}
transpose
\DeclareDocumentCommand\transpose{m}{#1^{\intercal}}
unit-vector
\DeclareDocumentCommand\unitvec{m}{\mathbbm{e}_{#1}}
zero-vector
\DeclareDocumentCommand\zerovec{o}{\IfNoValueTF{#1}{\mathbb{O}}{\mathbb{O}_{#1}}}
Polyhedra
ext-complexity
\DeclareDocumentCommand\xc{o}{\operatorname{xc}\IfValueTF{#1}{\left(#1\right)}{}}
normal-cone
\DeclareDocumentCommand\normalCone{mm}{\operatorname{N}_{#1}\left(#2\right)}
poly-faces
\DeclareDocumentCommand\polyFaces{o}{\mathop{\mathcal{F}}\IfValueTF{#1}{\left(#1\right)}{}}
poly-facets
\DeclareDocumentCommand\polyFacets{o}{\mathop{\widehat{\mathcal{F}}}\IfValueTF{#1}{\left(#1\right)}{}}
poly-lattice
\DeclareDocumentCommand\polyLattice{o}{\mathop{\mathcal{L}}\IfValueTF{#1}{\left(#1\right)}{}}
poly-vertices
\DeclareDocumentCommand\polyVerts{o}{\mathop{\mathcal{V}}\IfValueTF{#1}{\left(#1\right)}{}}
radial-cone
\DeclareDocumentCommand\radialCone{mm}{\operatorname{K}_{#1}\left(#2\right)}
Sets
complex
\DeclareDocumentCommand\C{}{\mathbb{C}}
integers
\DeclareDocumentCommand\Z{}{\mathbb{Z}}
naturals
\DeclareDocumentCommand\N{}{\mathbb{N}}
rationals
\DeclareDocumentCommand\Q{}{\mathbb{Q}}
reals
\DeclareDocumentCommand\R{}{\mathbb{R}}
Stochastics
expectation
\DeclareDocumentCommand\expect{mo}{\mathbb{E}\left[#1\IfValueTF{#2}{\,\middle|\,#2}{}\right]}
probability
\DeclareDocumentCommand\prob{mo}{\mathbb{P}\left[#1\IfValueTF{#2}{\,\middle|\,#2}{}\right]}
variance
\DeclareDocumentCommand\variance{o}{\operatorname{Var}\IfValueTF{#1}{\left(#1\right)}{}}
Technial Commands
input-options
\ProvideDocumentCommand\inputOptions{mo}{
  {\IfNoValueTF{#2}
  { \edef\keyValueParams{} }
  { \edef\keyValueParams{#2} }
  \def\pgfeqkeys [##1] %
    {\def\tikzPath{/options} \expandafter\pgfqkeys\expandafter{\expandafter\tikzPath\expandafter}\expandafter{##1}}
  \def\parseOptions {\expandafter\pgfeqkeys[\keyValueParams] }
  \input{#1}
}}