Daniel Gruss 2 gadi atpakaļ
vecāks
revīzija
b7d22bfec4
2 mainītis faili ar 61 papildinājumiem un 20 dzēšanām
  1. 37 11
      generator.php
  2. 24 9
      main.tex.php

+ 37 - 11
generator.php

@@ -256,6 +256,7 @@ 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);
           file_put_contents($file,$bib);
           $bibresources[$d] = $file;
         }
@@ -377,19 +378,19 @@ file_put_contents("$d/main.tex",$header);
         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/i",$tex) == 1)
+        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/i",$tex) == 1)
+        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_fulltitle == "" && preg_match("/\n\s*\\\\title/i",$tex) == 1)
+        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]))
@@ -404,10 +405,10 @@ file_put_contents("$d/main.tex",$header);
           $paper_shorttitle = trim(user_prompt("Please enter a short title for the paper in folder '$d'","$shorttitle"));
         }
         $header = "";
-        if ($paper_fulltitle != "" && $authors != "")
+        if ($paper_fulltitle != "" && $paper_shorttitle != "" && $authors != "")
         {
           $header=<<<END
-\chapter[$paper_shorttitle]{$paper_fulltitle}\label{chapter:$d}
+\chapter[$paper_shorttitle]{{$paper_fulltitle}}\label{chapter:$d}
 \section*{Publication Data}
 \\fullcite{TODO}
 
@@ -443,8 +444,8 @@ END;
 ",$tex);
         $tex = preg_replace("/\\\begin{document}/i",$header,$tex);
         $tex = preg_replace("/\\\begin{abstract}/i",'\section*{Abstract}',$tex);
-        $tex = preg_replace("/\\\\newcommand/i",'\providecommand',$tex);
-        $tex = preg_replace("/\\\\renewcommand/i",'\providecommand',$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);
@@ -458,7 +459,9 @@ END;
         $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","",$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);
@@ -479,7 +482,7 @@ END;
             $additional_usepackages[] = "\usepackage{minted}";
             $included_usepackages[] = $v;
           }
-          else if (!in_array($v,['usenix','usenix,epsfig,endnotes','usenixbadges','cite','csvenhanced']) && !($v == 'floatrow' && in_array('float',$included_usepackages)))
+          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;
@@ -494,7 +497,7 @@ END;
         $rmcommands = array_intersect($newcommands,$existing_commands);
         foreach ($rmcommands as $rmc)
         {
-          $tex = preg_replace("/\n\s*\\\\newcommand([^{}]*)({\s*\\".$rmc."\s*}.*\n)/i","\n",$tex);
+          //$tex = preg_replace("/\n\s*\\\\newcommand([^{}]*)({\s*\\".$rmc."\s*}.*\n)/i","\n",$tex);
         }
 
         $matches = [];
@@ -683,7 +686,12 @@ END;
     file_put_contents("intro.tex","");
 
   if (!file_exists("main.bib"))
-    file_put_contents("main.bib","");
+    file_put_contents("main.bib",'@inproceedings{Kocher2019,
+  author = {Paul Kocher and Jann Horn and Anders Fogh and Daniel Genkin and Daniel Gruss and Werner Haas and Mike Hamburg and Moritz Lipp and Stefan Mangard and Thomas Prescher and Michael Schwarz and Yuval Yarom},
+  booktitle = {S\&P},
+  title = {{Spectre Attacks: Exploiting Speculative Execution}},
+  year = {2019}
+}');
   if (isset($options["--cv"]))
   {
     if (!file_exists("cv.bib"))
@@ -692,5 +700,23 @@ 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);
+
+  shell_exec('latexmk -latexoption="-shell-escape" -g -pdf cover2.tex 1>/dev/null 2>/dev/null');
+
   echo "=== done ===\nNext step, run this command:\nlatexmk -latexoption=\"-shell-escape\" -g -pdf main.tex\n";
 ?>

+ 24 - 9
main.tex.php

@@ -1,12 +1,17 @@
-\documentclass[paper=a4,fontsize=11pt,twoside,titlepage,parskip=half-,openright]{scrbook}
-\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}
+\documentclass[paper=a4,fontsize=11pt,twoside,titlepage,openright]{scrbook}
+
+\newif\ifbeischnittzugabe\beischnittzugabefalse % TODO set to true for final upload (required by flyeralarm)
+
+%%% papering %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Flyeralarm / content: 170mm x 240mm / mit buffer: 176mm x 246mm
+\ifbeischnittzugabe
+  \usepackage[paperwidth=17.6cm, paperheight=24.6cm, 
+              lmargin = 2.7cm, rmargin = 2.7cm, top = 2.3cm, headsep = 0.6cm, textheight = 19.3cm, footskip = 1.0cm]{geometry}
+\else
+  \usepackage[paperwidth=17.0cm, paperheight=24.0cm, 
+              lmargin = 2.4cm, rmargin = 2.4cm, top = 2.0cm, headsep = 0.6cm, textheight = 19.3cm, footskip = 1.0cm]{geometry}
+\fi
+
 \usepackage{tugraz_defaults}
 \usepackage{moresize}
 \usepackage{pdfpages}
@@ -43,6 +48,7 @@ if (isset($options["--cv"]))
 \newcommand{\itemcite}[1]{\begin{itemize}\item \fullcite{#1}\end{itemize}}
 
 \renewcommand{\bf}{\bfseries}
+\renewcommand{\tt}{\ttfamily}
 \renewcommand{\and}{,\xspace}
 \newcommand{\CopyrightYear}{}
 \newcommand{\setcopyright}{}
@@ -100,6 +106,14 @@ if (isset($options["--cv"]))
 \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}}
@@ -262,6 +276,7 @@ echo '
   \newcommand{\thesisGenIncludePath}{'.$p.'}
   \subimport*{'.$p.'/}{'.$f.'}
   \graphicspath{}
+ 
   \end{refsection}
   \egroup