thesis.sty (14477B)
1 \NeedsTeXFormat{LaTeX2e} 2 \ProvidesPackage{thesis}[2021/01/01 Local package] 3 4 \RequirePackage[main=english,french,greek]{babel} 5 \RequirePackage{iflang} % For \IfLanguageName 6 \RequirePackage{lua-ul} % For \underLine 7 \RequirePackage{ccicons} % For Creative Commons licence logos 8 \RequirePackage{setspace} % For \onehalfspacing 9 \RequirePackage[inline]{enumitem} % For fancy itemize etc 10 \RequirePackage{array} % For \newcolumntype 11 \RequirePackage{tabularx} % For X-like column types 12 \RequirePackage{longtable} % For pagebreak inside a table 13 \RequirePackage{multirow} % For \multirow and \multicolumn 14 \RequirePackage{graphicx} % For \includegraphics on steroids 15 \RequirePackage{hyperref} % For hypertext functionalities 16 \RequirePackage{bookmark} % For \pdfbookmark 17 18 19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 %%% Hyperref setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 23 %%%%%%%%%%%%%%%%%%%% 24 % Set PDF metadata % 25 %%%%%%%%%%%%%%%%%%%% 26 \begingroup 27 \def\sep{;} 28 \edef\thesis@pdf@keywords{\@keywords} 29 30 \hypersetup{ 31 pdfauthor={\@author}, 32 pdftitle={\@title}, 33 pdfsubject={\@title}, 34 pdfkeywords={\thesis@pdf@keywords}, 35 pdflang=en, 36 } 37 \endgroup 38 39 %%%%%%%%%%%%%%%%%%%%%%%%%%% 40 % Hyperlink configuration % 41 %%%%%%%%%%%%%%%%%%%%%%%%%%% 42 \hypersetup{ 43 linktoc=all, 44 colorlinks=true, 45 linkcolor=red!60!black, 46 citecolor=green!60!black, 47 filecolor=cyan!60!black, 48 menucolor=red!60!black, 49 urlcolor=magenta!60!black, 50 pdfdisplaydoctitle=true, 51 } 52 53 54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 55 %%% Shorthand commands %%%%%%%%%%%%%%%%%%%%%%%%%%% 56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 57 58 %%%%%%%%%%%%%%%%%%%%% 59 % Draft Annotations % 60 %%%%%%%%%%%%%%%%%%%%% 61 \NewDocumentCommand\draftnotecmd{m O{} O{} o m m}{ 62 \ifnum\thesis@debug>0 63 \expandafter\NewDocumentCommand\csname\string#1\endcsname{+m}{\hbadness=10000\textcolor{#5}{#2\relax{}##1}} 64 \NewDocumentCommand#1{o +m}{\IfNoValueTF{##1}{\IfValueTF{#4}{#4\csname\string#1\endcsname{##2}}{\marginpar{\tiny\csname\string#1\endcsname{##2}}}}{\marginnote{\tiny\csname\string#1\endcsname{##2}}[##1]}\ignorespaces} 65 \else 66 \NewDocumentCommand#1{o +m}{\directlua{print("\string\27[#6;1mDRAFT MESSAGE: #3\luatexluaescapestring{\unexpanded{##1}}\string\27[0m")}} 67 \fi 68 } 69 70 \draftnotecmd\B{red}{31} 71 \draftnotecmd\benj[][][]{red}{31} 72 \draftnotecmd\Ba[\(\hookrightarrow\)][→]{red}{31} 73 \draftnotecmd\V{green!67!black}{32} 74 \draftnotecmd\vinc[][][]{green!67!black}{32} 75 \draftnotecmd\R{orange}{33} 76 \draftnotecmd\reu[][][]{orange}{33} 77 \draftnotecmd\E{blue}{34} 78 \draftnotecmd\e[][][]{blue}{34} 79 \draftnotecmd\Ea[\(\hookrightarrow\)][→]{blue}{34} 80 \draftnotecmd\M{purple}{35} 81 \draftnotecmd\syr[][][]{purple}{35} 82 83 %%%%%%%%%%%%%%%%%% 84 % Table commands % 85 %%%%%%%%%%%%%%%%%% 86 \newcolumntype{P}[1]{>{\footnotesize\raggedright\arraybackslash}p{#1}} 87 \newcolumntype{Y}{>{\footnotesize\raggedright\arraybackslash}X} 88 89 % won't compile on a PDP-50… O: 90 \setcounter{LTchunksize}{100} 91 92 %%%%%%%%%%%%%%%%% 93 % Math commands % 94 %%%%%%%%%%%%%%%%% 95 \DeclareMathOperator*\expectation{\symbb{E}} 96 \DeclareMathOperator*\entropy{H} 97 \DeclareMathOperator*\argmax{argmax} 98 \DeclareMathOperator\pmi{pmi} 99 \NewDocumentCommand\laplace{}{\symup{\Delta}} 100 \DeclareMathOperator\ReLU{ReLU} 101 \DeclareMathOperator\softmax{softmax} 102 \DeclareMathOperator\diagonal{diag} 103 \DeclareMathOperator\kl{D_\textsc{kl}} 104 \DeclareMathOperator\jsd{D_\textsc{jsd}} 105 \DeclareMathOperator\uniformDistribution{\symcal{U}} 106 \DeclareMathOperator\normalDistribution{\mathcal{N}} 107 \NewDocumentCommand\sigmoid{}{\mathop{\sigma}} 108 \NewDocumentCommand\diff{}{\mathop{}\!\mathrm{d}} 109 110 % Independent symbol with two vertical bar 111 \newcommand\independent{\protect\mathpalette{\protect\independenT}{\perp}} 112 \def\independenT#1#2{\mathrel{\rlap{$#1#2$}\mkern2mu{#1#2}}} 113 114 \NewDocumentCommand\middlerel{m}{\mathrel{}\middle#1\mathrel{}} 115 116 % For multisets 117 \NewDocumentCommand\lMultiBrace{}{\left\{\mskip-7mu\left\{} 118 \NewDocumentCommand\rMultiBrace{}{\right\}\mskip-7mu\right\}} 119 120 \newcommand\notindependent{\protect\mathpalette{\protect\notindependenT}{\perp}} 121 \def\notindependenT#1#2{\mathrel{\rlap{$#1#2$}\mkern2mu{#1\not#2}}} 122 % Comply with ISO 80000-2 (which mandates bold italic or \vec for vectors) 123 \NewDocumentCommand\vctr{m}{{\symbf{#1}}} 124 \NewDocumentCommand\mtrx{m}{{\symbf{#1}}} 125 \NewDocumentCommand\tnsr{m}{{\symbfsf{#1}}} 126 \NewDocumentCommand\rndm{m}{{\symup{#1}}} 127 \NewDocumentCommand\rndmvctr{m}{{\symbfup{#1}}} 128 \NewDocumentCommand\transposesym{}{\symsfup{T}} 129 \NewDocumentCommand\transpose{}{^{\mkern-1.5mu\transposesym}} 130 131 % Used in subscript of \ReLU to indicates it is only applied to half the units 132 \NewDocumentCommand\halfCircleScript{}{ 133 \begin{tikzpicture} 134 \draw[fill] (0,0)-- (90:0.8mm) arc (90:270:0.8mm) -- cycle ; 135 \draw (0,0) circle (0.8mm); 136 \end{tikzpicture} 137 } 138 139 %%%%%%%%%%%%%%%%%%%%%%%% 140 % Entities & Relations % 141 %%%%%%%%%%%%%%%%%%%%%%%% 142 \NewDocumentCommand\uhead{m}{\relax\underLine{#1}\textsubscript{\(e_1\)}} 143 \NewDocumentCommand\utail{m}{\relax\underLine{#1}\textsubscript{\(e_2\)}} 144 \NewDocumentCommand\uent{m}{\relax\underLine{#1}\textsubscript{\(e\)}} 145 \NewDocumentCommand\wdent{O{} m}{\texttt{\href{https://www.wikidata.org/wiki/Q#2}{#1Q#2}}} 146 \NewDocumentCommand\wdrel{O{} m}{\texttt{\href{https://www.wikidata.org/wiki/Property:P#2}{#1P#2}}} 147 148 \NewDocumentCommand\tripletHolds{m m m}{\ensuremath{\mathalpha{#1}\mathrel{#2}\mathalpha{#3}}} 149 \NewDocumentCommand\sfTripletHolds{m m m}{\tripletHolds{#1}{\textsl{#2\/}}{#3}} 150 151 %%%%%%%%%%%%%%% 152 % Common Sets % 153 %%%%%%%%%%%%%%% 154 \NewDocumentCommand\entitySet{}{{\symcal{E}}} 155 \NewDocumentCommand\relationSet{}{{\symcal{R}}} 156 \NewDocumentCommand\sentenceSet{}{{\symcal{S}}} 157 \NewDocumentCommand\dataSet{}{{\symcal{D}}} 158 \NewDocumentCommand\arcSet{}{{\symcal{A}}} 159 \NewDocumentCommand\kbSet{}{{\dataSet_\textup{\textsc{kb}}}} 160 \NewDocumentCommand\itemSet{}{{\symcal{I}}} 161 162 %%%%%%%%%%%%%%%%%%%%%%% 163 % Directed F1 Metrics % 164 %%%%%%%%%%%%%%%%%%%%%%% 165 \def\widebreve{\mathpalette\wide@breve} 166 \def\wide@breve#1#2{\sbox\z@{$#1#2$}% 167 \mathop{\vbox{% 168 \m@th\ialign{% 169 ##\crcr 170 \kern0.08em\brevefill#1{0.9\wd\z@}\crcr% 171 \noalign{\nointerlineskip\vskip -0.6mm\relax}% 172 $\hss#1#2\hss$\crcr% 173 }}}\limits} 174 \def\Pwidebreve{\mathpalette\Pwide@breve} 175 \def\Pwide@breve#1#2{\sbox\z@{$#1#2$}% 176 \mathop{\vbox{% 177 \m@th\ialign{% 178 ##\crcr 179 \kern0.08em\brevefill#1{0.9\wd\z@}\crcr% 180 \noalign{\nointerlineskip}% 181 $\hss#1#2\hss$\crcr% 182 }}}\limits} 183 \def\brevefill#1#2{$\m@th\sbox\tw@{$#1($}% 184 \hss\resizebox{#2}{\wd\tw@}{\rotatebox[origin=c]{90}{\upshape(}}\hss$} 185 186 %%%%%%%%% 187 % Graph % 188 %%%%%%%%% 189 \NewDocumentCommand\gfsource{}{\varepsilon_1} 190 \NewDocumentCommand\gftarget{}{\varepsilon_2} 191 \NewDocumentCommand\gfendpoints{}{\symbf{\varepsilon}} 192 \DeclareMathOperator\gfincidents{\symcal{I}} 193 \NewDocumentCommand\gfrelation{}{\mathop{\rho}} 194 \NewDocumentCommand\gfsentence{}{\mathop{\varsigma}} 195 \DeclareMathOperator\gfdegree{deg} 196 \DeclareMathOperator\gffourier{\symscr{F}} 197 \DeclareMathOperator\gfinvfourier{\symscr{F}^{-1}} 198 \NewDocumentCommand\laplacian{m}{\ensuremath{\mtrx{L}_{\textsc{#1}}}} 199 \NewDocumentCommand\inlineArc{s o m m}{% 200 \begin{tikzpicture}[baseline=(a.base)]% 201 \node[inner sep=0.3mm, outer sep=0mm] (a) {\(#3\)}; 202 \node[right=4mm of a,inner sep=0.2mm, outer sep=0mm] (b) {\(#4\)}; 203 \draw[-{Latex[length=1.5mm,width=1.2mm]}]% 204 (\IfBooleanTF{#1}{b}{a})% 205 --% 206 (\IfBooleanTF{#1}{a}{b})% 207 \IfValueT{#2}{node[midway,above] {\scriptsize \(#2\)}}% 208 ; 209 \end{tikzpicture}% 210 } 211 \NewDocumentCommand\inlineDoubleArc{s o o m m m}{% 212 \begin{tikzpicture}[baseline=(a.base)]% 213 \node[inner sep=0.3mm, outer sep=0mm] (a) {\(#4\)}; 214 \node[right=4mm of a,inner sep=0.2mm, outer sep=0mm] (b) {\(#5\)}; 215 \node[right=4mm of b,inner sep=0.2mm, outer sep=0mm] (c) {\(#6\)}; 216 \draw[-{Latex[length=1.5mm,width=1.2mm]}] (a) -- (b)% 217 \IfValueT{#2}{node[midway,above] {\scriptsize \(#2\)}}% 218 ; 219 \draw[-{Latex[length=1.5mm,width=1.2mm]}]% 220 (\IfBooleanTF{#1}{c}{b})% 221 --% 222 (\IfBooleanTF{#1}{b}{c})% 223 \IfValueT{#3}{node[midway,above] {\scriptsize \(#3\)}}% 224 ; 225 \end{tikzpicture}% 226 } 227 228 %%%%%%%%%%%%%%%% 229 % Neighborhood % 230 %%%%%%%%%%%%%%%% 231 \NewDocumentCommand\gfneighbors{}{N} 232 \NewDocumentCommand\gfeneighbors{}{\symcal{N}} 233 \NewDocumentCommand\gfsr{}{{\langle r\rangle}} 234 \NewDocumentCommand\gforight{}{{\tikz{\draw[-{Latex[length=1mm,width=1mm]}] (0, 0) -- (2.6mm, 0);}}} 235 \NewDocumentCommand\gfoleft{}{{\tikz{\draw[-{Latex[length=1mm,width=1mm]}] (0, 0) -- (-2.6mm, 0);}}} 236 \NewDocumentCommand\gfnright{}{{\kern-0.8mm\gforight}} 237 \NewDocumentCommand\gfnleft{}{{\kern-0.8mm\gfoleft}} 238 239 \NewDocumentCommand\gfneighborsrr{}{% 240 \operatorname{\mathnormal{\begin{tikzpicture}[baseline=(b.base)]% 241 \node[inner sep=0pt,outer sep=0pt] (n) {\(\gfneighbors_\gfsr\)};% 242 \draw[-{Latex[length=1mm,width=1mm]}] ($(n.center)+(0.39mm, 1mm)$) -- +(2.6mm, 0);% 243 \node[inner sep=0pt,outer sep=0pt,anchor=north west] (b) at (n.north west) {\(\gfneighbors\)};% 244 \clip (n.north west) rectangle (n.south east);% 245 \end{tikzpicture}}}% 246 } 247 \NewDocumentCommand\gfneighborsrl{}{% 248 \operatorname{\mathnormal{\begin{tikzpicture}[baseline=(b.base)]% 249 \node[inner sep=0pt,outer sep=0pt] (n) {\(\gfneighbors_\gfsr\)};% 250 \draw[-{Latex[length=1mm,width=1mm]}] ($(n.center)+(2.99mm, 1mm)$) -- +(-2.6mm, 0);% 251 \node[inner sep=0pt,outer sep=0pt,anchor=north west] (b) at (n.north west) {\(\gfneighbors\)};% 252 \clip (n.north west) rectangle (n.south east);% 253 \end{tikzpicture}}}% 254 } 255 256 %%%%%%%%%%%%%%%%%%%% 257 % Relation Algebra % 258 %%%%%%%%%%%%%%%%%%%% 259 \NewDocumentCommand\relationComposition{}{\mathbin{\bullet}} 260 \NewDocumentCommand\relationIdentity{}{\symbf{I}} 261 \NewDocumentCommand\relationAnd{}{\cap} 262 \NewDocumentCommand\relationOr{}{\cup} 263 \NewDocumentCommand\relationZero{}{\symbf{0}} 264 \NewDocumentCommand\relationOne{}{\symbf{1}} 265 266 %%%%%%%%%%%%%%%%%%%%%%% 267 % Loss Directionality % 268 %%%%%%%%%%%%%%%%%%%%%%% 269 \def\directedfill{\arrowfill@\relbar\relbar\rightarrow} 270 \def\halfdirectedfill{\arrowfill@\leftharpoonup\relbar\rightharpoondown} 271 \def\undirectedfill{\arrowfill@\leftarrow\relbar\rightarrow} 272 \NewDocumentCommand\overDirected{}{\mathpalette{\overarrow@\directedfill}} 273 \NewDocumentCommand\overHalfdirected{}{\mathpalette{\overarrow@\halfdirectedfill}} 274 \NewDocumentCommand\overUndirected{}{\mathpalette{\overarrow@\undirectedfill}} 275 276 %%%%%%%%%%%%%%%%% 277 % Abbreviations % 278 %%%%%%%%%%%%%%%%% 279 \NewDocumentCommand\trexspo{}{\textsc{t-re}x \textsc{spo}} 280 \NewDocumentCommand\trexds{}{\textsc{t-re}x \textsc{ds}} 281 \NewDocumentCommand\nytfb{}{\(\textsc{nyt}+\textsc{fb}\)} 282 283 %%%%%%%%%%%%%%%%% 284 % Miscellaneous % 285 %%%%%%%%%%%%%%%%% 286 \NewDocumentCommand\empP{}{\ensuremath{\hat{P}}} 287 \NewDocumentCommand\loss{O{\textsc} m}{\ensuremath{\symcal{L}_{#1{#2}}}} 288 \NewDocumentCommand\problem{m}{\ensuremath{\symscr{P}\;#1}} 289 \NewDocumentCommand\bertArch{m}{\textsc{bert-}\discretionary{}{}{}\texttt{#1}} 290 \NewDocumentCommand\bertcoder{}{\ensuremath{\operatorname{\textsc{bert}coder}}} 291 \NewDocumentCommand\fone{}{\ensuremath{F_1}} 292 \NewDocumentCommand\bcubed{}{\ensuremath{\symup{B}^3}} 293 \NewDocumentCommand\blanktag{}{\texttt{<}\textsc{blank}\texttt{/>}} 294 \NewDocumentCommand\ctxoneadj{}{\(\operatorname{\textsc{ctx}}(\textsc{1-adjacency})\)} 295 \NewDocumentCommand\mmsrlencoder{o}{\ensuremath{\operatorname{enc\IfValueT{#1}{_\text{#1}}}}} 296 \NewDocumentCommand\mmsrldecoder{o}{\ensuremath{\operatorname{dec\IfValueT{#1}{_\text{#1}}}}} 297 298 299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 300 %%% Hypothesis Management %%%%%%%%%%%%%%%%%%%%%%%% 301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 302 303 \NewDocumentCommand\hypothesis{m}{\ensuremath{\symscr{H}_\textsc{#1}}} 304 305 \NewDocumentCommand\typeassumption{o m}{% 306 \begin{trivlist}\item\relax% 307 \ifcsname hyp:#2\endcsname% 308 \expandafter\csname hyp:#2\endcsname% 309 \IfValueT{#1}{% 310 \rlap{\kern\marginparsep\marginsize\textsc{#1}}% 311 }% 312 \else% 313 \thesis@warning{Trying to type undefined assumption #2.}% 314 \fi% 315 \end{trivlist}% 316 } 317 318 %Global lrbox 319 \let\glrbox\lrbox 320 \let\endglrbox\endlrbox 321 \patchcmd{\glrbox} 322 {\setbox} 323 {\global\setbox} 324 {} 325 {\thesis@patch@error{Package}{Patch failed, can't make a global lrbox.}} 326 327 \NewDocumentCommand\thesis@define@assumption{m m +m}{ 328 \expandafter\gdef\csname hyp:#1\endcsname{% 329 \begin{minipage}[t]{\linewidth}% 330 \textbf{Assumption} \hypothesis{#2}\textbf{: }% 331 \em\ignorespaces% 332 #3% 333 \end{minipage}% 334 }% 335 } 336 337 \NewDocumentEnvironment{assumption}{O{#2} m +b} 338 {% 339 \protected@write\@auxout{}{% 340 \string\thesis@define@assumption{#1}{#2}{\unexpanded{#3}}% 341 \string\expandafter\xdef\string\csname\space sec:assumption:#1\string\endcsname{\thesubsection}% 342 }% 343 \thesis@define@assumption{#1}{#2}{#3}% 344 \phantomsection% 345 \label{assumption:#1}% 346 \expandafter\xdef\csname sec:assumption:#1\endcsname{\thesubsection}% 347 \typeassumption{#1}% 348 } 349 350 \NewDocumentEnvironment{refAssumptionSection}{m}{% 351 \hyperref[assumption:#1]{% 352 \ifcsname sec:assumption:#1\endcsname% 353 \csname sec:assumption:#1\endcsname% 354 \else% 355 \textbf{??}% 356 \thesis@warning{Reference to undefined assumption #1.} 357 \fi% 358 }% 359 } 360 361 362 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 363 %%% Lua libraries interface %%%%%%%%%%%%%%%%%%%%%% 364 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 365 366 \directlua{render = require("lib/render")} 367 \NewDocumentCommand\renderEmbeddings{m}{\directlua{render.embeddings([[#1]])}} 368 \NewDocumentCommand\renderConfusions{m m m m m m m m}{\directlua{render.confusions("\luatexluaescapestring{\unexpanded{#1}}", "\luatexluaescapestring{\unexpanded{#2}}", "\luatexluaescapestring{\unexpanded{#3}}", "\luatexluaescapestring{\unexpanded{#4}}", "\luatexluaescapestring{\unexpanded{#5}}", "\luatexluaescapestring{\unexpanded{#6}}", "\luatexluaescapestring{\unexpanded{#7}}", "\luatexluaescapestring{\unexpanded{#8}}")}} 369 \NewDocumentCommand\renderDegrees{m}{\directlua{render.degrees([[#1]])}} 370 371 372 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 373 %%% TikZ setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 375 376 \input{lib/memory network.def} 377 \input{lib/plate diagram.def} 378 \input{lib/distribution output.def} 379 380 381 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 382 %%% Font setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 384 385 \newfontfamily\greekFont{GFS Didot Classic}[Ligatures=TeX] 386 \languageattribute{greek}{ancient} 387 \addto\extrasgreek{\greekFont} 388 389 \newfontfamily\traditionalChineseFont{I.Ming}[Ligatures=TeX,LetterSpace=15,Vertical=Alternates] 390 \NewDocumentCommand\traditionalChinese{m}{\traditionalChineseFont\fontsize{9pt}{11pt}\selectfont #1}