Daniel Gruss 2 lat temu
rodzic
commit
2c1dd090ea
7 zmienionych plików z 940 dodań i 444 usunięć
  1. 257 0
      cover1.tex.php
  2. 290 0
      cover2.tex.php
  3. BIN
      figures/cover_figure.png
  4. BIN
      flyeralarm-info.pdf
  5. 269 181
      generator.php
  6. 1 116
      main.tex.php
  7. 123 147
      tugraz_defaults.sty

+ 257 - 0
cover1.tex.php

@@ -0,0 +1,257 @@
+\documentclass[fontsize=12pt]{standalone}
+
+\newif\ifdraft\drafttrue % TODO set false for submission
+
+\newif\iftwocol\twocoltrue % front bottom: classic two-column layout
+
+\usepackage[default,semibold]{sourcesanspro}
+\usepackage{soul}
+\sodef\so{}{0.45em}{1.4em}{0em}
+\newcommand{\tugsq}{\raisebox{0.5ex}{\tikz{\fill (0,0) rectangle (0.5ex,0.5ex);}}}
+
+\usepackage{tikz}
+\usetikzlibrary{calc}
+\ifdraft
+  \tikzset{layout/.style={draw,gray}}
+\else
+  \tikzset{layout/.style={}}
+\fi
+
+% TODO your info
+\newcommand{\thesistitle}{<?php echo $thesis_title ?>}
+\newcommand{\thesisauthor}{<?php echo $thesis_author ?>}
+\newcommand{\thesisdate}{<?php echo $thesis_date ?>}
+\iftwocol % front bottom: two text columns
+  \newcommand{\thesisassessors}{Assessors:\par <?php echo str_replace(',','\par',$thesis_assessors) ?>} % bottom layout 2
+\else
+  \newcommand{\thesisassessors}{assessed by <?php echo $thesis_assessors ?>} % bottom layout 1
+\fi
+\newcommand{\thesisabstract}{%
+  This is a great abstract for my thesis.
+}
+\newcommand{\thesisfigure}{\includegraphics[width=5cm]{figures/cover_figure}}
+% TODO don't forget to set \spinesize below based on your page number and paper quality!!
+
+
+\definecolor{tuglogo}{RGB}{237,26,82}
+\definecolor{tuglogodark}{RGB}{8,11,10}
+\newcommand{\tuglogo}{%
+\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
+\begin{scope}[cm={{1.25,0.0,0.0,-1.25,(0.0,53.75)}}]% g10
+  \begin{scope}[scale=0.100]% g12
+    % path14
+    \path[fill=tuglogo,nonzero rule] (1.0820,112.0390) -- (208.5310,112.0390) --
+      (208.5310,319.4960) -- (1.0820,319.4960) -- (1.0820,112.0390) -- cycle;
+
+    % path16
+    \path[fill=tuglogo,nonzero rule] (229.2730,112.0390) -- (436.7340,112.0390) --
+      (436.7340,319.4960) -- (229.2730,319.4960) -- (229.2730,112.0390) -- cycle;
+
+    % path18
+    \path[fill=tuglogo,nonzero rule] (457.4880,112.0390) -- (664.9290,112.0390) --
+      (664.9290,319.4960) -- (457.4880,319.4960) -- (457.4880,112.0390) -- cycle;
+
+    % path20
+    \path[fill=tuglogo,nonzero rule] (104.8050,8.3086) -- (312.2740,8.3086) --
+      (312.2740,215.7656) -- (104.8050,215.7656) -- (104.8050,8.3086) -- cycle;
+
+    % path22
+    \path[fill=tuglogo,nonzero rule] (353.7580,215.7660) -- (561.1990,215.7660) --
+      (561.1990,423.2270) -- (353.7580,423.2270) -- (353.7580,215.7660) -- cycle;
+
+    % path24
+    \path[fill=tuglogodark,nonzero rule] (752.1170,286.2190) -- (685.7030,286.2190) --
+      (685.7030,319.4140) -- (856.8950,319.4140) -- (856.8950,286.2190) --
+      (790.4840,286.2190) -- (790.4840,112.4770) -- (752.1170,112.4770) --
+      (752.1170,286.2190);
+
+    % path26
+    \path[fill=tuglogodark,nonzero rule] (1049.3600,188.5160) .. controls
+      (1049.3600,176.0550) and (1047.1300,164.8050) .. (1042.6400,154.7700) ..
+      controls (1038.1600,144.7340) and (1032.0500,136.2110) .. (1024.3000,129.2070)
+      .. controls (1016.5400,122.1760) and (1007.3900,116.7850) ..
+      (996.7850,112.9960) .. controls (986.1880,109.1880) and (974.6760,107.2930) ..
+      (962.2340,107.2930) .. controls (949.8120,107.2930) and (938.3010,109.1880) ..
+      (927.6910,112.9960) .. controls (917.0900,116.7850) and (907.8590,122.1760) ..
+      (900.0270,129.2070) .. controls (892.1760,136.2110) and (886.0550,144.7340) ..
+      (881.6880,154.7700) .. controls (877.2930,164.8050) and (875.1130,176.0550) ..
+      (875.1130,188.5160) -- (875.1130,319.4140) -- (913.4960,319.4140) --
+      (913.4960,189.8360) .. controls (913.4960,184.7810) and (914.2970,179.4770) ..
+      (915.9380,173.9300) .. controls (917.5660,168.3870) and (920.2700,163.2730) ..
+      (924.0620,158.6020) .. controls (927.8400,153.9340) and (932.8520,150.0900) ..
+      (939.0900,147.0780) .. controls (945.3120,144.0700) and (953.0230,142.5590) ..
+      (962.2340,142.5590) .. controls (971.4340,142.5590) and (979.1560,144.0700) ..
+      (985.3910,147.0780) .. controls (991.6210,150.0900) and (996.6410,153.9340) ..
+      (1000.4200,158.6020) .. controls (1004.2000,163.2730) and (1006.9000,168.3870)
+      .. (1008.5400,173.9300) .. controls (1010.1800,179.4770) and
+      (1011.0000,184.7810) .. (1011.0000,189.8360) -- (1011.0000,319.4140) --
+      (1049.3600,319.4140) -- (1049.3600,188.5160);
+
+    % path28
+    \path[fill=tuglogodark,nonzero rule] (833.6480,83.9727) .. controls
+      (826.0430,87.2539) and (816.1880,88.8281) .. (808.3090,88.8281) .. controls
+      (785.3790,88.8281) and (772.7030,74.4023) .. (772.7030,55.6523) .. controls
+      (772.7030,37.0391) and (785.0980,23.0156) .. (806.0550,23.0156) .. controls
+      (811.4020,23.0156) and (815.6450,23.5430) .. (819.0120,24.3242) --
+      (819.0120,48.1836) -- (798.1840,48.1836) -- (798.1840,62.6055) --
+      (837.8710,62.6055) -- (837.8710,13.3086) .. controls (827.4610,10.6914) and
+      (816.6090,8.5938) .. (806.0550,8.5938) .. controls (774.2460,8.5938) and
+      (752.1450,23.4062) .. (752.1450,54.3438) .. controls (752.1450,85.6836) and
+      (772.7030,103.2500) .. (806.0550,103.2500) .. controls (817.4610,103.2500) and
+      (826.4650,101.8050) .. (834.9100,99.4414) -- (833.6480,83.9727);
+
+    % path30
+    \path[fill=tuglogodark,nonzero rule] (857.2810,77.6836) -- (874.0430,77.6836) --
+      (874.0430,62.3438) -- (874.3240,62.3438) .. controls (875.1640,68.6406) and
+      (882.8980,79.2578) .. (894.1560,79.2578) .. controls (895.9960,79.2578) and
+      (897.9770,79.2578) .. (899.9300,78.7266) -- (899.9300,61.0234) .. controls
+      (898.2500,61.9414) and (894.8710,62.4688) .. (891.4800,62.4688) .. controls
+      (876.1480,62.4688) and (876.1480,44.6367) .. (876.1480,34.9492) --
+      (876.1480,10.1641) -- (857.2810,10.1641) -- (857.2810,77.6836);
+
+    % path32
+    \path[fill=tuglogodark,nonzero rule] (914.8440,74.1406) .. controls
+      (922.1560,77.2930) and (932.0200,79.2578) .. (940.0470,79.2578) .. controls
+      (962.1370,79.2578) and (971.2890,70.7305) .. (971.2890,50.8008) --
+      (971.2890,42.1445) .. controls (971.2890,35.3398) and (971.4340,30.2227) ..
+      (971.5700,25.2422) .. controls (971.7190,20.1250) and (971.9880,15.4062) ..
+      (972.4220,10.1641) -- (955.8090,10.1641) .. controls (955.1050,13.6992) and
+      (955.1050,18.1641) .. (954.9690,20.2617) -- (954.6760,20.2617) .. controls
+      (950.3200,12.7930) and (940.8790,8.5938) .. (932.3050,8.5938) .. controls
+      (919.5000,8.5938) and (906.9610,15.8008) .. (906.9610,28.6484) .. controls
+      (906.9610,38.7383) and (912.1680,44.6367) .. (919.3520,47.9180) .. controls
+      (926.5430,51.1992) and (935.8160,51.8516) .. (943.7110,51.8516) --
+      (954.1210,51.8516) .. controls (954.1210,62.7305) and (948.9140,66.4023) ..
+      (937.7930,66.4023) .. controls (929.7730,66.4023) and (921.7460,63.5234) ..
+      (915.4180,59.0703) -- (914.8440,74.1406) -- cycle(936.9530,21.4336) ..
+      controls (942.7230,21.4336) and (947.2270,23.7969) .. (950.1760,27.4688) ..
+      controls (953.2700,31.2695) and (954.1210,36.1211) .. (954.1210,41.3633) --
+      (945.9570,41.3633) .. controls (937.5200,41.3633) and (924.9880,40.0586) ..
+      (924.9880,29.6953) .. controls (924.9880,23.9336) and (930.1910,21.4336) ..
+      (936.9530,21.4336);
+
+    % path34
+    \path[fill=tuglogodark,nonzero rule] (986.7730,77.6836) -- (1044.2000,77.6836) --
+      (1044.2000,63.2617) -- (1008.1500,23.7969) -- (1045.4700,23.7969) --
+      (1045.4700,10.1641) -- (985.2230,10.1641) -- (985.2230,24.4609) --
+      (1021.9500,64.0508) -- (986.7730,64.0508) -- (986.7730,77.6836);
+
+    % path36
+    \path[fill=tuglogo,nonzero rule] (1060.7300,8.3086) -- (1129.8433,8.3086) --
+      (1129.8433,77.4219) -- (1060.7300,77.4219) -- (1060.7300,8.3086) -- cycle;
+
+  \end{scope}
+\end{scope}
+\end{tikzpicture}%
+}
+
+\definecolor{head}{HTML}{245B78} % Web blocks - head/dark
+
+
+\begin{document}
+\Large
+\begin{tikzpicture}[inner sep=0pt]
+  \pgfmathsetlengthmacro{\spinesize}{+17mm} % TODO this is for 292=288+4 pages at 100g - see table
+  \pgfmathsetlengthmacro{\pagehsize}{+174mm}
+  \pgfmathsetlengthmacro{\pagevsize}{+245mm}
+  \pgfmathsetlengthmacro{\beischnitt}{+15mm}
+  \pgfmathsetlengthmacro{\nut}{+8mm}
+  \pgfmathsetlengthmacro{\spinehalf}{0.5*\spinesize}
+  \pgfmathsetlengthmacro{\textmargin}{+24mm}
+  \pgfmathsetlengthmacro{\textpwidth}{\pagehsize-\nut-2*\textmargin}
+  % safety margins:
+  % - 5mm on front/back page from margin or nut
+  % - 2mm on spine
+  \ifdraft
+  \pgfmathsetlengthmacro{\beischnitt}{+0mm}
+  \fi
+
+  \path[layout] (-\spinehalf,0) coordinate (spineSW) rectangle (\spinehalf,\pagevsize) coordinate (spineNE);
+  \path[layout] (spineSW) ++(-\pagehsize,0) coordinate (backSW) rectangle (spineSW|-spineNE) coordinate (backNE);
+  \path[layout] (spineNE) ++(\pagehsize,0) coordinate (frontNE) rectangle (spineSW-|spineNE) coordinate (frontSW);
+  \path[layout, dotted] (spineSW) ++(-\nut,0) -- ++(0,\pagevsize);
+  \path[layout, dotted] (spineNE) ++(\nut,0) -- ++(0,-\pagevsize);
+  \path (backSW)  ++(-\beischnitt,-\beischnitt) coordinate (fileSW)
+        (frontNE) ++(\beischnitt,\beischnitt)   coordinate (fileNE)
+        (fileNE|-fileSW) coordinate (fileSE)
+        (fileNE-|fileSW) coordinate (fileNW);
+  \path (spineNE|-spineSW) coordinate (spineSE)
+        (spineNE-|spineSW) coordinate (spineNW)
+        (backNE|-backSW) coordinate (backSE)
+        (backNE-|backSW) coordinate (backNW)
+        (frontNE|-frontSW) coordinate (frontSE)
+        (frontNE-|frontSW) coordinate (frontNW);
+
+  % front - claim, logo
+  \draw (frontSE) ++(-\textmargin+.4cm,\pagevsize-\textmargin)
+    node[anchor=north east] {\resizebox{1in}{!}{\tuglogo}} ++(-3cm,-.4cm)
+    node[anchor=north east] {\color{black}\fontsize{9}{9}\selectfont\so{\sffamily SCIENCE \tugsq{} PASSION \tugsq{} TECHNOLOGY} };
+
+  % front - title, author
+  %\fill[head] (spineSE) ++(\nut,0.75*\pagevsize+.5*\textmargin) rectangle ++(\pagehsize-\nut+\beischnitt,-6cm);
+  %\fill[head] (spineSE) ++(\nut,0.75*\pagevsize+\textmargin) rectangle ++(\pagehsize-\nut+\beischnitt,-7cm);
+  \fill[head] (spineSE) ++(-\spinesize-\nut,0.75*\pagevsize+\textmargin) rectangle ++(\pagehsize+\spinesize+\nut+\beischnitt,-7cm);
+  \draw (spineSE) ++(\nut+\textmargin,0.75*\pagevsize) node[below right,white,font=\Huge] {%
+    \begin{minipage}{\textpwidth}
+      \bfseries\thesistitle
+      \par\null\par\mdseries\LARGE
+      \thesisauthor
+    \end{minipage}
+  };
+
+  % front - figure
+  \draw (spineSE) ++(.5*\nut+.5*\pagehsize,.4*\pagevsize) node {%
+    \thesisfigure
+  };
+
+  % bottom layout 1:
+\iftwocol
+  % two columns bottom left/right
+  \draw (spineSE) ++(\nut+\textmargin,\textmargin) node[above right,font=\large] {%
+    \begin{minipage}{\textpwidth}
+      \textbf{Doctoral thesis}\par
+      submitted in \thesisdate{} to\par
+      Graz University of Technology\strut
+    \end{minipage}
+  };
+
+  \draw (spineSE) ++(.5*\nut+.5*\pagehsize+1.5cm,\textmargin) node[above right,font=\large] {%
+  %\draw (frontSE) ++(-\textmargin,\textmargin) node[above left,font=\large] {%
+    \begin{minipage}{8cm}
+      %\raggedleft
+      \thesisassessors\strut
+    \end{minipage}
+  };
+\else
+  % single column bottom left
+  \draw (spineSE) ++(\nut+\textmargin,1.5cm) node[above right,font=\Large] {%
+    \begin{minipage}{\textpwidth}
+      Doctoral thesis\par
+      \large\null\par
+      submitted to %\par
+      Graz University of Technology\par
+      \thesisassessors\par
+      \null\par
+      \thesisdate
+    \end{minipage}
+  };
+
+\fi
+
+  % back
+  \draw (spineNW) ++(-0.5*\nut-0.5*\pagehsize,-2*\textmargin) node[below,font=\normalsize] {%
+    \begin{minipage}{\textpwidth}
+      {\bfseries\large\thesistitle}\medskip\par
+      {\itshape Doctoral thesis by \thesisauthor}\bigskip\par
+      \thesisabstract
+    \end{minipage}
+  };
+
+  % spine
+  \node[rotate=270,anchor=west,xshift=1.0cm]              at (0,\pagevsize)    {\resizebox{2cm}{!}{\tuglogo}};
+  \node[rotate=270,align=center,font=\bfseries]           at (0,.4*\pagevsize) {\thesistitle};
+  \node[rotate=270,anchor=west,xshift=5.2cm,white]        at (0,\pagevsize)    {\thesisauthor};
+  \node[rotate=270,anchor=east,xshift=-1.5cm,font=\large] at (0,0)             {\thesisdate};
+
+\end{tikzpicture}
+\end{document}

+ 290 - 0
cover2.tex.php

@@ -0,0 +1,290 @@
+\documentclass[fontsize=12pt]{standalone}
+% This cover design is based on the `tugraz-booklet` class (TU Graz corporate design)
+% The main photo can be replace by any other suitably-sized photo.
+
+\newif\ifdraft\drafttrue % TODO set false for submission
+
+\newif\ifshowiaik\showiaiktrue % true: show huge gray part of graphical acronym / false: hide this part
+
+\usepackage[default,semibold]{sourcesanspro}
+\usepackage{soul}
+\usepackage{adjustbox}
+\sodef\so{}{0.4em}{1.1em}{0em}
+\newcommand{\tugsq}{\raisebox{0.5ex}{\tikz{\fill (0,0) rectangle (0.5ex,0.5ex);}}}
+
+\usepackage{tikz}
+\usetikzlibrary{calc}
+\ifdraft
+  \tikzset{layout/.style={draw,gray}}
+\else
+  \tikzset{layout/.style={}}
+\fi
+
+% TODO your info
+\newcommand{\thesistitle}{<?php echo $thesis_title ?>}
+\newcommand{\thesisauthor}{<?php echo $thesis_author ?>}
+\newcommand{\thesisdate}{<?php echo $thesis_date ?>}
+\newcommand{\thesisassessors}{Assessors: <?php echo $thesis_assessors ?>}
+\newcommand{\thesisabstract}{%
+  This is a great abstract for my thesis.
+}
+\newcommand{\thesisphotopath}{figures/cover_figure}
+% TODO don't forget to set \spinesize below based on your page number and paper quality!
+
+
+% TU Graz logo
+\definecolor{tuglogo}{HTML}{F70146}
+%\definecolor{tuglogo}{RGB}{237,26,82}
+\colorlet{tuglogotext}{black}
+\newcommand{\tuglogo}{%
+  \begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
+  \begin{scope}[cm={{1.25,0.0,0.0,-1.25,(0.0,53.75)}}]% g10
+    \begin{scope}[scale=0.100]% g12
+      % path14
+      \path[fill=tuglogo,nonzero rule] (1.0820,112.0390) -- (208.5310,112.0390) --
+        (208.5310,319.4960) -- (1.0820,319.4960) -- (1.0820,112.0390) -- cycle;
+
+      % path16
+      \path[fill=tuglogo,nonzero rule] (229.2730,112.0390) -- (436.7340,112.0390) --
+        (436.7340,319.4960) -- (229.2730,319.4960) -- (229.2730,112.0390) -- cycle;
+
+      % path18
+      \path[fill=tuglogo,nonzero rule] (457.4880,112.0390) -- (664.9290,112.0390) --
+        (664.9290,319.4960) -- (457.4880,319.4960) -- (457.4880,112.0390) -- cycle;
+
+      % path20
+      \path[fill=tuglogo,nonzero rule] (104.8050,8.3086) -- (312.2740,8.3086) --
+        (312.2740,215.7656) -- (104.8050,215.7656) -- (104.8050,8.3086) -- cycle;
+
+      % path22
+      \path[fill=tuglogo,nonzero rule] (353.7580,215.7660) -- (561.1990,215.7660) --
+        (561.1990,423.2270) -- (353.7580,423.2270) -- (353.7580,215.7660) -- cycle;
+
+      % path24
+      \path[fill=tuglogotext,nonzero rule] (752.1170,286.2190) -- (685.7030,286.2190) --
+        (685.7030,319.4140) -- (856.8950,319.4140) -- (856.8950,286.2190) --
+        (790.4840,286.2190) -- (790.4840,112.4770) -- (752.1170,112.4770) --
+        (752.1170,286.2190);
+
+      % path26
+      \path[fill=tuglogotext,nonzero rule] (1049.3600,188.5160) .. controls
+        (1049.3600,176.0550) and (1047.1300,164.8050) .. (1042.6400,154.7700) ..
+        controls (1038.1600,144.7340) and (1032.0500,136.2110) .. (1024.3000,129.2070)
+        .. controls (1016.5400,122.1760) and (1007.3900,116.7850) ..
+        (996.7850,112.9960) .. controls (986.1880,109.1880) and (974.6760,107.2930) ..
+        (962.2340,107.2930) .. controls (949.8120,107.2930) and (938.3010,109.1880) ..
+        (927.6910,112.9960) .. controls (917.0900,116.7850) and (907.8590,122.1760) ..
+        (900.0270,129.2070) .. controls (892.1760,136.2110) and (886.0550,144.7340) ..
+        (881.6880,154.7700) .. controls (877.2930,164.8050) and (875.1130,176.0550) ..
+        (875.1130,188.5160) -- (875.1130,319.4140) -- (913.4960,319.4140) --
+        (913.4960,189.8360) .. controls (913.4960,184.7810) and (914.2970,179.4770) ..
+        (915.9380,173.9300) .. controls (917.5660,168.3870) and (920.2700,163.2730) ..
+        (924.0620,158.6020) .. controls (927.8400,153.9340) and (932.8520,150.0900) ..
+        (939.0900,147.0780) .. controls (945.3120,144.0700) and (953.0230,142.5590) ..
+        (962.2340,142.5590) .. controls (971.4340,142.5590) and (979.1560,144.0700) ..
+        (985.3910,147.0780) .. controls (991.6210,150.0900) and (996.6410,153.9340) ..
+        (1000.4200,158.6020) .. controls (1004.2000,163.2730) and (1006.9000,168.3870)
+        .. (1008.5400,173.9300) .. controls (1010.1800,179.4770) and
+        (1011.0000,184.7810) .. (1011.0000,189.8360) -- (1011.0000,319.4140) --
+        (1049.3600,319.4140) -- (1049.3600,188.5160);
+
+      % path28
+      \path[fill=tuglogotext,nonzero rule] (833.6480,83.9727) .. controls
+        (826.0430,87.2539) and (816.1880,88.8281) .. (808.3090,88.8281) .. controls
+        (785.3790,88.8281) and (772.7030,74.4023) .. (772.7030,55.6523) .. controls
+        (772.7030,37.0391) and (785.0980,23.0156) .. (806.0550,23.0156) .. controls
+        (811.4020,23.0156) and (815.6450,23.5430) .. (819.0120,24.3242) --
+        (819.0120,48.1836) -- (798.1840,48.1836) -- (798.1840,62.6055) --
+        (837.8710,62.6055) -- (837.8710,13.3086) .. controls (827.4610,10.6914) and
+        (816.6090,8.5938) .. (806.0550,8.5938) .. controls (774.2460,8.5938) and
+        (752.1450,23.4062) .. (752.1450,54.3438) .. controls (752.1450,85.6836) and
+        (772.7030,103.2500) .. (806.0550,103.2500) .. controls (817.4610,103.2500) and
+        (826.4650,101.8050) .. (834.9100,99.4414) -- (833.6480,83.9727);
+
+      % path30
+      \path[fill=tuglogotext,nonzero rule] (857.2810,77.6836) -- (874.0430,77.6836) --
+        (874.0430,62.3438) -- (874.3240,62.3438) .. controls (875.1640,68.6406) and
+        (882.8980,79.2578) .. (894.1560,79.2578) .. controls (895.9960,79.2578) and
+        (897.9770,79.2578) .. (899.9300,78.7266) -- (899.9300,61.0234) .. controls
+        (898.2500,61.9414) and (894.8710,62.4688) .. (891.4800,62.4688) .. controls
+        (876.1480,62.4688) and (876.1480,44.6367) .. (876.1480,34.9492) --
+        (876.1480,10.1641) -- (857.2810,10.1641) -- (857.2810,77.6836);
+
+      % path32
+      \path[fill=tuglogotext,nonzero rule] (914.8440,74.1406) .. controls
+        (922.1560,77.2930) and (932.0200,79.2578) .. (940.0470,79.2578) .. controls
+        (962.1370,79.2578) and (971.2890,70.7305) .. (971.2890,50.8008) --
+        (971.2890,42.1445) .. controls (971.2890,35.3398) and (971.4340,30.2227) ..
+        (971.5700,25.2422) .. controls (971.7190,20.1250) and (971.9880,15.4062) ..
+        (972.4220,10.1641) -- (955.8090,10.1641) .. controls (955.1050,13.6992) and
+        (955.1050,18.1641) .. (954.9690,20.2617) -- (954.6760,20.2617) .. controls
+        (950.3200,12.7930) and (940.8790,8.5938) .. (932.3050,8.5938) .. controls
+        (919.5000,8.5938) and (906.9610,15.8008) .. (906.9610,28.6484) .. controls
+        (906.9610,38.7383) and (912.1680,44.6367) .. (919.3520,47.9180) .. controls
+        (926.5430,51.1992) and (935.8160,51.8516) .. (943.7110,51.8516) --
+        (954.1210,51.8516) .. controls (954.1210,62.7305) and (948.9140,66.4023) ..
+        (937.7930,66.4023) .. controls (929.7730,66.4023) and (921.7460,63.5234) ..
+        (915.4180,59.0703) -- (914.8440,74.1406) -- cycle(936.9530,21.4336) ..
+        controls (942.7230,21.4336) and (947.2270,23.7969) .. (950.1760,27.4688) ..
+        controls (953.2700,31.2695) and (954.1210,36.1211) .. (954.1210,41.3633) --
+        (945.9570,41.3633) .. controls (937.5200,41.3633) and (924.9880,40.0586) ..
+        (924.9880,29.6953) .. controls (924.9880,23.9336) and (930.1910,21.4336) ..
+        (936.9530,21.4336);
+
+      % path34
+      \path[fill=tuglogotext,nonzero rule] (986.7730,77.6836) -- (1044.2000,77.6836) --
+        (1044.2000,63.2617) -- (1008.1500,23.7969) -- (1045.4700,23.7969) --
+        (1045.4700,10.1641) -- (985.2230,10.1641) -- (985.2230,24.4609) --
+        (1021.9500,64.0508) -- (986.7730,64.0508) -- (986.7730,77.6836);
+
+      % path36
+      \path[fill=tuglogo,nonzero rule] (1060.7300,8.3086) -- (1129.8433,8.3086) --
+        (1129.8433,77.4219) -- (1060.7300,77.4219) -- (1060.7300,8.3086) -- cycle;
+
+    \end{scope}
+  \end{scope}
+  \end{tikzpicture}%
+} 
+
+\definecolor{head}{HTML}{245B78} % Web blocks - head/dark
+
+% IAIK logo
+\ifshowiaik
+  \definecolor{iaikgray}{RGB}{213,213,214}
+\else
+  \colorlet{iaikgray}{white} % remove huge "IAIK" text
+\fi
+\colorlet{iaiktug}{tuglogo}
+\newcommand{\iaiklogo}{%
+  \begin{tikzpicture}[y=-0.80pt, x=0.80pt, inner sep=0pt, outer sep=0pt]
+  \begin{scope}[cm={{1.33333,0.0,0.0,-1.33333,(0.0,1065.8267)}}]
+    \begin{scope}[shift={(64.1961,387.2106)}]
+      \path[fill=iaikgray,nonzero rule]
+        (0.0000,0.0000) -- (-64.1960,49.6520) -- (-64.1960,-6.2650) -- (0.0760,-50.3060) -- (-64.1960,-50.3060) -- (-64.1960,-92.3500) -- (105.8820,-92.3500) -- (105.8820,-50.3060) -- (64.3800,-50.3060) -- (35.9380,-28.5840) -- (105.8820,0.1030) -- (105.8820,51.8800) -- cycle
+        (-64.1960,-164.8370) -- (105.8820,-164.8370) -- (105.8820,-122.7000) -- (-64.1960,-122.7000) -- cycle
+        (-64.1960,-231.0000) -- (-64.1960,-276.8620) -- (105.8820,-328.0010) -- (105.8820,-285.0730) -- (77.8080,-278.4410) -- (77.8080,-230.7080) -- (105.8820,-223.9010) -- (105.8820,-179.8730) -- cycle
+        (-20.1110,-254.4480) -- (41.0300,-239.4290) -- (41.0300,-269.3080) -- cycle
+        (-64.1960,-386.6590) -- (105.8820,-386.6590) -- (105.8820,-344.5210) -- (-64.1960,-344.5210) -- cycle
+        ;
+    \end{scope}
+    \begin{scope}[shift={(154.4448,600.9453)}]
+      \path[fill=iaiktug,nonzero rule] (0.0000,0.0000) -- (-11.8420,-13.1670) -- (-11.8420,0.0000) -- (-23.1460,0.0000) -- (-23.1460,-34.4440) -- (-35.3950,-34.4440) -- (-35.3950,0.0000) -- (-46.7250,0.0000) -- (-46.7250,-34.4440) -- (-55.0130,-34.4440) -- (-68.6030,0.0000) -- (-80.9330,0.0000) -- (-94.5260,-34.4440) -- (-103.2140,-34.4440) -- (-103.2140,0.0000) -- (-114.5440,0.0000) -- (-114.5440,-34.4440) -- (-126.0980,-34.4440) -- (-126.0980,0.0000) -- (-154.4440,0.0000) -- (-154.4440,-170.0790) -- (15.6340,-170.0790) -- (15.6340,-34.4440) -- (15.3780,-34.4440) -- (1.6850,-13.1520) -- (15.0340,0.0000) -- cycle
+        (-74.9070,-9.0320) -- (-70.8690,-21.5570) -- (-78.9030,-21.5570) -- cycle
+        (-11.8420,-26.3400) -- (-6.0000,-20.5140) -- (1.4990,-34.4440) -- (-11.8420,-34.4440) -- cycle
+        (-81.3580,-29.0910) -- (-68.5230,-29.0910) -- (-66.8200,-34.4440) -- (-83.0190,-34.4440) -- cycle
+        ;
+    \end{scope}
+  \end{scope}
+  \end{tikzpicture}%
+}
+
+
+\begin{document}
+\Large
+\begin{tikzpicture}[inner sep=0pt]
+  \pgfmathsetlengthmacro{\spinesize}{+22mm} % TODO this is for 292=288+4 pages at 135g - see table
+  \pgfmathsetlengthmacro{\pagehsize}{+174mm}
+  \pgfmathsetlengthmacro{\pagevsize}{+245mm}
+  \pgfmathsetlengthmacro{\nut}{+8mm}
+  \pgfmathsetlengthmacro{\spinehalf}{0.5*\spinesize}
+  \pgfmathsetlengthmacro{\textmargin}{+24mm}
+  \pgfmathsetlengthmacro{\textpwidth}{\pagehsize-\nut-2*\textmargin}
+  \pgfmathsetlengthmacro{\logowidth}{+48mm}
+  \ifdraft
+    \pgfmathsetlengthmacro{\beischnitt}{+0mm}
+  \else
+    \pgfmathsetlengthmacro{\beischnitt}{+15mm}
+  \fi
+  % safety margins:
+  % - 5mm on front/back page from margin or nut
+  % - 2mm on spine
+
+  \path[layout] (-\spinehalf,0) coordinate (spineSW) rectangle (\spinehalf,\pagevsize) coordinate (spineNE);
+  \path[layout] (spineSW) ++(-\pagehsize,0) coordinate (backSW) rectangle (spineSW|-spineNE) coordinate (backNE);
+  \path[layout] (spineNE) ++(\pagehsize,0) coordinate (frontNE) rectangle (spineSW-|spineNE) coordinate (frontSW);
+  \path[layout, dotted] (spineSW) ++(-\nut,0) -- ++(0,\pagevsize);
+  \path[layout, dotted] (spineNE) ++(\nut,0) -- ++(0,-\pagevsize);
+  \path (backSW)  ++(-\beischnitt,-\beischnitt) coordinate (fileSW)
+        (frontNE) ++(\beischnitt,\beischnitt)   coordinate (fileNE)
+        (fileNE|-fileSW) coordinate (fileSE)
+        (fileNE-|fileSW) coordinate (fileNW);
+  \path (spineNE|-spineSW) coordinate (spineSE)
+        (spineNE-|spineSW) coordinate (spineNW)
+        (backNE|-backSW) coordinate (backSE)
+        (backNE-|backSW) coordinate (backNW)
+        (frontNE|-frontSW) coordinate (frontSE)
+        (frontNE-|frontSW) coordinate (frontNW);
+
+  % front - claim, logo
+  \draw (frontSE) ++(-2*\nut,\pagevsize-\textmargin) coordinate (titleNE)
+    node[anchor=north east] {\resizebox{1in}{!}{\tuglogo}} ++(-3cm,-.4cm)
+    node[anchor=north east] {\large\so{\sffamily SCIENCE \tugsq{} PASSION \tugsq{} TECHNOLOGY} };
+
+  % front - institute acronym
+  \draw (spineSE) ++(2*\nut,2*\nut) node[above right] (iaiklogo) {%
+    \resizebox{\logowidth}{!}{\iaiklogo}
+  };
+  \draw (iaiklogo.north east) ++(-.5pt,-\logowidth) coordinate (logoSW);
+  \ifx\thesisphotopath\empty{}% no photo -> color fill
+    \fill[head] (logoSW) rectangle (iaiklogo.north-|fileSE);
+  \else % photo
+    \pgfmathsetlengthmacro{\photowidth}{\pagehsize-4*\nut-\logowidth}
+    \node[above right,minimum width=\photowidth,minimum height=\logowidth] (imgbox) at (logoSW) {\centering \maxsizebox{\photowidth}{\logowidth}{\includegraphics{\thesisphotopath}}};
+  \fi
+
+  % front - title, author
+\ifshowiaik
+  \draw (logoSW-|titleNE) ++(0,-2*\nut) node[below left,font=\huge\bfseries] {%
+\else
+  \draw (logoSW) ++(0,-2*\nut) node[below right,font=\huge\bfseries\raggedright] {%
+\fi
+    \begin{minipage}{8cm}
+      \ifshowiaik\raggedleft\fi
+      \thesistitle\bigskip\par\Large\mdseries
+      \thesisauthor
+    \end{minipage}
+  };
+
+  % front - thesis info
+\ifshowiaik
+  \draw (iaiklogo.south-|titleNE) node[above left,font=\Large] {%
+\else
+  \draw (iaiklogo.south east) node[above right,font=\Large\raggedright] {%
+\fi
+    \begin{minipage}{8cm}
+      \ifshowiaik\raggedleft\fi
+      Doctoral thesis\par
+      \normalsize
+      \null\par
+      submitted to %\par
+      Graz University of Technology\par
+      \null\par
+      \thesisassessors\par
+      \null\par
+      \thesisdate
+    \end{minipage}
+  };
+
+  % back
+  \draw (spineNW) ++(-0.5*\nut-0.5*\pagehsize,0) coordinate (backmid);
+  \draw (backmid|-iaiklogo.north) node[below,font=\normalsize] {%
+    \begin{minipage}{\textpwidth}
+      \thesisabstract
+    \end{minipage}
+  };
+  \draw (backmid|-iaiklogo.north) node[above=\baselineskip,font=\normalsize] {%
+    \begin{minipage}{\textpwidth}
+      {\bfseries\large\thesistitle}\medskip\par
+      {Doctoral thesis~~~\tugsq~~~\thesisauthor}
+    \end{minipage}
+  };
+
+  % spine
+  \node[rotate=270,anchor=west,xshift=\textmargin]         at (0,\pagevsize)        {\resizebox{2cm}{!}{\tuglogo}};
+  \node[rotate=270,anchor=west]                            at (0,0|-iaiklogo.north) {\thesisauthor};
+  \node[rotate=270,align=left,anchor=west,font=\bfseries]  at (0,0|-logoSW)         {\thesistitle};
+  \node[rotate=270,anchor=east,xshift=-2*\nut,font=\large] at (0,0)                 {\thesisdate};
+
+
+\end{tikzpicture}
+\end{document}

BIN
figures/cover_figure.png


BIN
flyeralarm-info.pdf


+ 269 - 181
generator.php

@@ -1,10 +1,17 @@
 <?php
   global $options;
   global $preamble;
+  global $sloppy_begin;
+  global $sloppy_end;
   $preamble = "";
   global $kpsefiles;
   $kpsefiles = [];
-  global $existing_commands;
+  global $ignore_packages;
+  $ignore_packages = [];
+  global $existing_mathops;
+  $existing_mathops = [];
+  global $tikzlibs;
+  $tikzlibs = [];
   global $included_usepackages;
   $included_usepackages = [];
   global $additional_usepackages;
@@ -13,12 +20,12 @@
   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;
+    if (isset($options["-n"]))
+      return false;
     $response = false;
     do
     {
@@ -47,13 +54,15 @@
     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.
-
+You can also provide pdf files instead of tex files or a mix of both.
 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
+--no-cover               do not generate book cover pdf files
+--compile                run latexmk on the resulting main.tex of your generated thesis
 --not-sloppy             disable use of sloppypar around places that struggle without
                          (mainly the bibliographies)
 --cv                     add a CV
@@ -256,7 +265,9 @@ END;
           $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);
           $bib = preg_replace("/([\{\"].*)[^\\\\]#(.*)/i",'${1}\#${2}',$bib);
-          $bib = preg_replace("/{\\\\i}/","{i}",$bib);
+          $bib = str_replace('{\i}','{i}',$bib);
+          $bib = str_replace('$\textregistered$','\textregistered',$bib);
+          $bib = str_replace('{$\textquoteright$}','\'',$bib);
           file_put_contents($file,$bib);
           $bibresources[$d] = $file;
         }
@@ -264,7 +275,7 @@ END;
         {
           $tex = file_get_and_backup($file);
           // labels of lstlistings etc
-          $tex = preg_replace("/([\[,]\s*label\s*=\s*)((?!$d)[^\[,]+[\[,])/i",'${1}'.$d.':${2}',$tex);
+          $tex = preg_replace("/(lstlisting.*[\[,]\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
@@ -305,7 +316,7 @@ END;
       }
       if (str_starts_with($lines[$i],'\appendices') || str_starts_with($lines[$i],'\appendix'))
       {
-        $lines[$i] = '\section*{Appendix}';
+        $lines[$i] = '\section{Appendix}';
         $appendix = true;
       }
     }
@@ -332,22 +343,69 @@ END;
     preg_match_all("/\n\s*(\\\\DeclareMath(Operator|Alphabet)\\*?((?<R>{((?:[^{}]+|(?&R))*)})([^{}]*)|\\\\[^\{]*)(?<P>{((?:[^{}]+|(?&P))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})?(?<S>{((?:[^{}]+|(?&S))*)})?(?<T>{((?:[^{}]+|(?&T))*)})?)/i",$tex,$mathops);
     if (isset($mathops[4]))
       return [$mathops[1],$mathops[3]];
-    return [];
+    return [[],[]];
   }
-  function getnewcommands($tex)
+  function gettikzlibs($tex)
   {
-    $newcommands = [];
-    preg_match_all("/\n\s*(\\\\newcommand([^{}]*)(?<R>{((?:[^{}]+|(?&R))*)})([^{}]*)(?<P>{((?:[^{}]+|(?&P))*)}))/i",$tex,$newcommands);
-    if (isset($newcommands[4]))
-      return $newcommands[4];
-    return [];
+    preg_match_all("/\\\\usetikzlibrary\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex,$matches);
+    if (isset($matches[2]))
+      return [$matches[0],$matches[2]];
+    else
+      return [[],[]];
+  }
+  function flatten($d,$f)
+  {
+    global $kpsefiles;
+    $tex = file_get_and_backup("$d/$f",".interm_bak");
+    preg_match_all("/\\n([^%]*?)(\\\\(input|include|usepackage)\s*\\\\*?\s*(?<R>{(?<RR>((?:[^{}]+|(?&R))*))}))/i",$tex,$inputs);
+    $files = [];
+    global $ignore_packages;
+    if (count($inputs) > 0)
+    {
+      for ($i = 0; $i < count($inputs[0]); $i++)
+      {
+        $exts = ['.tex'];
+        $f2 = $inputs['RR'][$i];
+        if (strtolower($inputs[3][$i]) === 'usepackage')
+        {
+          if (strpos($f2,",") !== false || in_array($f2,$ignore_packages) || in_array("$f2.sty",$kpsefiles))
+            continue;
+          $f2 .= ".sty";
+        }
+        while (!file_exists("$d/$f2") && count($exts) > 0)
+          $f2 = $inputs['RR'][$i].array_shift($exts);
+        if (file_exists("$d/$f2"))
+          $files[] = [$d,$f2,$inputs[2][$i]];
+      }
+    }
+    preg_match_all("/\\n([^%]*?)(\\\\(import|subimport)\s*\\\\*?\s*(?<R>{(?<RR>((?:[^{}]+|(?&R))*))})\s*(?<Q>{(?<QQ>((?:[^{}]+|(?&Q))*))}))/i",$tex,$inputs);
+    if (count($inputs) > 0)
+    {
+      for ($i = 0; $i < count($inputs[0]); $i++)
+      {
+        $exts = ['.tex'];
+        $f2 = $inputs['QQ'][$i].'/'.$inputs['RR'][$i];
+        while (!file_exists("$d/$f2") && count($exts) > 0)
+          $f2 = $inputs['QQ'][$i].'/'.$inputs['RR'][$i].array_shift($exts);
+        if (!file_exists("$d/$f2"))
+          $files[] = [$d,$f2,$inputs[2][$i]];
+      }
+    }
+    foreach ($files as $file)
+    {
+      $content = flatten($file[0],$file[1]);
+      $tex = str_replace($file[2],$content,$tex);
+    }
+    file_put_contents("$d/$f",$tex);
+    return $tex;
   }
-  function adjust_papers($papers,$extensions = [])
+  function adjust_papers($papers)
   {
     $tex = "";
     $paper_fulltitle = "";
     $authors = "";
     $institute = "";
+    $header = "";
     foreach ($papers as $d => $f)
     {
       if (str_ends_with($f,".pdf"))
@@ -366,48 +424,44 @@ TODO
 \includepdf[pages=-]{{$d}/{$f}}
 END;
 file_put_contents("$d/main.tex",$header);
+        continue;
       }
-      $files = rscandir($d,$extensions);
+      $file = "$d/$f";
       $authors = "";
       $institute = "";
       $title = "";
       $paper_fulltitle = "";
       $paper_shorttitle = "";
-      foreach ($files as $file)
+      $tex = file_get_and_backup($file,".interm_bak");
+      if ($authors == "" && preg_match("/\n\s*\\\\author\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex) == 1)
       {
-        if (!str_ends_with($file,".tex") && !str_ends_with($file,".tikz") && !str_ends_with($file,".sty"))
-          continue;
-        $tex = file_get_and_backup($file,".interm_bak");
-        if ($authors == "" && preg_match("/\n\s*\\\\author\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex) == 1)
-        {
-          preg_match_all("/\n\s*\\\\author\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex,$authors);
-          if (isset($authors[2]) && isset($authors[2][0]))
-            $authors = trim(stripformatting($authors[2][0]));
-        }
-        if ($institute == "" && preg_match("/\n\s*\\\\institute\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex) == 1)
-        {
-          preg_match_all("/\n\s*\\\\institute\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex,$institute);
-          if (isset($institute[2]) && isset($institute[2][0]))
-            $institute = trim(stripformatting($institute[2][0]));
-        }
-        if ($paper_shorttitle == "" && preg_match("/\n\s*\\\\title\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex) == 1)
-        {
-          preg_match_all("/\n\s*\\\\title\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex,$title);
-          if (isset($title[2]) && isset($title[2][0]))
-            $title = trim(stripformatting($title[2][0]));
-          else
-            $title = $d;
-          
-          $shorttitle = $title;
-          if (strpos($title,":") !== false)
-            $shorttitle = trim(explode(":",$title)[0]);
-          $paper_fulltitle = trim(user_prompt("Please enter the full title for the paper in folder '$d'","$title"));
-          $paper_shorttitle = trim(user_prompt("Please enter a short title for the paper in folder '$d'","$shorttitle"));
-        }
-        $header = "";
-        if ($paper_fulltitle != "" && $paper_shorttitle != "" && $authors != "")
-        {
-          $header=<<<END
+        preg_match_all("/\n\s*\\\\author\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex,$authors);
+        if (isset($authors[2]))
+          $authors = trim(stripformatting(implode(" ",$authors[2])));
+      }
+      if ($institute == "" && preg_match("/\n\s*\\\\institute\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex) == 1)
+      {
+        preg_match_all("/\n\s*\\\\institute\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex,$institute);
+        if (isset($institute[2]) && isset($institute[2][0]))
+          $institute = trim(stripformatting($institute[2][0]));
+      }
+      if ($paper_shorttitle == "" && preg_match("/\n\s*\\\\title\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex) == 1)
+      {
+        preg_match_all("/\n\s*\\\\title\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex,$title);
+        if (isset($title[2]) && isset($title[2][0]))
+          $title = trim(stripformatting($title[2][0]));
+        else
+          $title = $d;
+        
+        $shorttitle = $title;
+        if (strpos($title,":") !== false)
+          $shorttitle = trim(explode(":",$title)[0]);
+        $paper_fulltitle = trim(user_prompt("Please enter the full title for the paper in folder '$d'","$title"));
+        $paper_shorttitle = trim(user_prompt("Please enter a short title for the paper in folder '$d'","$shorttitle"));
+      }
+      if ($paper_fulltitle != "" && $paper_shorttitle != "" && $authors != "")
+      {
+        $header=<<<END
 \chapter[$paper_shorttitle]{{$paper_fulltitle}}\label{chapter:$d}
 \section*{Publication Data}
 \\fullcite{TODO}
@@ -425,91 +479,121 @@ $paper_fulltitle%
 {\large $authors%
 } % TODO: check author list
 {\large $institute%
-} % TODO: check author list
+} % TODO: check institutes
 \\end{center}
 END;
-        }
+      }
 
-        [$mathopsfull,$mathops] = getmathops($tex);
-        global $existing_mathops;
-        global $preamble;
-        $addmathops = array_diff($mathops,$existing_mathops);
-        foreach ($addmathops as $k => $v)
-        {
-          $preamble .= $mathopsfull[$k] . "\n";
-          $existing_mathops[] = $v;
-        }
+      [$mathopsfull,$mathops] = getmathops($tex);
+      global $existing_mathops;
+      global $preamble;
+      $addmathops = array_diff($mathops,$existing_mathops);
+      $existing_mathops = array_unique($existing_mathops);
+      $addmathops = array_unique($addmathops);
+      foreach ($addmathops as $k => $v)
+      {
+        $preamble .= $mathopsfull[$k] . "\n";
+        $existing_mathops[] = $v;
+      }
 
-        $tex = preg_replace("/\\\documentclass.*\\n/i","
+      global $tikzlibs;
+      [$foundlibsfull,$foundlibs] = gettikzlibs($tex);
+      $addlibs = array_diff($foundlibs,$tikzlibs);
+      $tikzlibs = array_unique($tikzlibs);
+      $addlibs = array_unique($addlibs);
+      foreach ($addlibs as $k => $v)
+      {
+        $preamble .= $foundlibsfull[$k] . "\n";
+        $tikzlibs[] = $v;
+      }
+
+
+      $tex = preg_replace("/\\\documentclass.*\\n/i","
 ",$tex);
+      if (preg_match("/\\\begin{document}/i",$tex) == 1)
+      {
         $tex = preg_replace("/\\\begin{document}/i",$header,$tex);
-        $tex = preg_replace("/\\\begin{abstract}/i",'\section*{Abstract}',$tex);
-        $tex = preg_replace("/\\\\newcommand/i",'\declarecommand',$tex);
-        $tex = preg_replace("/\\\\renewcommand/i",'\declarecommand',$tex);
-        $tex = preg_replace("/\\\\end{abstract}/i",'',$tex);
-        $tex = preg_replace("/\\\\DeclareMathOperator/i",'%$0',$tex);
-        $tex = preg_replace("/\\\\DeclareMathAlphabet/i",'%$0',$tex);
-        $tex = preg_replace("/\\\\usepackage[cache=false]{minted}/i",'\usepackage{minted}',$tex);
-        $tex = preg_replace("/\\\\thispagestyle{empty}/i",'',$tex);
-        $tex = preg_replace("/\\\\PassOptionsToPackage\s*(?<R>{((?:[^{}]+|(?&R))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})/i",'',$tex);
-        $tex = preg_replace("/(\\\\csvautobooktabular\s*([^{}]*)\s*)(?<R>{((?:[^{}]+|(?&R))*)})/i","\\1{{$d}/\\4}",$tex);
-        $tex = preg_replace("/\\\\bibliographystyle\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
-        $tex = preg_replace("/\\\\usetikzlibrary\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
-        $tex = preg_replace("/\\\\DeclareFloatFont\s*(?<R>{((?:[^{}]+|(?&R))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
-        $tex = preg_replace("/\\\\captionsetup\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])?(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
-        $tex = preg_replace("/\\\\tikzexternalize\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])/i","",$tex);
-        $tex = preg_replace("/\\\\floatsetup\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
-        $tex = preg_replace("/\s*\\\\bibliography\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","\n".'\begin{sloppypar}
+        $header = "";
+      }
+      $tex = preg_replace("/\\\begin{abstract}/i",'\section*{Abstract}',$tex);
+      $tex = preg_replace("/\\\\newcommand/i",'\declarecommand',$tex);
+      $tex = preg_replace("/\\\\renewcommand/i",'\declarecommand',$tex);
+      //$tex = preg_replace("/\\\\DeclareRobustCommand/i",'\declarecommand',$tex);
+      $tex = preg_replace("/\\\\newenvironment/i",'\declareenvironment',$tex);
+      $tex = preg_replace("/\\\\renewenvironment/i",'\declareenvironment',$tex);
+      $tex = preg_replace("/\\\\NewDocumentEnvironment/i",'\DeclareDocumentEnvironment',$tex);
+      $tex = preg_replace("/\\\\ReNewDocumentEnvironment/i",'\DeclareDocumentEnvironment',$tex);
+      $tex = preg_replace("/\\\\end{abstract}/i",'',$tex);
+      $tex = preg_replace("/\\\\onecolumn/i",'',$tex);
+      $tex = preg_replace("/\\\\pagenumbering\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\\\\special\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\\\\DeclareMathOperator/i",'%$0',$tex);
+      $tex = preg_replace("/\\\\DeclareMathAlphabet/i",'%$0',$tex);
+      $tex = preg_replace("/\\\\usepackage[cache=false]{minted}/i",'\usepackage{minted}',$tex);
+      $tex = preg_replace("/\\\\thispagestyle{empty}/i",'%$0',$tex);
+      $tex = preg_replace("/\\\\PassOptionsToPackage\s*(?<R>{((?:[^{}]+|(?&R))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})/i",'',$tex);
+      $tex = preg_replace("/(\\\\csvautobooktabular\s*([^{}]*)\s*)(?<R>{((?:[^{}]+|(?&R))*)})/i","\\1{{$d}/\\4}",$tex);
+      $tex = preg_replace("/\\\\bibliographystyle\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",'%$0',$tex);
+      $tex = preg_replace("/\\\\usetikzlibrary\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",'%$0',$tex);
+      $tex = preg_replace("/\\\\DeclareFloatFont\s*(?<R>{((?:[^{}]+|(?&R))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
+      $tex = preg_replace("/\\\\captionsetup\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])?(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
+      $tex = preg_replace("/\\\\RequirePackage\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])?(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
+      $tex = preg_replace("/\\\\tikzexternalize\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])/i","",$tex);
+      $tex = preg_replace("/\\\\floatsetup\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
+      $tex = preg_replace("/\\\\newfloat\s*(?<R>{((?:[^{}]+|(?&R))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})(?<P>{((?:[^{}]+|(?&P))*)})/i","",$tex);
+      $tex = preg_replace("/\s*\\\\bibliography\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","\n".'\begin{sloppypar}
 \printbibliography[title={References}, heading=subbibliography]
 \end{sloppypar}',$tex);
-        $tex = preg_replace("/\\\\end{document}/i",'',$tex);
-        $tex = preg_replace("/\n\s*\\\\author\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
-        $tex = preg_replace("/\n\s*\\\\authorrunning\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
-        $tex = preg_replace("/\n\s*\\\\institute\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
-        $tex = preg_replace("/\n\s*\\\\title\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
-        $tex = preg_replace("/\n\s*\\\\date\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
-        $tex = preg_replace("/\\\\includegraphics\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])(?<Q>{((?:[^{}]+|(?&Q))*)})/i",'\includegraphics${1}{'.$d.'/${4}}',$tex);
-        $tex = preg_replace("/\n\s*\\\\maketitle/i","",$tex);
-        $tex = preg_replace("/\\\\IEEEoverridecommandlockouts/i","",$tex);
-        $tex = preg_replace("/\\\\twocolumn/i","",$tex);
-        $tex = preg_replace("/\n\s*\\\\tikzexternalize/i","",$tex);
-        [$ups,$ps] = getusepackages($tex);
-        global $included_usepackages;
-        global $additional_usepackages;
-        foreach (array_diff($ps,$included_usepackages) as $k => $v) {
-          if (in_array($v,['minted']))
-          {
-            $additional_usepackages[] = "\usepackage{minted}";
-            $included_usepackages[] = $v;
-          }
-          else if (!in_array($v,['usenix','usenix,epsfig,endnotes','flushend','mathptmx','usenixbadges','cite','csvenhanced']) && !($v == 'floatrow' && in_array('float',$included_usepackages)))
-          {
-            $additional_usepackages[] = $ups[$k];
-            $included_usepackages[] = $v;
-          }
+      $tex = preg_replace("/\\\\end{document}/i",'',$tex);
+      $tex = preg_replace("/\n\s*\\\\author\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\\\\tag\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\n\s*\\\\authorrunning\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\n\s*\\\\institute\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\n\s*\\\\title\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\n\s*\\\\date\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\\\\includegraphics\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])(?<Q>{((?:[^{}]+|(?&Q))*)})/i",'\includegraphics${1}{'.$d.'/${4}}',$tex);
+      if (preg_match("/\\\\maketitle/i",$tex) == 1)
+      {
+        $tex = preg_replace("/\\\\maketitle/i",$header,$tex);
+        $header = "";
+      }
+      $tex = preg_replace("/\\\\IEEEoverridecommandlockouts/i","",$tex);
+      $tex = preg_replace("/\\\\IEEEauthorblock[AN]/i","",$tex);
+      $tex = preg_replace("/\\\\IEEEauthorrefmark/i","\\textsuperscript",$tex);
+      $tex = preg_replace("/\\\\twocolumn/i","",$tex);
+      $tex = preg_replace("/\\\\SetWatermarkText\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\\\\ProvidesPackage\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\\\\SetWatermarkScale\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\\\\SetWatermarkLightness\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/\n\s*\\\\tikzexternalize/i","",$tex);
+      [$ups,$ps] = getusepackages($tex);
+      global $ignore_packages;
+      global $included_usepackages;
+      global $additional_usepackages;
+      foreach (array_diff($ps,$included_usepackages) as $k => $v) {
+        if (in_array($v,['minted']))
+        {
+          $additional_usepackages[] = "\usepackage{minted}";
+          $included_usepackages[] = $v;
         }
-        array_unique($additional_usepackages);
-        $tex = preg_replace("/\n\s*\\\\usepackage([^{}]*)(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
-        $tex = preg_replace("/^\s*\\\\usepackage([^{}]*)(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
-        
-        $newcommands = getnewcommands($tex);
-        global $existing_commands;
-        $rmcommands = array_intersect($newcommands,$existing_commands);
-        foreach ($rmcommands as $rmc)
+        else if (!in_array($v,$ignore_packages) && !($v == 'floatrow' && in_array('float',$included_usepackages)))
         {
-          //$tex = preg_replace("/\n\s*\\\\newcommand([^{}]*)({\s*\\".$rmc."\s*}.*\n)/i","\n",$tex);
+          $additional_usepackages[] = $ups[$k];
+          $included_usepackages[] = $v;
         }
-
-        $matches = [];
-        $tex = preg_replace("/\n\s*\\\\pgfplotsset\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
-        $tex = preg_replace("/\n\s*\\\\setlength{\s*\\\marginparwidth.*\n/i","\n",$tex);
-
-        if (stripos($tex,"\appendices") !== false || stripos($tex,"\appendix") !== false)
-          $tex = handle_appendix($tex);
-        if (!str_starts_with($tex,"\\makeatletter\n\def\\relativepath{\\import@path}\n\\makeatother\n"))
-          $tex = "\\makeatletter\n\def\\relativepath{\\import@path}\n\\makeatother\n" . $tex;
-        file_put_contents($file,$tex);
       }
+      array_unique($additional_usepackages);
+      $tex = preg_replace("/\n\s*\\\\usepackage([^{}]*)(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      $tex = preg_replace("/^\s*\\\\usepackage([^{}]*)(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
+      
+      $tex = preg_replace("/\n\s*\\\\setlength{\s*\\\marginparwidth.*\n/i","\n",$tex);
+
+      if (stripos($tex,"\appendices") !== false || stripos($tex,"\appendix") !== false)
+        $tex = handle_appendix($tex);
+      if (!str_starts_with($tex,"\\makeatletter\n\def\\relativepath{\\import@path}\n\\makeatother\n"))
+        $tex = "\\makeatletter\n\def\\relativepath{\\import@path}\n\\makeatother\n" . $tex;
+      $tex .= "\n\graphicspath{}";
+      file_put_contents($file,$tex);
     }
     return;
   }
@@ -520,9 +604,9 @@ END;
     {
       if (str_starts_with($a,"-"))
         $options[$a] = 1;
-      if ($a == "-n")
-        $options["--no-overwrite"] = 1;
     }
+    if (isset($options["-n"]) && !isset($options["--force-overwrite"]))
+      $options["--no-overwrite"] = 1;
     return $options;
   }
   function compile_check($papers,$precopy = false)
@@ -591,13 +675,24 @@ END;
     }
     sort($kpsefiles);
   }
+  echo "\n=== Step 1/$steps: Check Software and Command Line Options ===\n\n";
   check_software();
   $options = check_options($argv);
   if (isset($options["--help"]))
     print_help();
-  echo "\n=== Step 1/$steps: Check Folders ===\n\n";
+
+  $sloppy_begin = "";
+  $sloppy_end = "";
+  if (!isset($options["--no-sloppy"]))
+  {
+    $sloppy_begin = '\begin{sloppypar}';
+    $sloppy_end = '\end{sloppypar}';
+  }
+  
+  echo "\n=== Step 2/$steps: Check Folders ===\n\n";
   [$targets,$texfiles,$sourcedirs] = check_folders($argv);
-  echo "\n=== Step 2/$steps: Pre-Copy Compile Check ===\n\n";
+
+  echo "\n=== Step 3/$steps: Pre-Copy Compile Check ===\n\n";
   $targets_exist = true;
   foreach ($targets as $t)
     if (!is_dir($t))
@@ -606,50 +701,42 @@ END;
     echo "Skipping...\n";
   else
     compile_check($argv,true);
-  echo "\n=== Step 3/$steps: Copying Files ===\n\n";
+  echo "\n=== Step 4/$steps: Copying Files ===\n\n";
   $papers = check_and_copy_folders($argv);
-  echo "\n=== Step 4/$steps: Adjusting References (in *.bib *.tex *.tikz) ===\n\n";
+  echo "\n=== Step 5/$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";
+  echo "\n=== Step 6/$steps: Post-Copy Compile Check ===\n\n";
   if (isset($options["--no-compile-check"]))
     echo "Skipping...\n";
   else
     compile_check($papers);
+  echo "\n=== Step 7/$steps: Initialize KPSE Database ===\n\n";
+  init_kpse();
+  global $ignore_packages;
+  $ignore_packages = explode(",",user_prompt("Enter a comma-separated list of packages that should be considered ignored (e.g. publisher or conference styles, as well as packages that modify font or page formats)","usenix,epsfig,endnotes,flushend,mathptmx,pslatex,fontenc,microtype,draftwatermark,usenixbadges,cite,csvenhanced,etex,filecontents"));
+  echo "\n=== Step 8/$steps: Flattening Papers ===\n\n";
+  foreach ($papers as $d => $f)
+    flatten($d,$f);
+  echo "\n=== Step 9/$steps: Post-Flattening Compile Check ===\n\n";
+  if (isset($options["--no-compile-check"]))
+    echo "Skipping...\n";
+  else
+    compile_check($papers);
+  echo "\n=== Step 10/$steps: Preparing Extraction of Used Packages, Tikz Libs, Math Ops etc. ===\n\n";
   [$_t,$usepackages1] = getusepackages(file_get_contents("main.tex.php"));
   [$_t,$usepackages2] = getusepackages(file_get_contents("tugraz_defaults.sty"));
   global $included_usepackages;
   $included_usepackages = array_unique(array_merge($usepackages1, $usepackages2));
   sort($included_usepackages);
-  $cmds1 = getnewcommands(file_get_contents("main.tex.php"));
-  $cmds2 = getnewcommands(file_get_contents("tugraz_defaults.sty"));
-  global $existing_commands;
-  $existing_commands = array_unique(array_merge($cmds1, $cmds2));
-  [$del,$mathops1] = getmathops(file_get_contents("main.tex.php"));
-  [$del,$mathops2] = getmathops(file_get_contents("tugraz_defaults.sty"));
-  global $existing_mathops;
-  $existing_mathops = array_unique(array_merge($mathops1, $mathops2));
-  echo "\n=== Step 5/$steps: Adjusting Papers (checking *.tex and *.tikz files) ===\n\n";
-  adjust_papers($papers,[".tex",".tikz",".sty"]);
-  init_kpse();
+
+  echo "\n=== Step 12/$steps: Adjusting Papers ===\n\n";
+  adjust_papers($papers);
   foreach ($papers as $k => $v)
   {
     if (str_ends_with($papers[$k],".pdf"))
       $papers[$k] = 'main.tex';
-    else
-    {
-      $stys = rscandir($k,[".sty"]);
-      foreach ($stys as $styf)
-      {
-        $styfb = basename($styf);
-        if (in_array($styfb,$kpsefiles) === false && !file_exists("./$styfb"))
-        {
-          echo "Copying $styf to ./$styfb...\n";
-          copy($styf,"./$styfb");
-        }
-      }
-    }
   }
-  echo "\n=== Step 6/$steps: Generate main.tex ===\n\n";
+  echo "\n=== Step 12/$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");
@@ -660,14 +747,6 @@ END;
   $num_publications_in_thesis = count($papers);
   $num_publications = user_prompt("How many publications did you co-author during your PhD? (6 is the absolute minimum for a cumulative thesis)","6");
 
-  $sloppy_begin = "";
-  $sloppy_end = "";
-  if (!isset($options["--no-sloppy"]))
-  {
-    $sloppy_begin = '\begin{sloppypar}';
-    $sloppy_end = '\end{sloppypar}';
-  }
-
   ob_start();
   require "main.tex.php";
   $maintex_content = ob_get_contents();
@@ -676,7 +755,7 @@ END;
     file_put_contents("main.tex",$maintex_content);
 
   if (!file_exists("mypreamble.sty") || user_consent("mypreamble.sty already exists... overwrite?","--force-overwrite","--no-overwrite"))
-    file_put_contents("mypreamble.sty","\ProvidesPackage{mypreamble}\n\n".implode("\n",$additional_usepackages)."\n\n".$preamble);
+    file_put_contents("mypreamble.sty","\ProvidesPackage{mypreamble}\n\n".implode("\n",array_unique($additional_usepackages))."\n\n".$preamble);
 
   @mkdir("tikz");
 
@@ -700,23 +779,32 @@ END;
       file_put_contents("cv.tex","This is my CV! Thanks for checking it out!");
   }
 
-  ob_start();
-  require "cover1.tex.php";
-  $covertex_content = ob_get_contents();
-  ob_end_clean();
-  if (!file_exists("cover1.tex") || user_consent("cover1.tex already exists. overwrite?"))
-    file_put_contents("cover1.tex",$covertex_content);
-  
-  shell_exec('latexmk -latexoption="-shell-escape" -g -pdf cover1.tex 1>/dev/null 2>/dev/null');
-
-  ob_start();
-  require "cover2.tex.php";
-  $covertex_content = ob_get_contents();
-  ob_end_clean();
-  if (!file_exists("cover2.tex") || user_consent("cover2.tex already exists. overwrite?"))
-    file_put_contents("cover2.tex",$covertex_content);
+  if (!isset($options["--no-cover"]))
+  {
+    ob_start();
+    require "cover1.tex.php";
+    $covertex_content = ob_get_contents();
+    ob_end_clean();
+    if (!file_exists("cover1.tex") || user_consent("cover1.tex already exists. overwrite?"))
+      file_put_contents("cover1.tex",$covertex_content);
+    
+    shell_exec('latexmk -latexoption="-shell-escape" -g -pdf cover1.tex 1>/dev/null 2>/dev/null');
 
-  shell_exec('latexmk -latexoption="-shell-escape" -g -pdf cover2.tex 1>/dev/null 2>/dev/null');
+    ob_start();
+    require "cover2.tex.php";
+    $covertex_content = ob_get_contents();
+    ob_end_clean();
+    if (!file_exists("cover2.tex") || user_consent("cover2.tex already exists. overwrite?"))
+      file_put_contents("cover2.tex",$covertex_content);
 
-  echo "=== done ===\nNext step, run this command:\nlatexmk -latexoption=\"-shell-escape\" -g -pdf main.tex\n";
+    shell_exec('latexmk -latexoption="-shell-escape" -g -pdf cover2.tex 1>/dev/null 2>/dev/null');
+  }
+  if (isset($options["--compile"]))
+  {
+    exec('latexmk -latexoption="-shell-escape" -g -pdf main.tex');
+  }
+  else
+  {
+    echo "=== done ===\nNext step, run this command:\nlatexmk -latexoption=\"-shell-escape\" -g -pdf main.tex\n";
+  }
 ?>

+ 1 - 116
main.tex.php

@@ -1,4 +1,4 @@
-\documentclass[paper=a4,fontsize=11pt,twoside,titlepage,openright]{scrbook}
+\documentclass[paper=a4,fontsize=11pt,twoside,titlepage,parskip=half-,openright]{scrbook}
 
 \newif\ifbeischnittzugabe\beischnittzugabefalse % TODO set to true for final upload (required by flyeralarm)
 
@@ -13,24 +13,6 @@
 \fi
 
 \usepackage{tugraz_defaults}
-\usepackage{moresize}
-\usepackage{pdfpages}
-\usepackage{enumitem}
-\usepackage{mdframed}
-\usepackage{import}
-
-\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 
 foreach ($bibresources as $br => $bib)
@@ -42,98 +24,6 @@ if (isset($options["--cv"]))
   echo '\addbibresource{cv.bib}
 ';
 ?>
-\DeclareFieldFormat*{title}{#1} 
-\DeclareFieldFormat*{booktitle}{#1}  
-\DeclareFieldFormat*{journaltitle}{#1}  
-\newcommand{\itemcite}[1]{\begin{itemize}\item \fullcite{#1}\end{itemize}}
-
-\renewcommand{\bf}{\bfseries}
-\renewcommand{\tt}{\ttfamily}
-\renewcommand{\and}{,\xspace}
-\newcommand{\CopyrightYear}{}
-\newcommand{\setcopyright}{}
-\newcommand{\conferenceinfo}{}
-\newcommand{\isbn}{}
-\newcommand{\doi}{}
-\newcommand{\printccsdesc}{}
-\newcommand{\numberofauthors}{}
-\newcommand{\alignauthor}{}
-\newcommand{\affaddr}{}
-\newcommand{\ccsdesc}[1]{}
-\newcommand{\acmPrice}{}
-\newcommand{\keywords}[1]{Keywords:\ #1.}
-
-\usepackage{graphicx}
-\usepackage[openbib,NoDate]{currvita}
-\preto\fullcite{\AtNextCite{\defcounter{maxnames}{99}}}
-
-
-\usepackage{quotchap} %
-
-\DefineBibliographyStrings{english}{%
-  backrefpage = {p.},%
-  backrefpages = {pp.},%
-}
-
-\usepackage[titles]{tocloft}
-\renewcommand\cftchapaftersnum{.}
-\setlength{\cftchapnumwidth}{2em}
-
-\usepackage{verbatim}
-
-\makeatletter
-\frenchspacing
-\widowpenalty=10000
-\clubpenalty=10000
-\setcounter{tocdepth}{1}
-\renewenvironment{table}
-               {\setlength\abovecaptionskip{0\p@}%
-                \setlength\belowcaptionskip{10\p@}%
-                \@float{table}}
-               {\end@float}
-\newenvironment{CCSXML}
-               {\comment}
-               {\endcomment}
-\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
-
-\makeatletter
-\newcommand\declarecommand{\@star@or@long\@declarecommand}
-\newcommand\@declarecommand[1]{%
-  \provide@command{#1}{}%
-  \renew@command{#1}%
-}
-\makeatother
-
-\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}
-
-\usepackage{mypreamble}
-\usepackage{scrhack}
-
 
 \begin{document}
 %\includepdf[pages=-]{front.pdf}
@@ -201,8 +91,6 @@ if (isset($options["--cv"]))
   \vspace{6cm}
 \end{titlepage}%
 
-%\pagenumbering{arabic}
-
 \cleardoublepage
 
 \addtocontents{toc}{\vspace*{\baselineskip}}
@@ -273,10 +161,7 @@ echo '
   \pgfplotsset{
     table/search path={'.$p.'/},
   }
-  \newcommand{\thesisGenIncludePath}{'.$p.'}
   \subimport*{'.$p.'/}{'.$f.'}
-  \graphicspath{}
- 
   \end{refsection}
   \egroup
   

+ 123 - 147
tugraz_defaults.sty

@@ -5,13 +5,11 @@
 \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{amsmath}
+\usepackage{amssymb}
+\usepackage{array}
 \usepackage{arydshln}
-\usepackage{booktabs}	% defined by ACM
-% \usepackage{cite} % to sort citations
+\usepackage{booktabs}
 \usepackage{collcell}
 \usepackage{comment}
 \usepackage{float}
@@ -24,15 +22,11 @@
 \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}
@@ -40,11 +34,8 @@
 \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}
@@ -56,11 +47,7 @@
 \usetikzlibrary{shapes.geometric,shapes.misc}
 \usetikzlibrary{pgfplots.groupplots}
 \pgfplotsset{compat=newest}
-% ------------------------------
-
 
-% ------------------------------
-% Fancy captions
 \usepackage{caption}
 \usepackage{subcaption}
 \captionsetup{compatibility=false}
@@ -87,48 +74,14 @@
 % ------------------------------
 % 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}
@@ -227,15 +180,8 @@
     \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
@@ -285,9 +231,6 @@
 \usepackage{soul}
 \usepackage[noabbrev,capitalize]{cleveref}
 
-% correct bad hyphenation here
-\hyphenation{op-tical net-works semi-conduc-tor row-ham-mer}
-
 \widowpenalty10000
 \clubpenalty10000
 
@@ -339,88 +282,6 @@
   {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}
 
@@ -446,10 +307,6 @@
 \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}
 
@@ -485,3 +342,122 @@
 \newcommand{\asm}[1]{\lstinline[style=asm]{#1}\xspace}
 \newcommand{\cpp}[1]{\lstinline[style=cpp]{#1}\xspace}
 \newcommand{\py}[1]{\lstinline[style=python]{#1}\xspace}
+\usepackage{moresize}
+\usepackage{pdfpages}
+\usepackage{enumitem}
+\usepackage{mdframed}
+\usepackage{import}
+\usepackage{microtype}
+\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}
+
+\DeclareFieldFormat*{title}{#1} 
+\DeclareFieldFormat*{booktitle}{#1}  
+\DeclareFieldFormat*{journaltitle}{#1}  
+\newcommand{\itemcite}[1]{\begin{itemize}\item \fullcite{#1}\end{itemize}}
+
+\renewcommand{\bf}{\bfseries}
+\renewcommand{\tt}{\ttfamily}
+\renewcommand{\and}{,\xspace}
+\newcommand{\CopyrightYear}{}
+\newcommand{\setcopyright}{}
+\newcommand{\conferenceinfo}{}
+\newcommand{\isbn}{}
+\newcommand{\doi}{}
+\newcommand{\printccsdesc}{}
+\newcommand{\numberofauthors}{}
+\newcommand{\alignauthor}{}
+\newcommand{\affaddr}{}
+\newcommand{\ccsdesc}[1]{}
+\newcommand{\acmPrice}{}
+\newcommand{\keywords}[1]{Keywords:\ #1.}
+
+\usepackage{graphicx}
+\usepackage[openbib,NoDate]{currvita}
+\preto\fullcite{\AtNextCite{\defcounter{maxnames}{99}}}
+
+
+\usepackage{quotchap} %
+
+\DefineBibliographyStrings{english}{%
+  backrefpage = {p.},%
+  backrefpages = {pp.},%
+}
+
+\usepackage[titles]{tocloft}
+\renewcommand\cftchapaftersnum{.}
+\setlength{\cftchapnumwidth}{2em}
+
+\usepackage{verbatim}
+
+\makeatletter
+\frenchspacing
+\widowpenalty=10000
+\clubpenalty=10000
+\setcounter{tocdepth}{1}
+\renewenvironment{table}
+               {\setlength\abovecaptionskip{0\p@}%
+                \setlength\belowcaptionskip{10\p@}%
+                \@float{table}}
+               {\end@float}
+\newenvironment{CCSXML}
+               {\comment}
+               {\endcomment}
+\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
+
+\makeatletter
+\newcommand\declarecommand{\@star@or@long\@declarecommand}
+\newcommand\@declarecommand[1]{%
+  \provide@command{#1}{}%
+  \renew@command{#1}%
+}
+\def\declareenvironment{\@star@or@long\declare@environment}
+\def\declare@environment#1{%
+        \@ifundefined{#1}%
+                {\def\reserved@a{\newenvironment{#1}}}%
+                {\def\reserved@a{\renewenvironment{dummy@environ}}}%
+        \reserved@a
+}
+\def\dummy@environ{}
+\makeatother
+
+
+\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}
+
+\usepackage{mypreamble}
+\usepackage{scrhack}
+