Daniel Gruss 2 年之前
父节点
当前提交
600c4fdd35
共有 2 个文件被更改,包括 31 次插入3 次删除
  1. 22 1
      generator.php
  2. 9 2
      main.tex.php

+ 22 - 1
generator.php

@@ -326,6 +326,7 @@ END;
       $tex = "";
       $paper_fulltitle = "";
       $authors = "";
+      $institute = "";
       if (str_ends_with($f,".pdf"))
       {
         $paper_fulltitle = trim(user_prompt("Please enter the full title for the paper in folder '$d'","TODO"));
@@ -356,6 +357,13 @@ file_put_contents("$d/main.tex",$header);
           if (isset($authors[2]) && isset($authors[2][0]))
             $authors = trim(stripformatting($authors[2][0]));
         }
+        if ($institute == "" && preg_match("/\n\s*\\\\institute/i",$tex) == 1)
+        {
+          $institute = [];
+          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)
         {
           $title = [];
@@ -391,21 +399,34 @@ $paper_fulltitle%
 \\vspace{0.6cm}
 {\large $authors%
 } % TODO: check author list
+{\large $institute%
+} % TODO: check author list
 \\end{center}
 END;
         }
-        $tex = preg_replace("/\\\documentclass.*\\n/i",'',$tex);
+        $tex = preg_replace("/\\\documentclass.*\\n/i","
+",$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("/\\\\end{abstract}/i",'',$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("/\n\s*\\\\bibliography\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
         $tex = preg_replace("/\\\\end{document}/i",'',$tex);
         $tex = preg_replace("/\n\s*\\\\author\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("/\n\s*\\\\maketitle/i","",$tex);
+        $tex = preg_replace("/\n\s*\\\\tikzexternalize/i","",$tex);
         [$ups,$ps] = getusepackages($tex);
         global $included_usepackages;
         global $additional_usepackages;

+ 9 - 2
main.tex.php

@@ -12,6 +12,7 @@
 \usepackage{pdfpages}
 \usepackage{enumitem}
 \usepackage{mdframed}
+\usepackage{import}
 
 \usepackage[breakable, theorems, skins]{tcolorbox}
 
@@ -41,6 +42,9 @@ if (isset($options["--cv"]))
 \DeclareFieldFormat*{journaltitle}{#1}  
 \newcommand{\itemcite}[1]{\begin{itemize}\item \fullcite{#1}\end{itemize}}
 
+\renewcommand{\bf}{\bfseries}
+\renewcommand{\and}{,\xspace}
+\newcommand{\keywords}[1]{Keywords:\ #1.}
 
 \usepackage{graphicx}
 \usepackage[openbib,NoDate]{currvita}
@@ -235,8 +239,11 @@ echo '
 
   \bgroup
   \begin{refsection}
-  
-  \input{'.$p.'/'.$f.'}
+  \pgfplotsset{
+    table/search path={'.$p.'/},
+  }
+  \newcommand{\thesisGenIncludePath}{'.$p.'}
+  \subimport{'.$p.'/}{'.$f.'}
   
   \end{refsection}
   \egroup