Skip to content
Snippets Groups Projects
basics.sty 7.82 KiB
Newer Older
  • Learn to ignore specific revisions
  • Dennis Müller's avatar
    Dennis Müller committed
    \newcommand{\tb}{\hspace*{.5cm}}
    \newcommand{\tbiff}{\tb\miff\tb}
    \newcommand{\tbimpl}{\tb\impl\tb}
    \newcommand{\mpag}[2]{\begin{minipage}{#1}#2\end{minipage}}
    \newcommand{\mpage}[1]{\begin{minipage}{\textwidth}#1\end{minipage}}
    
    % shortcut for centered tabular
    \newenvironment{ctabular}[1]{\begin{center}\begin{tabular}{#1}}{\end{tabular}\end{center}}
    
    \newenvironment{tabularfigure}[3]
     {\def\@mycaption{#2}\def\@mylabel{#3}\begin{figure}[htb]\centering\begin{tabular}{#1}}
     {\end{tabular}\caption{\@mycaption}\label{\@mylabel}\end{figure}}
    
    % wrap this around multiple calls to \footnotetext if there were multiple \footnotemark's to get the right numbering
    \newenvironment{multfootnotetext}[1]{\addtocounter{footnote}{-#1}\let\basics@footnotetext=\footnotetext\renewcommand{\footnotetext}[1]{\stepcounter{footnote}\basics@footnotetext{##1}}}{}
    
    %change figure/table placement
    % General parameters, for ALL pages:
    %\renewcommand{\topfraction}{0.9}	% max fraction of floats at top
    %\renewcommand{\bottomfraction}{0.8}	% max fraction of floats at bottom
    %Parameters for TEXT pages (not float pages):
    \setcounter{topnumber}{2}
    %\setcounter{bottomnumber}{2}
    %\setcounter{totalnumber}{4}     % 2 may work better
    %\setcounter{dbltopnumber}{2}    % for 2-column pages
    %\renewcommand{\dbltopfraction}{0.9}	% fit big float above 2-col. text
    %\renewcommand{\textfraction}{0.07}	% allow minimal text w. figs
    %Parameters for FLOAT pages (not text pages):
    %\renewcommand{\floatpagefraction}{0.7} % N.B.: floatpagefraction MUST be less than topfraction !!
    %\renewcommand{\dblfloatpagefraction}{0.7}
    % remember to use [htp] or [htpb] for placement
    
    % ifnonempty{a}{b} = if (a == empty) empty else b
    \newcommand{\ifnonempty}[3][]{\def\@empty{}\def\@test{#2}\ifx\@test\@empty#1\else#3\fi}
    % fold{a}{b1,...,bn} = b1 a ... a bn
    \newcommand{\fold}[2]{\def\@tmpop{\relax}\@for\@I:=#2\do{\@tmpop\@I\def\@tmpop{#1}}}
    % rep{n}{a} = a ... a (n times)
    \newcounter{loopcount}
    \newcommand{\ntimes}[2]{\setcounter{loopcount}{#1}\loop\ifnum\theloopcount>0#2\addtocounter{loopcount}{-1}\repeat}
    
    \renewcommand{\epsilon}{\varepsilon}
    \renewcommand{\phi}{\varphi}
    \renewcommand{\theta}{\vartheta}
    \newcommand{\N}{\mathbb{N}}
    \newcommand{\n}{\mathbb{N}^*}
    \newcommand{\R}{\mathbb{R}}
    \newcommand{\Q}{\mathbb{Q}}
    \newcommand{\Z}{\mathbb{Z}}
    \newcommand{\C}{\mathbb{C}}
    \newcommand{\B}{\mathbb{B}}
    \newcommand{\app}{\approx}
    \newcommand{\sq}{\subseteq}
    \newcommand{\impl}{\Rightarrow}
    \newcommand{\Arr}{\Rightarrow}
    \newcommand{\Darr}{\Leftrightarrow}
    \newcommand{\arr}{\rightarrow}
    \newcommand{\larr}{\leftarrow}
    \newcommand{\darr}{\leftrightarrow}
    \newcommand{\harr}{\hookrightarrow}
    \newcommand{\marr}{\mapsto}
    \newcommand{\caret}{\hat{\;}}
    %\renewcommand{\nin}{\not\in}
    \newcommand{\sm}{\setminus}
    \newcommand{\es}{\varnothing}
    \newcommand{\pwr}{\mathcal{P}}
    \newcommand{\rewrites}{\rightsquigarrow}
    
    %semantics of genfrac: #1, #2 delimiters; #3 line tickness; #4 scriptsize (0-3); #5, #6 items
    \newcommand{\myatop}[3][]{\genfrac{}{}{0pt}{#1}{#2}{#3}} %two items on top of each other, optional argument: 0-3 for normal-small script
    \newcommand{\myatopp}[3]{\myatop{\myatop[0]{#1}{#2}}{#3}} %three items on top of each other
    \newcommand{\myatoppp}[4]{\myatop{\myatop[0]{\myatop[0]{#1}{#2}}{#3}}{#4}} %four items on top of each other
    \newcommand{\ov}[1]{\overline{#1}}
    \newcommand{\und}[1]{\underline{#1}}
    \newcommand{\cas}[1]{\begin{cases}#1\end{cases}}
    \newcommand{\bcas}[1]{\left.\cas{#1}\right\}}
    \newcommand{\mifc}{&\mathrm{if}\;}
    \newcommand{\mothw}{&\mathrm{otherwise}}
    \newcommand{\mathll}[2][l]{\providecommand{\nl}[1][.2cm]{\\[##1]}\begin{array}{#1}#2\end{array}}
    \newcommand{\eqns}[2][=]{\providecommand{\nl}[1][.2cm]{\\[##1]}\begin{array}{l@{\;#1\;}l@{\tb}l}#2\end{array}}
    \newcommand{\Ceq}[1]{\;\stackrel{#1}{=}\;}
    \newcommand{\op}[1]{\mathit{#1}}
    \newenvironment{myeqnarray}[1][=] %\nl for new line right of the = symbol
     {\newcommand{\nl}{\\\multicolumn{1}{c}{}&}\begin{equation*}\begin{array}{l@{\;#1\;}l@{\tb}l}}
     {\end{array}\end{equation*}}
    \newcommand{\rul}[3][]{\cfrac{#2}{#3}\,#1}
    % column vector \vect{a\\b\\c}
    \newcommand{\vect}[1]{\left(\begin{array}{c}#1\end{array}\right)}
    
    % code for defining LFS-style flexary commands: \curriedvec{3}{a}{b}{c}
    %\newcount\foldindex
    %\newcommand{\curriedvec}[1]{\left(\array{c}\global\foldindex#1\curriedvec@next}
    %\newcommand{\curriedvec@next}[1]{#1\global\advance\foldindex-1\ifnum\foldindex>1\\\expandafter\curriedvec@next\else\endarray\right)\fi}
    
    %Mathematical Text
    \newcommand{\mof}{\;\mathrm{of}\;}
    \newcommand{\mif}{\;\mathrm{if}\;}
    \newcommand{\mthen}{\;\mathrm{then}\;}
    \newcommand{\mfor}{\;\mathrm{for}\;}
    \newcommand{\mand}{\;\mathrm{and}\;}
    \newcommand{\msome}{\;\mathrm{some}\;}
    \newcommand{\mall}{\;\mathrm{all}\;}
    \newcommand{\mforall}{\;\mathrm{for}\;\mathrm{all}\;}
    \newcommand{\mforsome}{\;\mathrm{for}\;\mathrm{some}\;}
    \newcommand{\mnot}{\;\mathrm{not}\;}
    \newcommand{\mno}{\;\mathrm{no}\;}
    \newcommand{\mor}{\;\mathrm{or}\;}
    \newcommand{\minn}{\;\mathrm{in}\;}
    \newcommand{\mwith}{\;\mathrm{with}\;}
    \newcommand{\mwhere}{\;\mathrm{where}\;}
    \newcommand{\mexists}{\;\mathrm{exists}\;}
    \newcommand{\miff}{\;\mathrm{iff}\;}
    \newcommand{\mimplies}{\;\mathrm{implies}\;}
    \newcommand{\msuchthat}{\;\mathrm{such}\;\mathrm{that}\;}
    \newcommand{\motherwise}{\;\mathrm{otherwise}\;}
    \newcommand{\mtext}[1]{\;\mathrm{#1}\;}
    
    %categories, general
    \newcommand{\id}[1]{\op{id}_{#1}}
    %\newcommand{\�}[2]{{#2}\circ {#1}}
    \newcommand{\oo}[3]{{#3}\circ {#2}\circ {#1}}
    \newcommand{\ooo}[4]{{#4}\circ {#3}\circ {#2}\circ {#1}}
    \newcommand{\obj}[1]{|#1|}
    \newcommand{\sli}[2]{#1\backslash #2}
    \newcommand{\slii}[2]{#1/#2}
    \newcommand{\catop}[1]{{{#1}^{op}}}
    
    \newcommand{\catfont}[1]{\mathcal{#1}}
    \newcommand{\Set}{\catfont{SET}}
    \newcommand{\Cat}{\catfont{CAT}}
    \newcommand{\Poset}{\catfont{POSET}}
    \newcommand{\Rel}{\catfont{REL}}
    \newcommand{\Class}{\catfont{CLASS}}
    \newcommand{\Ins}{\catfont{INS}}
    \newcommand{\Logics}{\catfont{LOG}}
    
    %for tikz
    \newcommand{\arrowtip}{angle 45}
    \newcommand{\arrowtipepi}{triangle 45}
    \newcommand{\arrowtipmono}{right hook}
    \newcommand{\refledge}[2]{(#1) .. controls +(-.5,.75) and +(.5,.75) .. node[above]{#2} (#1)} % reflexive edge
    
    %institutions
    \newcommand{\I}{\mathbb{I}}
    \newcommand{\insfont}[1]{\mathbf{#1}}
    \newcommand{\Sig}[1][]{{\insfont{Sig}^{#1}}}
    \newcommand{\Con}[1][]{{\insfont{Con}^{#1}}}
    \newcommand{\Sen}[1][]{{\insfont{Sen}^{#1}}}
    \newcommand{\Mod}[1][]{{\insfont{Mod}^{#1}}}
    \newcommand{\Pf}[1][]{{\insfont{Pf}\,^{#1}}}
    \newcommand{\Th}[1][]{{\insfont{Th}^{#1}}}
    \newcommand{\Syn}[1][]{{\insfont{Syn}^{#1}}}
    \newcommand{\Jud}[1][]{{\insfont{Jud}^{#1}}}
    
    \newcommand{\der}{\vdash}
    \newcommand{\dera}[4][]{#2\der^{#1}_{#3}#4}
    \newcommand{\moda}[4][]{#2\models^{#1}_{#3}#4}
    \newcommand{\nmoda}[4][]{#2\not\models^{#1}_{#3}#4}
    
    % CFGs
    \newenvironment{grammar}{\[\begin{array}{l@{\tb\bbc\tb}l@{\tb}l}}{\end{array}\]}
    \newcommand{\bnf}[1]{#1}
    \newcommand{\bbc}{\bnf{::=}}
    \newcommand{\bnfalt}{\ensuremath{\;\bnf{|}\;}}
    \providecommand{\alt}{\ensuremath{\;\bnf{|}\;}} % already used by beamer
    \newcommand{\opt}[1]{\bnf{[}#1\bnf{]}}
    \newcommand{\bnfbracket}[1]{\bnf{(}#1\bnf{)}}
    \newcommand{\rep}[1]{#1^{\bnf{\ast}}}
    \newcommand{\bnfchoice}[1]{\bnf{[}#1\bnf{]}}
    \newcommand{\bnfnegchoice}[1]{\bnf{[\caret}#1\bnf{]}}
    
    \newenvironment{commgrammar}{\[\begin{array}{l@{\;}c@{\;}l@{\tb}l}}{\end{array}\]}
    \newcommand{\gcomment}[1]{\multicolumn{4}{l}{\rule{0pt}{4ex}\fbox{#1}\vspace{.3em}}}
    \newcommand{\gprod}[3]{#1 & \bbc & #2 & \text{#3}}
    \newcommand{\galtprod}[2]{ & \bnf{|} & #1 & \text{#2}}
    
    
    \RequirePackage{xspace}
    \newcommand{\mmt}{\texorpdfstring{{\normalfont\scshape{Mmt}}\xspace}{MMT\ }}
    \newcommand{\omdoc}{{\scshape{OMDoc}}\xspace}
    \newcommand{\mathml}{{\scshape{MathML}}\xspace}
    \newcommand{\openmath}{{\scshape{OpenMath}}\xspace}