Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
550 lines (449 sloc) 15.6 KB
\ProvidesPackage{mycommands}
\addto\captionsenglish{\renewcommand{\chaptername}{Unit}}
\addto\captionsenglish{\renewcommand{\contentsname}{Contents (detailed)}}
% \addto\captionsenglish{\renewcommand{\bibname}{References and Further Reading}}
\def\thesection{\arabic{section}}
\newenvironment{literature}{%
\subsection*{Relevant literature for
\chaptername~\thechapter}}{%
\printbibliography[heading=subbibliography,segment=\therefsegment]}
\newcommand{\thexload}[1]{%
\input{./exercises/theory/#1.tex}
}
\newcommand{\cexload}[1]{%
\input{./exercises/coding/#1.tex}
}
\newcommand{\tikzload}[1]{%
\tikzsetnextfilename{#1}%
\input{./img/tikz/#1.tikz}%
}
\newcommand{\forestload}[1]{%
\tikzsetnextfilename{#1}%
\input{./img/tikz/#1.forest}%
}
\newcommand{\Note}[1]{\marginpar{\scriptsize #1}}
\newcommand{\NoteNearNumbers}[1]{\marginpar[%
\begin{tabular}{p{\marginparwidth-2em}r}
\scriptsize
#1 &
\end{tabular}%
]{%
\begin{tabular}{rp{\marginparwidth-2em}}
&
\scriptsize
#1
\end{tabular}%
}}
\newcounter{homework}[chapter]
\def\thehomework{\thechapter.\arabic{homework}}
\definecolor{exblue}{HTML}{2D68A2}
\newenvironment{homework}[1][\unskip]{%
\refstepcounter{homework}%
\medskip
\noindent\ignorespaces%
\textbf{\color{exblue}[Exercise \thehomework #1} \quad%
}%
% {\hfill \tikzset{external/export next=false}\tikz{\node[minimum size=.7em, inner sep=0pt, circle, fill=exblue] at (0,0) {};}}
{\unskip\textbf{\color{exblue}]}%
\medskip\par\noindent\ignorespacesafterend}
\newcommand{\DangerSymbol}{\ensuremath{\skull}}
\newcommand{\difficultsymbol}{\ensuremath{\skull}}
\newcommand{\difficult}{\difficultsymbol\ }
% \setof - set with auto-sized brackets
\newcommand{\setof}[1]{\ensuremath{\left \{ #1 \right \}}}
% \cardof - cardinality
\newcommand{\cardof}[1]{\ensuremath{| #1 |}}
% \tuple - tuple with auto-sized brackets
\newcommand{\tuple}[1]{\ensuremath{\left \langle #1 \right \rangle }}
\newcommand{\ftuple}[1]{\tuple{\mathrm{#1}}}
\newcommand{\ttuple}[1]{\tuple{\text{#1}}}
% Defines
\newcommand{\is}{\ensuremath{\mathrel{\mathop:}=}}
% emptystring
\newcommand{\emptystring}{\ensuremath{\varepsilon}}
% strings
\newcommand{\String}[1]{\ensuremath{\mathit{#1}}}
\newcommand{\mlex}[2]{\ensuremath{\text{#1} ::\thinspace \mathrm{#2}}}
\newcommand{\SelEq}{\ensuremath{\mathop{=}}}
\newcommand{\fsel}[1]{\ensuremath{\SelEq\mathrm{#1}}}
\newcommand{\restrictor}{\ensuremath{\upharpoonright}}
\newcommand{\idom}{\ensuremath{\triangleleft}}
\newcommand{\pdom}{\ensuremath{\triangleleft^+}}
\newcommand{\rdom}{\ensuremath{\triangleleft^*}}
\newcommand{\outdom}{\ensuremath{\blacktriangleleft}}
\newcommand{\word}[1]{\emph{#1}}
% example box environment
\colorlet{exmp}{SeaGreen4}
\colorlet{tech}{Purple}
\tikzstyle{examplebox} = [draw=exmp, fill=exmp!25, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
\tikzstyle{exampletitle} = [fill=exmp, text=white]
% code for an examplebox
% first we need a background layer
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
% we define a couple of macros for parts of the box:
% box on entire page, top, middle, bottom
\def\ExampleboxframeTotal#1{
\tikzset{external/export next=false}
\tikz{
\node[inner sep=10pt, inner ysep=20pt] (text) {#1};
\begin{pgfonlayer}{background}
\draw[exmp, very thick, rounded corners]
(text.south west) -- (text.north west) --
(text.north east) -- (text.south east) -- cycle;
\end{pgfonlayer}
}
}
\def\ExampleboxframeTop#1{
\tikzset{external/export next=false}
\tikz{
\node[inner sep=10pt, inner ysep=20pt] (text) {#1};
\begin{pgfonlayer}{background}
\draw[exmp, very thick, rounded corners]
(text.south west) -- (text.north west) --
(text.north east) -- (text.south east);
\end{pgfonlayer}
}
}
\def\ExampleboxframeMiddle#1{
\tikzset{external/export next=false}
\tikz{
\node[inner sep=10pt, inner ysep=20pt] (text) {#1};
\begin{pgfonlayer}{background}
\draw[exmp, very thick, rounded corners]
(text.south west) -- (text.north west);
\draw[exmp, very thick, rounded corners]
(text.north east) -- (text.south east);
\end{pgfonlayer}
}
}
\def\ExampleboxframeBottom#1{
\tikzset{external/export next=false}
\tikz{
\node[inner sep=10pt, inner ysep=20pt] (text) {#1};
\begin{pgfonlayer}{background}
\draw[exmp, very thick, rounded corners]
(text.north west) -- (text.south west) --
(text.south east) -- (text.north east);
\end{pgfonlayer}
}
}
% define a new list via tocloft
% \newcounter{examplebox}[chapter]
% \def\theexamplebox{\thechapter.\arabic{examplebox}}
\newlistof[chapter]{examplebox}{exs}{List of Examples}
\cftsetindents{examplebox}{1.5em}{2.3em}
\newenvironment{examplebox}[1][\unskip]{
\refstepcounter{examplebox}
\def\FrameCommand{\ExampleboxframeTotal}
\def\FirstFrameCommand{\ExampleboxframeTop}
\def\MidFrameCommand{\ExampleboxframeMiddle}
\def\LastFrameCommand{\ExampleboxframeBottom}
\vskip\baselineskip
\MakeFramed {\FrameRestore}
\noindent%
\tikzset{external/export next=false}%
\tikz\node[fill=exmp,text=white,anchor=west,overlay]
at (0em,2.5em) {Example \theexamplebox \quad #1};%
\addcontentsline{exs}{examplebox}{\protect\numberline{\theexamplebox} #1}%
\ignorespaces
}
{\endMakeFramed}
\newenvironment{dexamplebox}[1][\unskip]{
\refstepcounter{examplebox}
\def\FrameCommand{\ExampleboxframeTotal}
\def\FirstFrameCommand{\ExampleboxframeTop}
\def\MidFrameCommand{\ExampleboxframeMiddle}
\def\LastFrameCommand{\ExampleboxframeBottom}
\vskip\baselineskip
\MakeFramed {\FrameRestore}
\noindent%
\tikzset{external/export next=false}%
\tikz\node[fill=exmp,text=white,anchor=west,overlay]
at (0em,2.5em) {Example \theexamplebox\quad #1 \quad\DangerSymbol};%
\addcontentsline{exs}{examplebox}{\protect\numberline{\theexamplebox} #1 \DangerSymbol}%
\ignorespaces
}
{\endMakeFramed}
% tech info environment
\def\Techinfoframe#1{
\tikzset{external/export next=false}
\tikz{
\node[inner sep=10pt, inner ysep=20pt] (text) {#1};
\begin{pgfonlayer}{background}
\fill[tech!10] (text.north west) rectangle (text.south east);
\end{pgfonlayer}
}
}
\newenvironment{techinfo}[1][\unskip]{%
\def\FrameCommand{\Techinfoframe}
\vskip\baselineskip
\MakeFramed {\FrameRestore}
\noindent\ignorespaces%
\tikzset{external/export next=false}%
\tikz\node[fill=tech,text=white,anchor=west,overlay]
at (0em,2.5em) {Background \quad #1};%
\ignorespaces
}
{\endMakeFramed}
\def\Peopleinfoframe#1{
\tikzset{external/export next=false}
\tikz{
\node[inner sep=10pt, inner ysep=20pt] (text) {#1};
\begin{pgfonlayer}{background}
\fill[Sepia!15,rounded corners] (text.north west) rectangle (text.south east);
\end{pgfonlayer}
}
}
\newenvironment{person}[2][\unskip]{%
\def\FrameCommand{\Peopleinfoframe}
\vskip\baselineskip
\MakeFramed {\FrameRestore}
\noindent\ignorespaces%
\tikzset{external/export next=false}%
\tikz\node[fill=Sepia,text=white,anchor=west,overlay,rounded corners]
at (0em,2.5em) {\textbf{#2} (#1)};%
\ignorespaces
}
{\endMakeFramed}
\theoremstyle{plain}
\theoremheaderfont{\normalfont\bfseries}
\theorembodyfont{\normalfont\upshape}
\theoremseparator{.}
\newcommand{\TheoremSymbol}{\tikzset{external/export next=false}\tikz{\draw (0,0) -| (.5em,.5em);}}
\theoremsymbol{\ensuremath{\TheoremSymbol}}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\theorembodyfont{\normalfont\itshape}
\theoremsymbol{}
\newtheorem{conjecture}[theorem]{Conjecture}
\newtheorem{problem}[theorem]{Problem}
\theorembodyfont{\normalfont\upshape}
\theoremprework{\bigskip\hrule}
\theorempostwork{\hrule\bigskip}
\newtheorem{definition}[theorem]{Definition}
\theoremstyle{nonumberplain}
\theoremheaderfont{\normalfont\itshape}
\theoremprework{}
\theorempostwork{}
\newcommand{\QED}{\ensuremath{\blacksquare}}
\qedsymbol{\QED}
\theoremsymbol{\ensuremath{\Box}}
\newtheorem{proof}{Proof}
\theoremsymbol{\ensuremath{\bigcirc}}
\newtheorem{remark}{Remark}
\newtheorem{example}{Example}
\theoremsymbol{}
\theoremheaderfont{\normalfont\scshape}
\theoremindent1.5em
\newtheorem{ucase}{Case}
\theoremstyle{plain}
\newtheorem{case}{Case}
\theoremindent1.5em
\newtheorem{subcase}{Case}
\numberwithin{subcase}{case}
\newcommand{\ltr}{\noindent\textsc{Left to right}.\ }
\newcommand{\rtl}{\noindent\textsc{Right to left}.\ }
\newcommand{\Automaton}[4][3]{%
\begin{tikzpicture}
\Tree
[.\node(root){#3};
#4
]
\node (label) at ($(root)+(-#1em,0)$) {#2};
\draw[dashed] (label) to (root);
\end{tikzpicture}
}
\newcommand{\Transducer}[6][3]{%
\begin{tikzpicture}
\Tree
[.\node(root){#3};
#4
]
\node (label) at ($(root)+(-#1em,0)$) {#2};
\node (tree) at ($(root)+(#1em,0)$) {%
\Tree
[.\node{#5};
#6
]
};
\foreach \Node in {label,tree}
\draw[dashed] (\Node) to (root);
\end{tikzpicture}
}
\newenvironment{Example}{\noindent\textit{Example.}}{}
\newcommand{\rewrite}{\ensuremath{\rightarrow}\xspace}
\newcommand{\tsb}[1]{\ensuremath{_{\textrm{#1}}}}
\newcommand{\tsp}[1]{\ensuremath{^{\textrm{#1}}}}
\newcommand{\emptyhead}{\ensuremath{\varepsilon}}
\newcommand{\gloss}[1]{\textsc{#1}}
\newcommand{\BigO}{\ensuremath{O}}
\definecolor{codebg}{rgb}{0.98,0.98,0.98}
\setminted[python]{style=arduino}
\newminted{python}{linenos,mathescape,gobble=4,fontsize=\footnotesize,bgcolor=codebg,samepage=false}
\newmintedfile{python}{linenos,mathescape,fontsize=\footnotesize,bgcolor=codebg,samepage=false}
\newmintinline{python}{}
\newcommand{\LeftEdgeSymbol}{\ensuremath{\rtimes}}
\newcommand{\RightEdgeSymbol}{\ensuremath{\ltimes}}
\newcommand{\LeftEdge}{\ensuremath{\LeftEdgeSymbol}}
\newcommand{\RightEdge}{\ensuremath{\RightEdgeSymbol}}
\newcommand{\Bigrams}[1][2]{\ensuremath{#1\mathrm{\text{-}grams}}}
\newcommand{\ktrees}[1][2]{\ensuremath{#1\mathrm{\text{-}trees}}}
\newcommand{\Subsequences}[1][2]{\ensuremath{#1\mathrm{\text{-}seqs}}}
\newcommand{\augmented}[1]{\ensuremath{\hat{#1}}}
\newcommand{\stringcat}{\ensuremath{\cdot}}
\newcommand{\posG}[1]{\ensuremath{^+ #1}}
\newcommand{\negG}[1]{\ensuremath{^- #1}}
\newcommand{\complementof}[1]{\ensuremath{ \overline{#1} } }
% labeling function
\newcommand{\LabelFunc}{\ensuremath{\ell}}
% string yield
\newcommand{\Yield}{\ensuremath{\mathrm{yd}}}
% natural numbers
\newcommand{\NatNum}{\ensuremath{\mathbb{N}}}
% positive natural numbers
\newcommand{\NatNumPos}{\ensuremath{\mathbb{N}^{+}}}
% semiring operations
\newcommand{\semiadd}{\ensuremath{\oplus}}
\newcommand{\semimult}{\ensuremath{\otimes}}
% multiplication
\newcommand{\mult}{\ensuremath{\mathop{\times}}}
% ngrams
\newcommand{\ngram}[1]{\ensuremath{\mathit{#1}}}
% language class
\newcommand{\LangClass}[1]{\ensuremath{\mathrm{#1}}}
% Finite
\newcommand{\FIN}{\LangClass{Fin}}
% Strictly Local
\newcommand{\SL}{\LangClass{SL}}
% Strictly Local for trees
\newcommand{\SLT}[1][\unskip]{\LangClass{SL^T_{\mathit{#1}}}}
% Refined Strictly Local for trees
\newcommand{\SLTR}[1][\unskip]{\LangClass{SL^{T,R}_{\mathit{#1}}}}
%fixme: numbers shouldn't be in mathit
% Strictly Piecewise
\newcommand{\SP}{\LangClass{SP}}
% Threshold Testable
\newcommand{\TT}{\LangClass{TT}}
% Strictly Threshold Testable
\newcommand{\STT}{\LangClass{STT}}
\newcommand{\SLTT}[2]{\ensuremath{\SL_{#1}\TT_{#2}}}
\newcommand{\SPTT}[2]{\ensuremath{\SP_{#1}\TT_{#2}}}
% content
\newcommand{\contentof}{\ensuremath{\mathit{content}}}
% learner
\newcommand{\Learner}{\ensuremath{\phi}}
% noise
\newcommand{\Noise}{\ensuremath{\#}}
% binary relation
\newcommand{\binrel}[3]{\ensuremath{#2 \mathrel{#1} #3}}
\newcommand{\notbinrel}[3]{\ensuremath{#2 \not\mathrel{#1} #3}}
% identity element
\newcommand{\IdOne}{\ensuremath{\mathbf{1}}}
\newcommand{\IdNull}{\ensuremath{\mathbf{0}}}
\newcommand{\IdE}{\ensuremath{e}}
% min
\newcommand{\minfix}{\ensuremath{\mathrel{\text{min}}}}
% threshold function
\newcommand{\ThreshFunc}{\ensuremath{\tau}}
% string occurrences
\newcommand{\StringOcc}[2]{\ensuremath{\cardof{#1}_{#2}}}
% state symbols
\newcommand{\kState}[2]{\ensuremath{\dfrac{\color{SeaGreen4}#1}{#2}}}
\newcommand{\ComplexState}[2]{\ensuremath{\color{SeaGreen4}\dfrac{#1}{#2}}}
% inverse
\newcommand{\invof}[1]{\ensuremath{#1^{-1}}}
% identity
\newcommand{\idfunc}{\ensuremath{\mathrm{id}}}
% rewritten
\newcommand{\rewritten}[1]{{\color{red!75}#1}}
% transduction
\newcommand{\transduction}{\ensuremath{\tau}}
\newcommand{\uptransduction}[1]{\ensuremath{#1 \transduction^{\uparrow}}}
\newcommand{\downtransduction}[1]{\ensuremath{#1 \transduction^{\downarrow}}}
% generator
\newcommand{\Gen}{\textsc{Gen}}
% OT constraints
\newcommand{\con}{\ensuremath{c}}
\newcommand{\conset}{\ensuremath{C}}
% OT composition
\newcommand{\lencomp}{\ensuremath{\uparrow}}
\newcommand{\glencomp}{\ensuremath{\downharpoonright}}
% range
\newcommand{\range}{\ensuremath{\mathop{\mathrm{ran}}}}
% relativized ranking
\newcommand{\relrank}[2]{\ensuremath{\mathit{rel}^{#2}_{#1}}}
% state heads and tails
\newcommand{\heads}[1]{\ensuremath{\mathit{heads}(#1)}}
\newcommand{\tails}[1]{\ensuremath{\mathit{tails}(#1)}}
% equivalence class
\newcommand{\eclass}[1]{\ensuremath{[#1]}}
% features for AVMs
\newcommand{\FType}[1]{\text{\textsc{#1}}}
\newcommand{\Cat}{\FType{Cat}}
\newcommand{\Phon}{\FType{Phon}}
\newcommand{\Compound}{\FType{Compound}}
\newcommand{\Subcat}{\FType{Subcat}}
\newcommand{\Address}{\FType{Add}}
\newcommand{\Num}{\FType{Num}}
\newcommand{\Pers}{\FType{Pers}}
\newcommand{\Gender}{\FType{Gender}}
\newcommand{\Type}{\FType{Type}}
\newcommand{\Target}{\FType{Target}}
\newcommand{\Displace}{\FType{Displace}}
% MG operation dots in trees
\newcommand{\MergeSym}{\ensuremath{\circ}}
\newcommand{\MoveSym}{\ensuremath{\bullet}}
% Derivation Tree Commands
\newcommand{\Lab}[3]{\textsuperscript{#2}#1\textsubscript{#3}}
\newcommand{\BLab}[3]{\textsuperscript{#2}#1\boxed{\textsubscript{#3}}}
\newcommand{\IBLab}[3]{\textsuperscript{#2}#1\boxed{\textsubscript{#3}}}
% Checkmark and cross; requires bbding
\newcommand{\yes}{\checkmark}
\newcommand{\no}{\XSolidBrush}
% fancy quote environment with tikz
\makeatletter
\tikzset{%
fancy quotes/.style={
text width=\fq@width pt,
align=justify,
inner sep=1em,
anchor=north west,
minimum width=\linewidth,
},
fancy quotes width/.initial={.8\linewidth},
fancy quotes marks/.style={
scale=8,
text=gray!25,
inner sep=0pt,
},
fancy quotes opening/.style={
fancy quotes marks,
},
fancy quotes closing/.style={
fancy quotes marks,
},
fancy quotes background/.style={
show background rectangle,
inner frame xsep=0pt,
background rectangle/.style={
fill=white!25,
rounded corners,
},
}
}
\newenvironment{fancyquote}[1][]{%
\noindent
\tikzset{external/export next=false}
\tikzpicture[fancy quotes background]
\node[fancy quotes opening,anchor=north west] (fq@ul) at (0,0) {``};
\tikz@scan@one@point\pgfutil@firstofone(fq@ul.east)
\pgfmathsetmacro{\fq@width}{\linewidth - 2*\pgf@x}
\node[fancy quotes,#1] (fq@txt) at (fq@ul.north west) \bgroup}
{\egroup;
\node[overlay,fancy quotes closing,anchor=east] at (fq@txt.south east) {''};
\endtikzpicture}
\makeatother