Преглед на файлове

refs/cites donerefs/cites done

Daniel Gruss преди 2 години
ревизия
7164c66a96
променени са 6 файла, в които са добавени 1455 реда и са изтрити 0 реда
  1. 219 0
      figures/TU_Graz_Logo.pdf
  2. BIN
      figures/background.png
  3. 344 0
      generator.php
  4. 400 0
      main.tex.php
  5. BIN
      no_part2.pdf
  6. 492 0
      tugraz_defaults.sty

+ 219 - 0
figures/TU_Graz_Logo.pdf

@@ -0,0 +1,219 @@
+%PDF-1.3
+%âãÏÓ
+2 0 obj
+<<
+/Length 2930
+>>
+stream
+0 0.957 0.569 0 k
+/GS1 gs
+0 31.119 20.745 -20.746 re
+f
+22.819 31.119 20.746 -20.746 re
+f
+q
+1 i 
+0 41.492 112.876 -41.432 re
+W n
+45.641 31.119 20.744 -20.746 re
+f
+10.372 20.746 20.747 -20.686 re
+f
+Q
+35.268 41.492 20.744 -20.746 re
+f
+0.941 0.82 0.808 0.894 k
+1 i 
+75.104 27.791 m
+68.462 27.791 l
+68.462 31.11 l
+85.581 31.11 l
+85.581 27.791 l
+78.94 27.791 l
+78.94 10.417 l
+75.104 10.417 l
+75.104 27.791 l
+f
+q
+0 41.492 112.876 -41.432 re
+W n
+104.828 18.021 m
+104.828 16.774 104.604 15.649 104.156 14.646 c
+103.708 13.643 103.097 12.79 102.321 12.09 c
+101.546 11.387 100.631 10.848 99.57 10.469 c
+98.511 10.088 97.359 9.898 96.115 9.898 c
+94.873 9.898 93.722 10.088 92.661 10.469 c
+91.601 10.848 90.678 11.387 89.895 12.09 c
+89.109 12.79 88.497 13.643 88.061 14.646 c
+87.621 15.649 87.403 16.774 87.403 18.021 c
+87.403 31.11 l
+91.241 31.11 l
+91.241 18.153 l
+91.241 17.648 91.321 17.117 91.485 16.562 c
+91.648 16.008 91.919 15.497 92.298 15.029 c
+92.676 14.563 93.177 14.178 93.801 13.877 c
+94.423 13.576 95.194 13.425 96.115 13.425 c
+97.035 13.425 97.808 13.576 98.431 13.877 c
+99.054 14.178 99.556 14.563 99.934 15.029 c
+100.312 15.497 100.582 16.008 100.746 16.562 c
+100.909 17.117 100.991 17.648 100.991 18.153 c
+100.991 31.11 l
+104.828 31.11 l
+104.828 18.021 l
+f
+83.257 7.566 m
+82.496 7.895 81.511 8.052 80.723 8.052 c
+78.43 8.052 77.162 6.609 77.162 4.734 c
+77.162 2.873 78.401 1.471 80.497 1.471 c
+81.032 1.471 81.456 1.523 81.793 1.602 c
+81.793 3.987 l
+79.71 3.987 l
+79.71 5.43 l
+83.679 5.43 l
+83.679 0.5 l
+82.638 0.238 81.553 0.028 80.497 0.028 c
+77.316 0.028 75.106 1.51 75.106 4.604 c
+75.106 7.737 77.162 9.494 80.497 9.494 c
+81.638 9.494 82.538 9.35 83.383 9.113 c
+83.257 7.566 l
+f
+85.62 6.938 m
+87.296 6.938 l
+87.296 5.403 l
+87.324 5.403 l
+87.408 6.033 88.182 7.095 89.308 7.095 c
+89.491 7.095 89.689 7.095 89.885 7.042 c
+89.885 5.272 l
+89.717 5.363 89.379 5.416 89.04 5.416 c
+87.507 5.416 87.507 3.633 87.507 2.664 c
+87.507 0.186 l
+85.62 0.186 l
+85.62 6.938 l
+f
+93.587 1.312 m
+94.164 1.312 94.614 1.549 94.909 1.916 c
+95.219 2.296 95.304 2.781 95.304 3.306 c
+94.487 3.306 l
+93.644 3.306 92.391 3.175 92.391 2.139 c
+92.391 1.563 92.911 1.312 93.587 1.312 c
+h
+91.376 6.583 m
+92.107 6.898 93.094 7.095 93.896 7.095 c
+96.105 7.095 97.021 6.242 97.021 4.249 c
+97.021 3.384 l
+97.021 2.703 97.035 2.191 97.049 1.693 c
+97.063 1.182 97.091 0.71 97.134 0.186 c
+95.473 0.186 l
+95.402 0.539 95.402 0.985 95.389 1.195 c
+95.359 1.195 l
+94.924 0.448 93.979 0.028 93.122 0.028 c
+91.842 0.028 90.588 0.749 90.588 2.034 c
+90.588 3.043 91.108 3.633 91.827 3.961 c
+92.546 4.289 93.474 4.355 94.263 4.355 c
+95.304 4.355 l
+95.304 5.442 94.783 5.81 93.671 5.81 c
+92.869 5.81 92.066 5.522 91.434 5.076 c
+91.376 6.583 l
+f
+98.569 6.938 m
+104.312 6.938 l
+104.312 5.495 l
+100.707 1.549 l
+104.438 1.549 l
+104.438 0.186 l
+98.414 0.186 l
+98.414 1.615 l
+102.087 5.574 l
+98.569 5.574 l
+98.569 6.938 l
+f
+0 0.957 0.569 0 k
+105.965 6.911 6.911 -6.851 re
+f
+Q
+endstream
+endobj
+3 0 obj
+<<
+/ProcSet [/PDF ]
+/ExtGState <<
+/GS1 4 0 R
+>>
+>>
+endobj
+4 0 obj
+<<
+/Type /ExtGState
+/SA false
+/SM 0.02
+/OP false
+/op false
+/OPM 1
+/BG2 /Default
+/UCR2 /Default
+/HT /Default
+/TR2 /Default
+>>
+endobj
+1 0 obj
+<<
+/Type /Page
+/Parent 5 0 R
+/Resources 3 0 R
+/Contents 2 0 R
+>>
+endobj
+6 0 obj
+<<
+/S /D
+>>
+endobj
+7 0 obj
+<<
+/Nums [0 6 0 R ]
+>>
+endobj
+5 0 obj
+<<
+/Type /Pages
+/Kids [1 0 R]
+/Count 1
+/MediaBox [0 0 113 42]
+>>
+endobj
+8 0 obj
+<<
+/CreationDate (D:20060111234722+13'00')
+/ModDate (D:20060111234722+13'00')
+/Producer (PSNormalizer.framework)
+>>
+endobj
+9 0 obj
+<<
+/Type /Catalog
+/Pages 5 0 R
+/PageLabels 7 0 R
+>>
+endobj
+xref
+0 10
+0000000000 65535 f 
+0000003204 00000 n 
+0000000016 00000 n 
+0000002998 00000 n 
+0000003064 00000 n 
+0000003349 00000 n 
+0000003284 00000 n 
+0000003311 00000 n 
+0000003429 00000 n 
+0000003560 00000 n 
+trailer
+<<
+/Size 10
+/Root 9 0 R
+/Info 8 0 R
+/ID [<99444215e2a4a31d5c4ca09b38102d5e><99444215e2a4a31d5c4ca09b38102d5e>]
+>>
+startxref
+3627
+%%EOF

BIN
figures/background.png


+ 344 - 0
generator.php

