tame/design/tpl/tpl.sty

166 lines
4.7 KiB
TeX

% The TAME Programming Language glossary
%
% Copyright (C) 2021 Ryan Specialty Group, LLC.
%
% Licensed under the Creative Commons Attribution-ShareAlike 4.0
% International License.
%%
% Concrete Mathematics fonts
\usepackage[amsfonts,amssymb]{concmath}
\usepackage{makeidx}
% Note that we force draft=false so hyperlinks always appear
\usepackage[colorlinks=true,linkcolor=href,draft=false]{hyperref}
% For displaying source code (e.g. XML); `final' needed in draft mode,
% otherwise no listings display.
\usepackage[final]{listings}
% Definitions, theorems, proofs, etc
\usepackage{amsmath}
\usepackage{amsthm}
% Line spacing instead of indentation for paragraphs
%\usepackage[parfill]{parskip}
\usepackage{xcolor}
% To aid in defining star commands
\usepackage{suffix}
\usepackage{marginnote}
% Creative Commons icons
\usepackage{ccicons}
% Dangerous Bend, from TeXbook
\usepackage{manfnt}
% Colors from Tango Icon Theme
% https://en.wikipedia.org/wiki/Tango_Desktop_Project
\definecolor{href}{HTML}{204a87}
% TAME is typeset in smallcaps
\newcommand{\tame}{\textsc{Tame}}
\newcommand{\tamer}{\textsc{Tamer}}
% TODO: highlighting
\lstset{
language=XML,
basicstyle=\ttfamily,
columns=fullflexible,
keepspaces=true,
showstringspaces=false,
}
\newcommand\xpath[1]{\texttt{#1}}
\newcommand\xmlnode[1]{\texttt{#1}}
\newcommand\xmlattr[1]{{@\texttt{#1}}}
\newcommand\tameparam[1]{\texttt{#1}}
\newcommand\tameclass[1]{\texttt{#1}}
\newcommand\tameconst[1]{\texttt{#1}}
\newcommand\true{\ensuremath{\top}}
\newcommand\false{\ensuremath{\bot}}
\newcommand\Bool{\ensuremath{\mathbb{B}}}
\newcommand\tametrue{\tameconst{TRUE}}
\newcommand\tamefalse{\tameconst{FALSE}}
\newcommand\Int{\ensuremath{\mathbb{Z}}}
\newcommand\Real{\ensuremath{\mathbb{R}}}
\newcommand\Set[1]{\ensuremath{\left\{#1\right\}}}
\newcommand\Fam[3]{\ensuremath{\left\{#1_{#2}\right\}_{#2\in #3}}}
\newcommand\Vectors{\ensuremath{\mathcal{V}}}
\newcommand\Vector[1]{\ensuremath{\left\langle#1\right\rangle}}
\newcommand\VFam[3]{\ensuremath{\Vector{#1_{#2}}_{#2\in #3}}}
\newcommand\Matrices{\ensuremath{\Vectors^{\Vectors^\Real}}}
\let\union\cup
\let\Union\bigcup
\let\intersect\cap
\let\infer\vdash
\let\emptystr\epsilon
\newcommand\len[1]{\ensuremath{\left|#1\right|}}
\numberwithin{equation}{section}
% Allows us to switch between styles, if need be
% (e.g. I used the colon style before adopting notation from type theory
% where the colon became ambiguous)
\newcommand\Forall{\@ifstar\@Forallstar\@Forall}
\newcommand\@Forall[2]{\forall #1\left(#2\right)}
\newcommand\@Forallstar[2]{\forall #1 #2}
\newcommand\Exists{\@ifstar\@Existsstar\@Exists}
\newcommand\@Exists[2]{\exists #1\left(#2\right)}
% Without \left and \right. You'll also need this if you use `&' in an
% `align' environment within an argument.
\newcommand\@Existsstar[2]{\exists #1 #2}
% Create a new theorem environment along with a set of label/ref/pref
% commands.
\newcommand\newtheoremwithlabel[3]{%
\newtheorem{#1}{#2}[section]
\expandafter\def\csname #1autorefname\endcsname{#2}
\expandafter\newcommand\csname #3label\endcsname[1]{\label{#1:##1}}
\expandafter\newcommand\csname #3ref\endcsname[1]{\autoref{#1:##1}}
\expandafter\newcommand\csname #3pref\endcsname[1]{\autopref{#1:##1}}
}
\theoremstyle{definition}
\newtheoremwithlabel{definition}{Definition}{dfn}
\theoremstyle{plain}
\newtheoremwithlabel{corollary}{Corollary}{cor}
\newtheoremwithlabel{lemma}{Lemma}{lem}
\theoremstyle{remark}
\newtheoremwithlabel{remark}{Remark}{rem}
\newcommand\pref[1]{\ref{#1} on page~\pageref{#1}}
\newcommand\seclabel[1]{\label{sec:#1}}
\newcommand\secref[1]{Section~\ref{sec:#1}}
\newcommand\secpref[1]{Section~\pref{sec:#1}}
% Binary function composition
\newcommand\bicomp[1]{{#1}^\circ}
\newcommand\bicompi[1]{{#1}^\bullet}
\let\xml\texttt
% Symbols appear at the beginning of the index
\newcommand\indexsym[2]{\index{__sym_#2@{\ensuremath{#1}}|see {#2}}}
\DeclareMathOperator*\Classify{%
\mathchoice{\vcenter{\hbox{\huge$\mathfrak{C}$}}}
{\vcenter{\hbox{\Large$\mathfrak{C}$}}}
{\frak{C}}
{\frak{C}}
}
\newcommand\todo[1]{\marginnote{\underline{\textsc{Todo:}}\\ \textsl{#1}}}
\newcommand\mremark[1]{\marginnote{\textsl{#1}}}
\newcommand\Monoid[3]{\left({#1},{#2},{#3}\right)}
% A really obnoxious notice making clear to the reader that this portion of
% the work is unfinished, to the point where it's probably even
% incorrect. Uses dangerous bend symbol from manfnt, which is admittedly a
% misuse given that it's often used to represent difficult problems. Though
% I suppose an unfinished work is a difficult problem.
\newcommand\INCOMPLETE[1]{%
\bigskip
\par
\todo{This is incomplete!}
\hfill\textdbend\textbf{\textsl{#1}}\textdbend\hfill
\bigskip
}