@@ -0,0 +1,344 @@
+<?php
+  global $options;
+  $steps = 10;
+  function user_consent($msg,$defaultyes = null,$defaultno = null)
+  {
+    global $options;
+    if (isset($options["-n"]))
+      return false;
+    if ($defaultyes !== null && isset($options[$defaultyes]))
+      return true;
+    if ($defaultno !== null && isset($options[$defaultno]))
+      return false;
+    $response = false;
+    do
+    {
+      echo "$msg (y/n)\n";
+      $response = rtrim(fgets(STDIN));
+      if ($response === "n" || $response == "N")
+        return false;
+    } while ($response !== "y" && $response !== "Y" && $response !== "");
+    return true;
+  }
+  function user_prompt($msg,$default)
+  {
+    global $options;
+    echo "$msg [Default: $default]\n";
+    $response = "";
+    if (!isset($options["-n"]))
+      $response = rtrim(fgets(STDIN));
+    if ($response == "")
+      $response = $default;
+    echo "You entered: '$response'\n";
+    return $response;
+  }
+  function print_help()
+  {
+    $name = basename(__FILE__);
+    echo<<<END
+Usage: php $name /path/folder1/main.tex /path/folder2/article.tex ... /path/folderN/paper.tex\n
+Generate a thesis template from the provided paper tex files and folders.
+
+The absolute minimum for a cumulative thesis is currently 3 papers first-authored and 6 in total.
+
+--force-overwrite        overwrite files and folders
+--no-overwrite           do not overwrite files and folders
+--no-compile-check       do not perform a compile check
+--use-backups            restore backups before making changes
+-n                       skip all prompts (implies --no-overwrite)
+--help                   display this help and exit
+END;
+    exit(0);
+  }
+  function error_exit($msg,$usage = false)
+  {
+    echo "ERROR: $msg\n";
+    if ($usage)
+      echo "Usage: php ".basename(__FILE__)." /path/folder1/main.tex /path/folder2/article.tex ... /path/folderN/paper.tex\n";
+    exit(-1);
+  }
+  function check_software()
+  {
+    if (!str_starts_with(shell_exec("latexmk --version"),"Latexmk,"))
+      error_exit("latexmk not installed");
+    if (!str_starts_with(shell_exec("pdftotext --help 2>&1"),"pdftotext version"))
+      error_exit("pdftotext not installed");
+  }
+  function rrmdir($dir) {
+    if (is_dir($dir)) {
+      $files = scandir($dir);
+      foreach ($files as $file)
+      if ($file != "." && $file != "..") rrmdir("$dir/$file");
+      rmdir($dir);
+    }
+    else if (file_exists($dir)) unlink($dir);
+  }
+  function rcopy($src, $dst) {
+    if (file_exists($dst)) rrmdir($dst);
+    if (is_dir($src)) {
+      mkdir($dst);
+      $files = scandir($src);
+      foreach ($files as $file)
+      if ($file != "." && $file != "..") rcopy("$src/$file", "$dst/$file"); 
+    }
+    else if (file_exists($src)) copy($src, $dst);
+  }
+  function rscandir($dir,$extensions = []) {
+    $result = [];
+    if (!str_ends_with($dir,"/"))
+      $dir .= "/";
+    if (str_ends_with($dir,"latex.out/"))
+      return $result;
+    $array = scandir($dir);
+    foreach ($array as $item) {
+      if (!str_starts_with($item,"."))
+      {
+        if (!is_dir($dir.$item))
+        {
+          $extension_match = true;
+          if ($extensions != [])
+          {
+            $extension_match = false;
+            foreach ($extensions as $e)
+            {
+              if (str_ends_with($item,"$e"))
+              {
+                $extension_match = true;
+              }
+            }
+          }
+          if ($extension_match)
+            $result[] = $dir.$item;
+        }
+        else
+          $result = array_merge($result, rscandir($dir.$item,$extensions));
+      }
+    }
+    return $result;
+  }
+  function unique_targets($targets)
+  {
+    $parts_required = 1;
+    $unique_targets = [];
+    while (count($unique_targets) != count($targets))
+    {
+      foreach ($targets as $t)
+      {
+        $tparts = explode("/",$t);
+        $tpcount = count($tparts);
+        $tparts = array_splice($tparts,$tpcount-$parts_required,$parts_required);
+        $t = implode("_",$tparts);
+        if (isset($unique_targets[$t]))
+        {
+          $parts_required++;
+          $unique_targets = [];
+          break;
+        }
+        $unique_targets[$t] = 1;
+      }
+    }
+    return array_keys($unique_targets);
+  }
+  function check_folders($argv)
+  {
+    $args = array_slice($argv,1);
+    $sourcedirs = [];
+    foreach ($args as $a)
+    {
+      if (!str_starts_with($a,"-"))
+        $sourcedirs[] = $a;
+    }
+    if (count($sourcedirs) < 1)
+    {
+      error_exit("Too few papers. Need at least one paper to run this.",true);
+    }
+    if (count($sourcedirs) < 3)
+    {
+      echo "Warning: Too few papers. The statutes require as an absolute minimum for a cumulative thesis at least 3 first-author papers and at least 6 in total.";
+    }
+    if (count($sourcedirs) < 5)
+    {
+      echo "Warning: Few papers. Check your institute guidelines to see how many papers are recommended. Also the statutes require as an absolute minimum for a cumulative thesis at least 6 papers in total.";
+    }
+    $texfiles = [];
+    for ($i = 0; $i < count($sourcedirs); $i++)
+    {
+      $texfiles[$i] = basename($sourcedirs[$i]);
+      $sourcedirs[$i] = dirname($sourcedirs[$i]);
+    }
+    $targets = unique_targets($sourcedirs);
+    return [$targets,$texfiles,$sourcedirs];
+  }
+  function check_and_copy_folders($argv)
+  {
+    [$targets,$texfiles,$sourcedirs] = check_folders($argv);
+    //echo "Source -> Target Directory Mapping:\n";
+    $mapping = array_combine($sourcedirs,$targets);
+    //print_r($mapping);
+    foreach ($mapping as $s => $t)
+    {
+      if (!file_exists($s))
+        error_exit("$s not found");
+      if (file_exists($t) && !user_consent("$t already exists... overwrite?","--force-overwrite","--no-overwrite"))
+      {
+        echo "Skipping ".$s.", ".$t." already exists...\n";
+      }
+      else
+      {
+        echo "Copying ".$s." to ".$t."...\n";
+        rcopy($s,$t);
+      }
+    }
+    return array_combine($targets,$texfiles);
+  }
+  function file_get_and_backup($f)
+  {
+    global $options;
+    if (isset($options["--use-backups"]))
+    {
+      if (file_exists("$f.bak"))
+        copy("$f.bak", $f);
+    }
+    $content = file_get_contents("$f");
+    if (!file_exists("$f.bak"))
+      file_put_contents("$f.bak",$content);
+    return $content;
+  }
+  function adjust_references($papers,$extensions = [])
+  {
+    foreach ($papers as $d => $f)
+    {
+      $tex = file_get_and_backup("$d/$f");
+      $files = rscandir($d,$extensions);
+      foreach ($files as $file)
+      {
+        if (str_ends_with($file,".bib"))
+        {
+          $bib = file_get_and_backup($file);
+          $bib = preg_replace("/(^\s*@\s*[a-z]+\s*\{\s*)((?!$d)\S)/i",'${1}'.$d.':${2}',$bib);
+          $bib = preg_replace("/(\n\s*@\s*[a-z]+\s*\{\s*)((?!$d)\S)/i",'${1}'.$d.':${2}',$bib);
+          file_put_contents($file,$bib);
+        }
+        else
+        {
+          $tex = file_get_and_backup($file);
+          // labels of lstlistings etc
+          $tex = preg_replace("/([\[,]\s*label\s*=\s*)((?!$d)[^\[,]+[\[,])/i",'${1}'.$d.':${2}',$tex);
+          // normal labels
+          $tex = preg_replace("/(\\\label\s*\{\s*)((?!$d)[^}]+\})/i",'${1}'.$d.':${2}',$tex);
+          // cref ref autoref
+          $refs = [];
+          preg_match_all("/\\\(cref|ref|autoref)\s*\{\s*[^}]+\}/i",$tex,$refs);
+          foreach ($refs[0] as $ref)
+          {
+            $oldref = $ref;
+            $ref = preg_replace("/([{,])\s*((?!$d)[^,}]+[},])/i",'${1}'.$d.':${2}',$ref);
+            $ref = preg_replace("/([{,])\s*((?!$d)[^,}]+[},])/i",'${1}'.$d.':${2}',$ref);
+            $tex = str_replace($oldref,$ref,$tex);
+          }
+          // cite citeA citeauthor etc
+          $cites = [];
+          preg_match_all("/\\\([a-z]*cite[a-z]*)\s*\{\s*[^}]+\}/i",$tex,$cites);
+          foreach ($cites[0] as $cite)
+          {
+            $oldcite = $cite;
+            $cite = preg_replace("/([{,])\s*((?!$d)[^,}]+[},])/i",'${1}'.$d.':${2}',$cite);
+            $cite = preg_replace("/([{,])\s*((?!$d)[^,}]+[},])/i",'${1}'.$d.':${2}',$cite);
+            $tex = str_replace($oldcite,$cite,$tex);
+          }
+          file_put_contents($file,$tex);
+        }
+      }
+    }
+    return array();
+  }
+  function check_options($argv)
+  {
+    $options = [];
+    foreach ($argv as $a)
+    {
+      if (str_starts_with($a,"-"))
+        $options[$a] = 1;
+      if ($a == "-n")
+        $options["--no-overwrite"] = 1;
+    }
+    return $options;
+  }
+  function compile_check($papers,$precopy = false)
+  {
+    if ($precopy)
+      $papers = array_combine($papers,$papers);
+    foreach ($papers as $p => $f)
+    {
+      echo "======= Paper $p -> $f START =======\n";
+      if ($precopy)
+      {
+        echo "$p\n";
+        if (strpos($p,"/") === false || str_starts_with($p,".") || !is_dir(dirname($p)))
+          continue;
+        $f = basename($p);
+        $p = dirname($p);
+      }
+      else
+      {
+        shell_exec("cd $p; latexmk -c 2>/dev/null; latexmk -C 2>/dev/null; rm -f *.bbl");
+      }
+      $str = shell_exec("cd $p; latexmk -latexoption=\"-shell-escape\" -g -pdf $f 2>&1");
+      $lines = explode("\n",$str);
+      $skip = true;
+      $failed = false;
+      foreach($lines as $l)
+      {
+        if (str_starts_with($l,"Latexmk: ====List of undefined refs and citations:"))
+          $skip = false;
+        if ($skip)
+          continue;
+        if (stripos($l,"fail") !== false)
+          $failed = true;
+        echo "$l\n";
+      }
+      if ($failed || user_consent("Please check the PDF file. Are there any problems with invalid references to figures, tables or with the bibliography?","--","--no-overwrite"))
+        error_exit("The paper did not compile properly, please fix the errors next before continuing.");
+      echo "======= Paper $p -> $f  END  =======\n";
+    }
+  }
+  check_software();
+  $options = check_options($argv);
+  if (isset($options["--help"]))
+    print_help();
+  echo "\n=== Step 1/$steps: Check Folders ===\n\n";
+  [$targets,$texfiles,$sourcedirs] = check_folders($argv);
+  echo "\n=== Step 2/$steps: Pre-Copy Compile Check ===\n\n";
+  $targets_exist = true;
+  foreach ($targets as $t)
+    if (!is_dir($t))
+      $targets_exist = false;
+  if (isset($options["--no-compile-check"]) || $targets_exist)
+    echo "Skipping...\n";
+  else
+    compile_check($argv,true);
+  echo "\n=== Step 3/$steps: Copying Files ===\n\n";
+  $papers = check_and_copy_folders($argv);
+  echo "\n=== Step 4/$steps: Adjusting References (in *.bib *.tex *.tikz) ===\n\n";
+  $bibresources = adjust_references($papers,[".bib",".tex",".tikz"]);
+  echo "\n=== Step 5/$steps: Compile Check ===\n\n";
+  if (isset($options["--no-compile-check"]))
+    echo "Skipping...\n";
+  else
+    compile_check($papers);
+  echo "\n=== Step 6/$steps: Generate main.tex ===\n\n";
+  $thesis_type = user_prompt("Enter Thesis Type ","PhD Thesis");
+  $thesis_title = user_prompt("Enter Thesis Title ","Security of TODO");
+  $thesis_part1_title = user_prompt("Enter Introductory Part Title ","Introduction to the Security of TODO");
+  $thesis_author = user_prompt("Enter Your Name ","Harry Potter");
+  $thesis_date = user_prompt("Enter Prospective Defense Month", "July 1998");
+  $thesis_institute = user_prompt("Enter Your Institute","Institute for Applied Information Processing and Communications");
+  ob_start();
+  require "main.tex.php";
+  $maintex_content = ob_get_contents();
+  ob_end_clean();
+  if (!file_exists("main.bib"))
+    file_put_contents("main.bib","");
+  //if (!file_exists("main.tex") || user_consent("main.tex already exists. overwrite?")) // TODO: enable this check
+  file_put_contents("main.tex",$maintex_content);
+?>

+ 400 - 0
main.tex.php

@@ -0,0 +1,400 @@
+\documentclass[paper=a4,fontsize=11pt,twoside,titlepage,parskip=half-,openright]{scrbook}
+\usepackage[utf8]{inputenc}
+\usepackage[paperwidth=15.5cm,
+            paperheight=23.5cm,
+            lmargin = 2.1cm,
+            rmargin = 1.2cm,
+            top = 2.2cm,
+            headsep = 0.6cm,
+            textheight = 19.3cm,
+            footskip = 1.0cm]{geometry}
+
+\usepackage{moresize}
+\usepackage{tugraz_defaults}
+\usepackage{pdfpages}
+\usepackage{csquotes}
+\usepackage{enumitem}
+%\usepackage[hidelinks]{hyperref}
+\usepackage{subcaption}
+\usepackage{mdframed}
+
+\usepackage[breakable, theorems, skins]{tcolorbox}
+
+\usepackage[backend=biber,
+            url=true,
+            style=numeric,
+            giveninits=false,
+            maxnames=32,
+            minnames=32,
+            maxcitenames=2,
+            mincitenames=1,
+            backref=true, %
+           ]{biblatex}
+\addbibresource{main.bib}
+<?php echo $bibresources; ?>
+\usepackage[acronym]{glossaries}
+\DeclareFieldFormat*{title}{#1} 
+\DeclareFieldFormat*{booktitle}{#1}  
+\DeclareFieldFormat*{journaltitle}{#1}  
+\newcommand{\itemcite}[1]{\begin{itemize}\item \fullcite{#1}\end{itemize}}
+
+
+\usepackage{csquotes}
+\usepackage{graphicx}
+\usepackage[openbib,NoDate]{currvita}
+\usepackage{paralist}
+\preto\fullcite{\AtNextCite{\defcounter{maxnames}{99}}}
+
+
+\usepackage{scrhack}
+\usepackage{quotchap} %
+\usepackage{arydshln}
+
+\DefineBibliographyStrings{english}{%
+  backrefpage = {p.},%
+  backrefpages = {pp.},%
+}
+
+\usepackage[titles]{tocloft}
+\renewcommand\cftchapaftersnum{.}
+\setlength{\cftchapnumwidth}{2em}
+
+\makeatletter
+\frenchspacing
+\widowpenalty=10000
+\clubpenalty=10000
+\setcounter{tocdepth}{1}
+\renewenvironment{table}
+               {\setlength\abovecaptionskip{0\p@}%
+                \setlength\belowcaptionskip{10\p@}%
+                \@float{table}}
+               {\end@float}
+\makeatother
+
+\makeatletter
+\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
+\hbox{} \vspace*{\fill}
+\begin{center}
+\end{center}
+\vspace{\fill} \thispagestyle{empty}
+\newpage
+\if@twocolumn\hbox{}\newpage\fi\fi\fi}
+\makeatother
+
+\usepackage{soul}
+
+\usepackage{titling}
+\usepackage[english]{babel}
+\addto{\captionsenglish}{\renewcommand*{\appendixname}{Appendix}}
+\renewcommand{\algorithmautorefname}{Algorithm}
+\renewcommand\itemautorefname{Step}
+\renewcommand\chapterautorefname{Chapter}
+\renewcommand\sectionautorefname{Section}
+\renewcommand\subsectionautorefname{Section}
+\renewcommand\subsubsectionautorefname{Section}
+
+\usepgfplotslibrary{dateplot}
+\usepgfplotslibrary{fillbetween}
+
+\hyphenation{}
+\usepackage{chngcntr}
+\addtokomafont{disposition}{\rmfamily}
+
+\begin{document}
+%\includepdf[pages=-]{front.pdf}
+\frontmatter
+%\counterwithin{lstlisting}{section}
+\counterwithin{listing}{section}
+\title{<?php echo $thesis_title ?>}
+\author{<?php echo $thesis_author ?>}
+\date{<?php echo $thesis_date ?>}
+%\pagenumbering{gobble}
+
+\newcommand{\tugsq}{\raisebox{0.5ex}{\tikzset{external/export next=false}\tikz{\fill (0,0) rectangle (0.5ex,0.5ex);}}}
+\sodef\so{}{0.45em}{1.4em}{0em}
+
+\begin{titlepage}%
+  \pagestyle{empty}
+\tikzset{external/export next=false}
+  \begin{tikzpicture}[remember picture,overlay]
+    \node at (current page.south west){
+    \tikzset{external/export next=false}
+      \begin{tikzpicture}[remember picture, overlay]
+        \fill[white] (0,0) rectangle (\paperwidth,\paperheight);
+        \shade[shading=axis,bottom color=black!35,top color=white] 
+          (0,0) rectangle (\paperwidth,0.92\paperheight);
+        \node[anchor=south west,inner sep=0pt] at (-2.8,1) {\includegraphics[width=152.5mm]{figures/background.png}};
+      \end{tikzpicture}};
+    \node at (current page.south east){
+    \tikzset{external/export next=false}
+      \begin{tikzpicture}[remember picture, overlay]
+        \node[anchor=north east] at ($({\paperwidth-19cm},1)$) {
+          \color{black}\fontsize{9}{9}\selectfont\so{\sffamily SCIENCE \tugsq{} PASSION \tugsq{} TECHNOLOGY}
+          };
+          \node [anchor=north east] at ($({\paperwidth-16cm},1.4)$) {\resizebox{1in}{!}{
+\includegraphics{figures/TU_Graz_Logo}
+}};
+      \end{tikzpicture}};
+    \node at (current page.east){
+      \begin{tikzpicture}[remember picture, overlay]
+        \node[anchor=east,xshift=-1.075cm,yshift=-3.6cm] (inst) {
+          \color{black}\sffamily <?php echo $thesis_institute ?>
+        };
+            \node[below=of inst.east,anchor=east,yshift=0.4cm] {\sffamily Graz University of Technology};	        
+      \end{tikzpicture}};
+  \end{tikzpicture}
+
+  \vspace{1cm}
+
+  {\sffamily\large\noindent 
+  \theauthor}
+
+  \vspace{0.15cm}
+  \hrule 
+  \vspace{0.3cm}
+
+  {\sffamily\huge\noindent \thetitle}
+
+  \vspace{0.2cm}
+  \hrule
+
+  \vspace{2cm}
+
+  {\sffamily\Large\noindent <?php echo $thesis_type ?>}\\[0.2cm]
+  {\sffamily\noindent <?php echo $thesis_date ?>}\\[0.2cm]
+  \vspace{6cm}
+\end{titlepage}%
+
+%\pagenumbering{arabic}
+
+\cleardoublepage
+
+\addtocontents{toc}{\vspace*{\baselineskip}}
+
+\addtocontents{toc}{\vspace*{\baselineskip}}
+
+\tikzset{external/export next=true}
+\input{abstract}
+
+\cleardoublepage
+
+\tableofcontents
+\addcontentsline{toc}{chapter}{Contents}
+
+\cleardoublepage
+\mainmatter
+
+\addtocontents{toc}{\vspace*{\baselineskip}}
+
+\part[<?php echo $thesis_part1_title ?>]{<?php echo $thesis_part1_title ?>}
+
+\bgroup
+\begin{refsection}
+
+\input{intro}
+
+\begin{sloppypar}
+\printbibliography[title={References}, heading=bibintoc]
+\end{sloppypar}
+\end{refsection}
+\egroup
+
+\addtocontents{toc}{\vspace*{\baselineskip}}
+
+\chapter*{Information on Part II}
+Note that Part II is not included in this PDF. Please download the full version for Part II.
+
+\part{Publications}
+\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
+\renewcommand*\thesection{\arabic{section}}
+
+\bgroup
+\begin{refsection}
+\chapter*{List of Publications}
+\label{sec:publicationlist}
+\addcontentsline{toc}{chapter}{List of Publications}
+
+During my habilitation, I contributed to 33 publications (48 in since I started my PhD), 11 of which are included in this habilitation, as shown below.
+Out of the 33 publications, 16 were top-tier publications (8 included in this habilitation).
+Internationally, only a single person had a higher number of publications at the four top-tier system security conferences in the same time frame.
+
+\newrefcontext[sorting=ydnt]
+\nocite{CV:How2020Fall,CV:Donky2020August,CV:Meltdown2020June,CV:Nethammer2020June,CV:Take2020June,CV:KASLR2020June,CV:LVI2020May,CV:Plundervolt2020May,CV:RAMBleed2020May,CV:ConTExT2020February,CV:Malware2020January,CV:ZombieLoad2019November,CV:Page2019November,CV:Fallout2019November,CV:SGXJail2019September,CV:NetSpectre2019September,CV:Wait2019August,CV:ScatterCache2019August,CV:A2019August,CV:Practical2019June,CV:Store-to-Leak2019May,CV:Spectre2019May,CV:JavaScript2019February,CV:Kernel2018December,CV:Software-based2018November,CV:Software-basierte2018September,CV:Meltdown2018August,CV:Automated2018June,CV:Use-After-FreeMail2018June,CV:ProcHarvester2018June,CV:Another2018May,CV:JavaScript2018February,CV:KeyDrown2018February,CV:Practical2017September,CV:Strong2017August,CV:KASLR2017July,CV:Malware2017July,CV:Software-based2017June,CV:Fantastic2017April,CV:Hello2017February,CV:Prefetch2016October,CV:Drammer2016October,CV:DRAMA2016August,CV:ARMageddon2016August,CV:Rowhammer.js2016July,CV:Flush+Flush2016July,CV:Practical2015September,CV:Cache2015August}
+
+\begin{sloppypar}
+\printbibliography[title={Publications in this Habilitation}, type=inproceedings, heading=subbibliography, keyword={mine}]
+
+\printbibliography[title={Other Contributions}, type=inproceedings, heading=subbibliography, keyword={mine_other}]
+\end{sloppypar}
+
+\end{refsection}
+\egroup
+
+\bgroup
+\begin{refsection}
+
+\input{spectre}
+
+\end{refsection}
+\egroup
+
+\newpage
+\bgroup
+\begin{refsection}
+
+\input{netspectre}
+
+\end{refsection}
+\egroup
+
+\newpage
+\bgroup
+\begin{refsection}
+
+\input{meltdown}
+
+\end{refsection}
+\egroup
+
+\newpage
+\bgroup
+\begin{refsection}
+
+\input{kaiser1}
+
+\end{refsection}
+\egroup
+
+\newpage
+\bgroup
+\begin{refsection}
+
+\input{kaiser2}
+
+\end{refsection}
+\egroup
+
+\newpage
+\bgroup
+\begin{refsection}
+
+\input{prefetch}
+
+\end{refsection}
+\egroup
+
+\newpage
+\bgroup
+\begin{refsection}
+
+\input{systematic}
+
+\end{refsection}
+\egroup
+
+\newpage
+\bgroup
+\begin{refsection}
+
+\input{zombieload}
+
+\end{refsection}
+\egroup
+
+\newpage
+\bgroup
+\begin{refsection}
+
+\input{fallout}
+
+\end{refsection}
+\egroup
+
+\newpage
+\bgroup
+\begin{refsection}
+
+\input{lvi}
+
+\end{refsection}
+\egroup
+
+\newpage
+\bgroup
+\begin{refsection}
+
+\input{context}
+
+\end{refsection}
+\egroup
+
+\cleardoublepage
+
+\appendix 
+\part*{Appendix}
+\addcontentsline{toc}{part}{Appendix}
+
+\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
+\renewcommand*\thesection{\arabic{section}}
+
+\addtocontents{toc}{\vspace*{\baselineskip}}
+
+\chapter*{Curriculum Vitae}
+
+\bgroup
+\begin{refsection}
+\input{cv}
+\end{refsection}
+\egroup
+
+\cleardoublepage
+
+\chapter*{Academic Field ``Applied Computer Science''}
+
+\bgroup
+\begin{refsection}
+
+\input{academicfield}
+
+\end{refsection}
+\egroup
+
+\cleardoublepage
+
+\chapter*{Acknowledgements}
+I have worked with so many wonderful people over the past years, had so many inspiring discussions, and got to know so many extraordinarily clever and kind people that it feels very difficult to write these acknowledgements.
+My feeling is that I surely forgot to mention someone and I will only realize it the week after everything is published and went into print.
+I owe thanks to more people than I can list here by name.
+Instead, if you are reading this: Thank you for the discussions we had, for the beers we shared, the time we spent, and for the papers we wrote together.
+
+First and foremost, I want to thank the head of the Institute of Applied Information Processing and Communications, Stefan Mangard, for creating an excellent working environment, supporting my research group, and inspiring me to be ambitious and strive for excellence in research.
+Thank you for your guidance on how to lead research and research groups.
+
+This habilitation would not have been possible in this time frame without my extraordinary research group: Michael Schwarz (now at CISPA), Moritz Lipp, Claudio Canella, Martin Schwarzl, Lukas Giner, Catherine Easdon, and Andreas Kogler.
+I tried to get the best people into my research group, the most clever, most productive, most empathetic, most kind.
+I must have succeeded.
+It is a pleasure to spend time with you every day.
+
+I want to thank all the master and bachelor students that have worked in our group over the past years.
+One of the most important reasons for staying in Graz was the excellent environment here, and that includes you, students.
+It is amazing and impressive to see you contributing to our research projects.
+
+I also owe thanks to my teaching assistants and co-lecturers.
+Attracting the best students to our group requires to have excellent positive visibility in lectures.
+Your incredible support for the students, your motivation, and the ambition we share, to make our classes the best experience possible, was the basis for winning the prize for excellence in teaching.
+
+I want to thank my co-authors from all the collaborations, colleagues from our institute, and from other universities and industry, in particular Jo Van Bulck, Daniel Moghimi, Frank Piessens, Berk Sunar, and Anders Fogh.
+I want to thank Thorsten Holz, Thomas Eisenbarth, and Frank Piessens for giving me the opportunity to visit their institutions during my habilitation.
+
+I want to thank the industry partners that funded my research group in the last years and made this research possible: Intel, Arm, Amazon, Cloudflare, and Red Hat.
+It was great to have the opportunity to work on problems we are all interested in and to engage in interesting and enlightening discussions with many clever people.
+
+I want to thank my fiancée Maria Eichlseder for her love and patience with me.
+Thank you for supporting me and (still) tolerating my healthy work-job balance.
+
+Finally, I would like to thank my friends, my fiancée's and my family, and my cats for both supporting my work and distracting me from it in the past years.
+
+%\includepdf[pages=-]{back.pdf}
+
+\end{document}
+

BIN
no_part2.pdf


+ 492 - 0
tugraz_defaults.sty

@@ -0,0 +1,492 @@
+\ProvidesPackage{tugraz_defaults}
+%\usepackage[hyphens]{url}
+\PassOptionsToPackage{bookmarks,hidelinks}{hyperref}
+\usepackage{hyperref}
+\hypersetup{breaklinks=true}
+\usepackage[utf8]{inputenc}
+
+% \usepackage[table,dvipsnames]{xcolor}
+\usepackage{amsmath}	% defined by ACM
+\usepackage{amssymb}	% defined by ACM
+\usepackage{array}		% defined by ACM
+\usepackage{arydshln}
+\usepackage{booktabs}	% defined by ACM
+% \usepackage{cite} % to sort citations
+\usepackage{collcell}
+\usepackage{comment}
+\usepackage{float}
+\usepackage{ifthenx}
+\usepackage{lipsum}
+\usepackage{makecell}
+\usepackage{multirow}
+\usepackage{adjustbox}
+\usepackage{multicol}
+\usepackage{nicefrac}
+\usepackage{paralist}
+\usepackage{csquotes}
+%\usepackage{flushend}
+% \usepackage{upgreek}
+\usepackage{siunitx}
+\sisetup{detect-weight=true,binary-units=true,group-separator = \text{\,}}
+\usepackage{threeparttable}
+% \PassOptionsToPackage{table}{xcolor}\usepackage{xcolor}
+\usepackage{xspace}
+\usepackage{placeins}
+% \usepackage[numbers,sort&compress]{natbib}
+\def\subheading#1{\medskip\noindent{\boldmath\textbf{#1}}~\ignorespaces}
+
+\usepackage{tabularx}
+\newcolumntype{Y}{>{\centering\arraybackslash}X}
+\usepackage{xcolor}
+\usepackage{fdsymbol}
+
+% ------------------------------
+% Fancy plots
+\usepackage{tikz}
+\usetikzlibrary{external}
+%\tikzexternalize[prefix=tikz/,only named=true,mode=list and make] % TODO
+\usepackage{pgfplots}
+\usepackage{pgfplotstable}
+\usetikzlibrary{pgfplots.groupplots}
+\usetikzlibrary{arrows}
+\usetikzlibrary{patterns}
+\usetikzlibrary{positioning}
+\usetikzlibrary{decorations.pathreplacing}
+\usetikzlibrary{shapes.arrows}
+\usetikzlibrary{shapes.geometric,shapes.misc}
+\usetikzlibrary{pgfplots.groupplots}
+\pgfplotsset{compat=newest}
+% ------------------------------
+
+
+% ------------------------------
+% Fancy captions
+\usepackage{caption}
+\usepackage{subcaption}
+\captionsetup{compatibility=false}
+\captionsetup[figure]{aboveskip=0.5em, belowskip=0.5em,labelfont={small},font={small}} 
+%\captionsetup[subfigure]{skip=10pt,labelfont={bf,normal},font={bf,normal}}
+\captionsetup[table]{aboveskip=0.5em, belowskip=0.5em,labelfont={small},font={small}}
+\captionsetup[lstlisting]{labelformat=simple,skip=5pt,labelfont={small},font={small}}
+\captionsetup[subfloat]{font={small}}
+% ------------------------------
+
+\definecolor{lukasred}{HTML}{950000}
+\definecolor{andreasgreen}{HTML}{e9f5db}
+\definecolor{vsblack}{cmyk}{0,0,0,1}             
+\definecolor{vswhite}{HTML}{24292e}
+\definecolor{vsbackground}{HTML}{ffffff}    %background in Visual Studio
+\definecolor{vscomment}{HTML}{047f04}       %comments in Visual Studio
+\definecolor{vskeyword}{HTML}{0024fe}       %keywords in Visual Studio
+\definecolor{vsstring}{cmyk}{0,0.26,0.38,0} %strings in Visual Studio
+\definecolor{vsctrlflow}{HTML}{ad1eda}      %if/else,switch/case etc. in Visual Studio
+\definecolor{vslocalvar}{HTML}{001780}      %local variables in Visual Studio
+\definecolor{vsclass}{HTML}{1d809d}         %class types in Visual Studio
+\definecolor{vsfunctions}{HTML}{7a5d27}     %enumerations and methods in Visual Studio
+
+% ------------------------------
+% Fancy notes
+\usepackage{letltxmacro}
+\setlength{\marginparwidth}{1.5cm}
+%\reversemarginpar
+\usepackage{todonotes}
+\usepackage{marginnote} 
+\let\marginpar\marginnote
+\LetLtxMacro{\oldtodo}{\todo}
+\renewcommand{\todo}[2][]{\tikzexternaldisable\oldtodo[fancyline,size=\footnotesize,#1]{#2}\tikzexternalenable}
+\renewcommand{\todo}[1]{\tikzexternaldisable\oldtodo[fancyline,size=\footnotesize]{#1}\tikzexternalenable}
+\newcommand{\noted}[2][]{\tikzexternaldisable\oldtodo[color=red!40,fancyline,size=\footnotesize,#1]{\textbf{Da} #2}\tikzexternalenable}
+\renewcommand{\noted}[1]{\tikzexternaldisable\oldtodo[color=red!40,fancyline,size=\footnotesize]{\textbf{Da} #1}\tikzexternalenable}
+\newcommand{\notey}[2][]{\tikzexternaldisable\oldtodo[color=violet!40,fancyline,size=\footnotesize,#1]{\textbf{Y} #2}\tikzexternalenable}
+\renewcommand{\notey}[1]{\tikzexternaldisable\oldtodo[color=violet!40,fancyline,size=\footnotesize]{\textbf{Y} #1}\tikzexternalenable}
+\newcommand{\notema}[2][]{\tikzexternaldisable\oldtodo[color=blue!40,fancyline,size=\footnotesize,#1]{\textbf{Ma} #2}\tikzexternalenable}
+\renewcommand{\notema}[1]{\tikzexternaldisable\oldtodo[color=blue!40,fancyline,size=\footnotesize]{\textbf{Ma} #1}\tikzexternalenable}
+\newcommand{\notel}[2][]{\tikzexternaldisable\oldtodo[color=lukasred,fancyline,size=\footnotesize,#1]{\textbf{L} #2}\tikzexternalenable}
+\renewcommand{\notel}[1]{\tikzexternaldisable\oldtodo[color=lukasred,fancyline,size=\footnotesize]{\textbf{L} #1}\tikzexternalenable}
+\newcommand{\notea}[2][]{\tikzexternaldisable\oldtodo[color=andreasgreen,fancyline,size=\footnotesize,#1]{\textbf{A} #2}\tikzexternalenable}
+\renewcommand{\notea}[1]{\tikzexternaldisable\oldtodo[color=andreasgreen,fancyline,size=\footnotesize]{\textbf{A} #1}\tikzexternalenable}
+\newcommand{\notej}[2][]{\tikzexternaldisable\oldtodo[color=blue!40,fancyline,size=\footnotesize,#1]{\textbf{J} #2}\tikzexternalenable}
+\renewcommand{\notej}[1]{\tikzexternaldisable\oldtodo[color=blue!40,fancyline,size=\footnotesize]{\textbf{J} #1}\tikzexternalenable}
+\newcommand{\notef}[2][]{\tikzexternaldisable\oldtodo[color=yellow!40,fancyline,size=\footnotesize,#1]{\textbf{F} #2}\tikzexternalenable}
+\renewcommand{\notef}[1]{\tikzexternaldisable\oldtodo[color=yellow!40,fancyline,size=\footnotesize]{\textbf{F} #1}\tikzexternalenable}
+\newcommand{\notes}[2][]{\tikzexternaldisable\oldtodo[color=orange!40,fancyline,size=\footnotesize,#1]{\textbf{S} #2}\tikzexternalenable}
+\renewcommand{\notes}[1]{\tikzexternaldisable\oldtodo[color=orange!60,fancyline,size=\footnotesize]{\textbf{S} #1}\tikzexternalenable}
+
+
+\newcommand{\TODO}{\hl{TODO}\xspace }
+
+% ------------------------------
+
+% ------------------------------
+% Fancy figures
+\usepackage{xparse}
+\setdefaultleftmargin{1.5em}{}{}{}{.5em}{.5em}
+\NewDocumentEnvironment{figureA}{omo}{\begin{figure}[#1]\tikzsetnextfilename{#2}\centering}{\IfNoValueTF {#3}{}{\caption{#3}}\label{fig:#2}\end{figure}}
+\NewDocumentEnvironment{subfigureA}{ommo}{\begin{subfigure}[#1]{#2}\tikzsetnextfilename{#3}\centering}{\IfNoValueTF {#4}{}{\caption{#4}}\label{fig:#3}\end{subfigure}}
+\NewDocumentEnvironment{figureA*}{omo}{\begin{figure*}[#1]\tikzsetnextfilename{#2}\centering}{\IfNoValueTF {#3}{}{\caption{#3}}\label{fig:#2}\end{figure*}}
+\NewDocumentEnvironment{subfigureA*}{ommo}{\begin{subfigure*}[#1]{#2}\tikzsetnextfilename{#3}\centering}{\IfNoValueTF {#4}{}{\caption{#4}}\label{fig:#3}\end{subfigure*}}
+% ------------------------------
+
+% ------------------------------
+% Fancy algorithms and code
+\usepackage{algorithmic}
+\usepackage[ruled]{algorithm2e}
+\usepackage{listings}
+\newfloat{listing}{tbhp}{lst}%[section]
+\floatname{listing}{Listing}
+\lstset{ %
+  backgroundcolor=\color{vsbackground},
+  basicstyle=\scriptsize\bf\ttfamily\upshape\color{vswhite},
+  belowcaptionskip=1\baselineskip,
+  breakatwhitespace=true,
+  breakautoindent=false,
+  breakindent=0pt,
+  breaklines=true,                 % sets automatic line breaking
+  captionpos=b,                    % sets the caption-position to bottom
+  columns=fixed,
+  commentstyle=\color{vscomment},
+  emphstyle={[2]\color{vslocalvar}},
+  emphstyle={[3]\color{vsclass}},
+  emphstyle={[4]\color{vsfunctions}},
+  emphstyle=\color{vsctrlflow},
+  escapeinside={(*@}{@*)},
+  extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
+  frame=single,                    % adds a frame around the code
+  %framesep=5pt,
+  framexleftmargin=13pt,
+  framexrightmargin=-20.5pt,
+  keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
+  keywordstyle=\color{vskeyword},
+  language=C,                      % the language of the code
+  %linewidth=\listingwidth,
+  morecomment=[s][\color{vscomment}]{/*-}{*/},
+  morecomment=[s][\color{vscomment}]{/*+}{*/},
+  numbers=left,                    % where to put the line-numbers; possible values are (none, left, right)
+  numbersep=4pt,                   % how far the line-numbers are from the code
+  numberstyle=\tiny\bf\color{vsblack}, 
+  postbreak=\mbox{\textcolor{red}{->}\space},
+  rulecolor=\color{black},         % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
+  rulecolor=\color{vsbackground},
+  rulesep=0pt,
+  showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
+  showstringspaces=false,          % underline spaces within strings only
+  showtabs=false,                  % show tabs within strings adding particular underscores
+  stringstyle=\color{vsstring},
+  tabsize=2,                       % sets default tabsize to 2 spaces
+  xleftmargin=10pt,
+  xrightmargin=10pt
+}
+\lstdefinelanguage
+   [x64]{Assembler}     % add a "x64" dialect of Assembler
+   [x86masm]{Assembler} % based on the "x86masm" dialect
+   % with these extra keywords:
+   {morekeywords={CDQE,CQO,CMPSQ,CMPXCHG16B,JRCXZ,LODSQ,MOVSXD, %
+                  POPFQ,PUSHFQ,SCASQ,STOSQ,IRETQ,RDTSCP,SWAPGS, %
+                  rax,rdx,rcx,rbx,rsi,rdi,rsp,rbp, %
+                  r8,r8d,r8w,r8b,r9,r9d,r9w,r9b}} % etc.
+
+\lstdefinestyle{cpp}
+{
+  language=c++,
+  % syntax higlights
+  morekeywords={partial, var, value, get, set, uint64\_t, func},
+  % control flow 
+  emph={if, else, return, throw, switch, case, for, repeat},
+  % local vars
+  emph={[2]start, end, samples, N, L, cache\_line, victim_cache_line,KEY_FLAG_REVOKED,keyring,ns},
+  % class and structs
+  emph={[3]SomeOwnClassType, Measurement, Sample, key},
+  % functions
+  emph={[4]measure,fill,ioctl,measure_power,record_sample,diff,access,find\_keyring\_by\_name,list\_for\_each\_entry,test\_bit,kuid_has_mapping,keyctl_join_session_keyring,KEYCTL_JOIN_SESSION_KEYRING},
+}
+\usepackage{fancyvrb}
+
+
+\lstdefinestyle{asm}
+{
+  language={[x64]Assembler},
+  % syntax higlights
+  morekeywords={ud2,syscall,movq,prefetcht0},
+  % control flow 
+  emph={},
+  % local vars
+  emph={[2]victim\_cache\_line,MSR\_PKG\_POWER\_LIMIT},
+  % class and structs
+  emph={[3]rip,rax,rdx,eax,rsp},
+  % functions
+  emph={[4]module\_ioctl,misspeculation,retpoline,retpoline\_end},
+}
+
+\newcommand\Highlight[1]{\underline{\textcolor{red}{#1}}}
+\newcommand\HighlightB[1]{\textbf{\textcolor{blue}{#1}}}
+
+\newcommand\HighlightD[1]{{\textcolor{green!80!black}{#1}}}
+
+\newenvironment{Plain}[1][]
+  { \VerbatimEnvironment%
+    \begin{Verbatim}[#1]}
+  { \end{Verbatim}  } 
+
+% ------------------------------
+
+% ------------------------------
+% New commands
+\newcommand{\gbr}[1]{\left\{#1\right\}}
+%\DeclareMathOperator{\KB}{KB}
+\newcommand{\SIx}[1]{\num{#1}\relax}
+%\DeclareMathOperator*{\argmax}{arg\,max}
+%\DeclareMathOperator*{\argmin}{arg\,min}
+\newcommand{\xor}{\oplus}
+\newcommand{\etal}{et~al.\ } % typography nerd
+\newcommand{\ie}{\textit{i.e.},\ } % typography nerd
+\newcommand{\eg}{e.g.,\ } % typography nerd
+\newcommand{\cf}{cf.\ } % typography nerd
+\newcommand{\KeyDrown}{\emph{KeyDrown}\xspace}
+\newcommand{\FlushOnly}{Flush+Flush\xspace}
+\newcommand{\clflush}{\texttt{clflush}\xspace}
+\newcommand{\FlushReload}{Flush+\allowbreak Reload\xspace}
+\newcommand{\EvictReload}{Evict+\allowbreak Reload\xspace}
+\newcommand{\EvictTime}{Evict+\allowbreak Time\xspace}
+\newcommand{\PrimeProbe}{Prime+\allowbreak Probe\xspace}
+\newcommand{\MultiPrimeProbe}{Multi-\allowbreak Prime+\allowbreak Probe\xspace}
+\newcommand{\FlushFlush}{Flush+\allowbreak Flush\xspace}
+\newcommand{\GTKplus}{\emph{GTK+}\xspace}
+\newcommand{\libgdk}{\emph{libgdk}\xspace}
+\newcommand{\OnePlus}{OnePlus 3t\xspace}
+\newcommand{\FScore}{F-score\xspace}
+
+\newcommand{\ReqOne}{\emph{R1}\xspace}
+\newcommand{\ReqTwo}{\emph{R2}\xspace}
+\newcommand{\ReqThree}{\emph{R3}\xspace}
+
+\usepackage{pifont}
+\newcommand{\xmark}{\leavevmode{\color{red}\ding{55}}}%
+\newcommand{\cmark}{\leavevmode{\color{TolDarkGreen}\ding{51}}}%
+\newcommand{\tmark}{\leavevmode{\color{orange!90!red}\large $\mathbf{\thicksim}$}}%
+\mathchardef\mhyphen="2D
+\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
+            \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}
+\newcommand*\circledb[1]{\tikz[baseline=(char.base)]{
+            \node[shape=circle,draw,inner sep=2pt,fill=black,text=white] (char) {#1};}}
+\newcommand*\circleds[1]{\tikz[baseline=(char.base)]{
+            \node[shape=circle,draw,inner sep=1pt] (char) {\footnotesize #1};}}
+\newcommand*\circledsb[1]{\tikz[baseline=(char.base)]{
+            \node[shape=circle,draw,inner sep=0.7pt,fill=black,text=white] (char) {\footnotesize #1};}}
+% ------------------------------
+
+
+\newcommand{\FakeMarker}{{\color{red}$\blacktriangle$}}
+\newcommand{\RealMarker}{{\color{green}$\bullet$}}
+
+\newfloat{lstfloat}{htbp}{lop}
+\floatname{lstfloat}{Listing}
+
+\usepackage{epsdice}
+\usepackage{soul}
+\usepackage[noabbrev,capitalize]{cleveref}
+
+% correct bad hyphenation here
+\hyphenation{op-tical net-works semi-conduc-tor row-ham-mer}
+
+\widowpenalty10000
+\clubpenalty10000
+
+% plot default colors
+\definecolor{TolDarkPurple}{HTML}{332288}
+\definecolor{TolDarkBlue}{HTML}{6699CC}
+\definecolor{TolLightBlue}{HTML}{88CCEE}
+\definecolor{TolLightGreen}{HTML}{44AA99}
+\definecolor{TolDarkGreen}{HTML}{117733}
+\definecolor{TolDarkBrown}{HTML}{999933}
+\definecolor{TolLightBrown}{HTML}{DDCC77}
+\definecolor{TolDarkRed}{HTML}{661100}
+\definecolor{TolLightRed}{HTML}{CC6677}
+\definecolor{TolLightPink}{HTML}{AA4466}
+\definecolor{TolDarkPink}{HTML}{882255}
+\definecolor{TolLightPurple}{HTML}{AA4499}
+
+% plot
+\definecolor{PlotColorBlue}{HTML}{2C7FB8}
+\definecolor{PlotColorRed}{HTML}{F03B20}
+\definecolor{PlotColorGreen}{HTML}{31A354}
+
+% colors
+\definecolor{red}{HTML}{F03B20}
+\definecolor{yellow}{HTML}{F5EE9A}
+\definecolor{green}{HTML}{BEDB39}
+\definecolor{blue}{HTML}{2C7FB8}
+
+
+\pgfplotscreateplotcyclelist{mbarplot cycle}{%
+  {draw=TolDarkBlue,    fill=TolDarkBlue!70},
+  {draw=TolLightBrown,  fill=TolLightBrown!70},
+  {draw=TolLightGreen,  fill=TolLightGreen!70},
+  {draw=TolDarkPink,    fill=TolDarkPink!70},
+  {draw=TolDarkPurple,  fill=TolDarkPurple!70},
+  {draw=TolDarkRed,     fill=TolDarkRed!70},
+  {draw=TolDarkBrown,   fill=TolDarkBrown!70},
+  {draw=TolLightRed,    fill=TolLightRed!70},
+  {draw=TolLightPink,   fill=TolLightPink!70},
+  {draw=TolLightPurple, fill=TolLightPurple!70},
+  {draw=TolLightBlue,   fill=TolLightBlue!70},
+  {draw=TolDarkGreen,   fill=TolDarkGreen!70},
+}
+
+\pgfplotscreateplotcyclelist{mlineplot cycle}{%
+  {TolDarkBlue, mark=*, mark size=1.5pt},
+  {TolLightBrown, mark=square*, mark size=1.3pt},
+  {TolLightGreen, mark=triangle*, mark size=1.5pt},
+  {TolDarkBrown, mark=diamond*, mark size=1.5pt},
+}
+
+\pgfplotsset{
+  compat=1.9
+}
+\pgfplotsset{
+  mlineplot/.style={
+%     mbaseplot,
+%     xmajorgrids=true,
+%     ymajorgrids=true,
+%     major grid style={dotted},
+%     axis x line=bottom,
+%     axis y line=left,
+%     legend style={
+%       cells={anchor=west},
+%       draw=none
+%     },
+%     cycle list name=mlineplot cycle,
+  },
+}
+
+\pgfplotsset{
+  mbarplot base/.style={
+    mbaseplot,
+    bar width=6pt,
+    axis y line*=none,
+  },
+}
+
+\pgfplotsset{
+  mbarplot/.style={
+    mbarplot base,
+    ybar,
+    xmajorgrids=false,
+    ymajorgrids=true,
+    area legend,
+    legend image code/.code={%
+      \draw[#1] (0cm,-0.1cm) rectangle (0.15cm,0.1cm);
+    },
+    cycle list name=mbarplot cycle,
+  },
+}
+
+\pgfplotsset{
+  horizontal mbarplot/.style={
+    mbarplot base,
+    xmajorgrids=true,
+    ymajorgrids=false,
+    xbar stacked,
+    area legend,
+    legend image code/.code={%
+      \draw[#1] (0cm,-0.1cm) rectangle (0.15cm,0.1cm);
+    },
+    cycle list name=mbarplot cycle,
+  },
+}
+
+\pgfplotsset{
+  mbaseplot/.style={
+    legend style={
+      draw=none,
+      fill=none,
+      cells={anchor=west},
+    },
+    x tick label style={
+      font=\footnotesize
+    },
+    y tick label style={
+      font=\footnotesize
+    },
+    legend style={
+      font=\footnotesize
+    },
+    major grid style={
+      dotted,
+    },
+    axis x line*=bottom,
+  },
+  disable thousands separator/.style={
+    /pgf/number format/.cd,
+      1000 sep={}
+  },
+}
+
+\usepackage{diagbox}
+\usepackage{oplotsymbl}
+
+\LetLtxMacro{\oldcircletfill}{\circletfill}
+\LetLtxMacro{\oldcirclet}{\circlet}
+\LetLtxMacro{\oldcircletfillhl}{\circletfillhl}
+\renewcommand{\circletfill}{\raisebox{-0.9pt}{\tikzsetnextfilename{circletfill}\oldcircletfill}}
+\renewcommand{\circlet}{\raisebox{-0.9pt}{\tikzsetnextfilename{circlet}\oldcirclet}}
+\renewcommand{\circletfillhl}{\raisebox{-0.9pt}{\tikzsetnextfilename{circletfillhl}\oldcircletfillhl}}
+  
+\newcommand{\cmarkfull}{\multicolumn{1}{c} {\circletfill \phantom{*}}}
+\newcommand{\cmarkempty}{\multicolumn{1}{c} {\circlet \phantom{*}}}
+\newcommand{\cmarkhalf}{\multicolumn{1}{c} {\circletfillhl \phantom{*}}}
+
+\newcommand{\cstarletfill}{\multicolumn{1}{c} {\starletfill \phantom{*}}}
+\newcommand{\cstarlet}{\multicolumn{1}{c} {\starlet \phantom{*}}}
+
+\newcommand{\cmarkfulls}{\multicolumn{1}{c} {\circletfill *}}
+\newcommand{\cmarkemptys}{\multicolumn{1}{c} {\circlet *}}
+\newcommand{\cmarkhalfs}{\multicolumn{1}{c} {\circletfillhl *}}
+
+\newcommand{\cmarkfulld}{\multicolumn{1}{c} {\circletfill $^\dagger$}}
+\newcommand{\cmarkemptyd}{\multicolumn{1}{c} {\circlet $^\dagger$}}
+\newcommand{\cmarkhalfd}{\multicolumn{1}{c} {\circletfillhl $^\dagger$}}
+
+% cite authors
+% \newcommand{\citeA}[1]{\citeauthor{#1}~\cite{#1}}
+
+% micro ops
+\newcommand{\muop}{$\mu$OP\xspace}
+\newcommand{\muops}{$\mu$OPs\xspace}
+
+\RequirePackage{titlesec}
+\titlespacing*{\section}{0pt}{1.6ex}{1.2ex}
+\titlespacing*{\subsection}{0pt}{1.3ex}{1ex}
+%\titlespacing*{\subsubsection}{0pt}{0.4ex}{0.05ex}
+
+\lstdefinestyle{python}{
+  language=python,
+  % syntax higlights
+  morekeywords={False, True},
+  % control flow 
+  emph={if, else, return, throw, switch, case, for, repeat, import},
+  % local vars
+  emph={[2]cpu, self, stable_periode, STABLE, PWRSAVE, POWERSAVE},
+  % class and structs
+  emph={[3]SUIT_DOWN_simple, PowerState},
+  % functions
+  emph={[4]__init__, disabled_instruction_ex_handler, timer_interrupt_handler},
+}
+
+
+\lstdefinestyle{cppinline}{
+  style = cpp,
+  basicstyle=\small\bf\ttfamily\upshape\color{vswhite},
+}
+
+\lstdefinestyle{asminline}{
+  style = asm,
+  basicstyle=\small\bf\ttfamily\upshape\color{vswhite},
+}
+
+\lstdefinestyle{pythoninline}{
+  style = python,
+  basicstyle=\small\bf\ttfamily\upshape\color{vswhite},
+}
+\newcommand{\asm}[1]{\lstinline[style=asm]{#1}\xspace}
+\newcommand{\cpp}[1]{\lstinline[style=cpp]{#1}\xspace}
+\newcommand{\py}[1]{\lstinline[style=python]{#1}\xspace}