|
@@ -1,10 +1,17 @@
|
|
|
<?php
|
|
<?php
|
|
|
global $options;
|
|
global $options;
|
|
|
global $preamble;
|
|
global $preamble;
|
|
|
|
|
+ global $sloppy_begin;
|
|
|
|
|
+ global $sloppy_end;
|
|
|
$preamble = "";
|
|
$preamble = "";
|
|
|
global $kpsefiles;
|
|
global $kpsefiles;
|
|
|
$kpsefiles = [];
|
|
$kpsefiles = [];
|
|
|
- global $existing_commands;
|
|
|
|
|
|
|
+ global $ignore_packages;
|
|
|
|
|
+ $ignore_packages = [];
|
|
|
|
|
+ global $existing_mathops;
|
|
|
|
|
+ $existing_mathops = [];
|
|
|
|
|
+ global $tikzlibs;
|
|
|
|
|
+ $tikzlibs = [];
|
|
|
global $included_usepackages;
|
|
global $included_usepackages;
|
|
|
$included_usepackages = [];
|
|
$included_usepackages = [];
|
|
|
global $additional_usepackages;
|
|
global $additional_usepackages;
|
|
@@ -13,12 +20,12 @@
|
|
|
function user_consent($msg,$defaultyes = null,$defaultno = null)
|
|
function user_consent($msg,$defaultyes = null,$defaultno = null)
|
|
|
{
|
|
{
|
|
|
global $options;
|
|
global $options;
|
|
|
- if (isset($options["-n"]))
|
|
|
|
|
- return false;
|
|
|
|
|
if ($defaultyes !== null && isset($options[$defaultyes]))
|
|
if ($defaultyes !== null && isset($options[$defaultyes]))
|
|
|
return true;
|
|
return true;
|
|
|
if ($defaultno !== null && isset($options[$defaultno]))
|
|
if ($defaultno !== null && isset($options[$defaultno]))
|
|
|
return false;
|
|
return false;
|
|
|
|
|
+ if (isset($options["-n"]))
|
|
|
|
|
+ return false;
|
|
|
$response = false;
|
|
$response = false;
|
|
|
do
|
|
do
|
|
|
{
|
|
{
|
|
@@ -47,13 +54,15 @@
|
|
|
echo<<<END
|
|
echo<<<END
|
|
|
Usage: php $name /path/folder1/main.tex /path/folder2/article.tex ... /path/folderN/paper.tex\n
|
|
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.
|
|
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.
|
|
The absolute minimum for a cumulative thesis is currently 3 papers first-authored and 6 in total.
|
|
|
|
|
|
|
|
--force-overwrite overwrite files and folders
|
|
--force-overwrite overwrite files and folders
|
|
|
--no-overwrite do not overwrite files and folders
|
|
--no-overwrite do not overwrite files and folders
|
|
|
--no-compile-check do not perform a compile check
|
|
--no-compile-check do not perform a compile check
|
|
|
--use-backups restore backups before making changes
|
|
--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
|
|
--not-sloppy disable use of sloppypar around places that struggle without
|
|
|
(mainly the bibliographies)
|
|
(mainly the bibliographies)
|
|
|
--cv add a CV
|
|
--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("/(^\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("/(\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",'${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);
|
|
file_put_contents($file,$bib);
|
|
|
$bibresources[$d] = $file;
|
|
$bibresources[$d] = $file;
|
|
|
}
|
|
}
|
|
@@ -264,7 +275,7 @@ END;
|
|
|
{
|
|
{
|
|
|
$tex = file_get_and_backup($file);
|
|
$tex = file_get_and_backup($file);
|
|
|
// labels of lstlistings etc
|
|
// 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
|
|
// normal labels
|
|
|
$tex = preg_replace("/(\\\label\s*\{\s*)((?!$d)[^}]+\})/i",'${1}'.$d.':${2}',$tex);
|
|
$tex = preg_replace("/(\\\label\s*\{\s*)((?!$d)[^}]+\})/i",'${1}'.$d.':${2}',$tex);
|
|
|
// cref ref autoref
|
|
// cref ref autoref
|
|
@@ -305,7 +316,7 @@ END;
|
|
|
}
|
|
}
|
|
|
if (str_starts_with($lines[$i],'\appendices') || str_starts_with($lines[$i],'\appendix'))
|
|
if (str_starts_with($lines[$i],'\appendices') || str_starts_with($lines[$i],'\appendix'))
|
|
|
{
|
|
{
|
|
|
- $lines[$i] = '\section*{Appendix}';
|
|
|
|
|
|
|
+ $lines[$i] = '\section{Appendix}';
|
|
|
$appendix = true;
|
|
$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);
|
|
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]))
|
|
if (isset($mathops[4]))
|
|
|
return [$mathops[1],$mathops[3]];
|
|
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 = "";
|
|
$tex = "";
|
|
|
$paper_fulltitle = "";
|
|
$paper_fulltitle = "";
|
|
|
$authors = "";
|
|
$authors = "";
|
|
|
$institute = "";
|
|
$institute = "";
|
|
|
|
|
+ $header = "";
|
|
|
foreach ($papers as $d => $f)
|
|
foreach ($papers as $d => $f)
|
|
|
{
|
|
{
|
|
|
if (str_ends_with($f,".pdf"))
|
|
if (str_ends_with($f,".pdf"))
|
|
@@ -366,48 +424,44 @@ TODO
|
|
|
\includepdf[pages=-]{{$d}/{$f}}
|
|
\includepdf[pages=-]{{$d}/{$f}}
|
|
|
END;
|
|
END;
|
|
|
file_put_contents("$d/main.tex",$header);
|
|
file_put_contents("$d/main.tex",$header);
|
|
|
|
|
+ continue;
|
|
|
}
|
|
}
|
|
|
- $files = rscandir($d,$extensions);
|
|
|
|
|
|
|
+ $file = "$d/$f";
|
|
|
$authors = "";
|
|
$authors = "";
|
|
|
$institute = "";
|
|
$institute = "";
|
|
|
$title = "";
|
|
$title = "";
|
|
|
$paper_fulltitle = "";
|
|
$paper_fulltitle = "";
|
|
|
$paper_shorttitle = "";
|
|
$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}
|
|
\chapter[$paper_shorttitle]{{$paper_fulltitle}}\label{chapter:$d}
|
|
|
\section*{Publication Data}
|
|
\section*{Publication Data}
|
|
|
\\fullcite{TODO}
|
|
\\fullcite{TODO}
|
|
@@ -425,91 +479,121 @@ $paper_fulltitle%
|
|
|
{\large $authors%
|
|
{\large $authors%
|
|
|
} % TODO: check author list
|
|
} % TODO: check author list
|
|
|
{\large $institute%
|
|
{\large $institute%
|
|
|
-} % TODO: check author list
|
|
|
|
|
|
|
+} % TODO: check institutes
|
|
|
\\end{center}
|
|
\\end{center}
|
|
|
END;
|
|
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);
|
|
",$tex);
|
|
|
|
|
+ if (preg_match("/\\\begin{document}/i",$tex) == 1)
|
|
|
|
|
+ {
|
|
|
$tex = preg_replace("/\\\begin{document}/i",$header,$tex);
|
|
$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]
|
|
\printbibliography[title={References}, heading=subbibliography]
|
|
|
\end{sloppypar}',$tex);
|
|
\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;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -520,9 +604,9 @@ END;
|
|
|
{
|
|
{
|
|
|
if (str_starts_with($a,"-"))
|
|
if (str_starts_with($a,"-"))
|
|
|
$options[$a] = 1;
|
|
$options[$a] = 1;
|
|
|
- if ($a == "-n")
|
|
|
|
|
- $options["--no-overwrite"] = 1;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ if (isset($options["-n"]) && !isset($options["--force-overwrite"]))
|
|
|
|
|
+ $options["--no-overwrite"] = 1;
|
|
|
return $options;
|
|
return $options;
|
|
|
}
|
|
}
|
|
|
function compile_check($papers,$precopy = false)
|
|
function compile_check($papers,$precopy = false)
|
|
@@ -591,13 +675,24 @@ END;
|
|
|
}
|
|
}
|
|
|
sort($kpsefiles);
|
|
sort($kpsefiles);
|
|
|
}
|
|
}
|
|
|
|
|
+ echo "\n=== Step 1/$steps: Check Software and Command Line Options ===\n\n";
|
|
|
check_software();
|
|
check_software();
|
|
|
$options = check_options($argv);
|
|
$options = check_options($argv);
|
|
|
if (isset($options["--help"]))
|
|
if (isset($options["--help"]))
|
|
|
print_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);
|
|
[$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;
|
|
$targets_exist = true;
|
|
|
foreach ($targets as $t)
|
|
foreach ($targets as $t)
|
|
|
if (!is_dir($t))
|
|
if (!is_dir($t))
|
|
@@ -606,50 +701,42 @@ END;
|
|
|
echo "Skipping...\n";
|
|
echo "Skipping...\n";
|
|
|
else
|
|
else
|
|
|
compile_check($argv,true);
|
|
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);
|
|
$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"]);
|
|
$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"]))
|
|
if (isset($options["--no-compile-check"]))
|
|
|
echo "Skipping...\n";
|
|
echo "Skipping...\n";
|
|
|
else
|
|
else
|
|
|
compile_check($papers);
|
|
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,$usepackages1] = getusepackages(file_get_contents("main.tex.php"));
|
|
|
[$_t,$usepackages2] = getusepackages(file_get_contents("tugraz_defaults.sty"));
|
|
[$_t,$usepackages2] = getusepackages(file_get_contents("tugraz_defaults.sty"));
|
|
|
global $included_usepackages;
|
|
global $included_usepackages;
|
|
|
$included_usepackages = array_unique(array_merge($usepackages1, $usepackages2));
|
|
$included_usepackages = array_unique(array_merge($usepackages1, $usepackages2));
|
|
|
sort($included_usepackages);
|
|
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)
|
|
foreach ($papers as $k => $v)
|
|
|
{
|
|
{
|
|
|
if (str_ends_with($papers[$k],".pdf"))
|
|
if (str_ends_with($papers[$k],".pdf"))
|
|
|
$papers[$k] = 'main.tex';
|
|
$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_type = user_prompt("Enter Thesis Type ","PhD Thesis");
|
|
|
$thesis_title = user_prompt("Enter Thesis Title ","Security of TODO");
|
|
$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_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_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");
|
|
$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();
|
|
ob_start();
|
|
|
require "main.tex.php";
|
|
require "main.tex.php";
|
|
|
$maintex_content = ob_get_contents();
|
|
$maintex_content = ob_get_contents();
|
|
@@ -676,7 +755,7 @@ END;
|
|
|
file_put_contents("main.tex",$maintex_content);
|
|
file_put_contents("main.tex",$maintex_content);
|
|
|
|
|
|
|
|
if (!file_exists("mypreamble.sty") || user_consent("mypreamble.sty already exists... overwrite?","--force-overwrite","--no-overwrite"))
|
|
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");
|
|
@mkdir("tikz");
|
|
|
|
|
|
|
@@ -700,23 +779,32 @@ END;
|
|
|
file_put_contents("cv.tex","This is my CV! Thanks for checking it out!");
|
|
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";
|
|
|
|
|
+ }
|
|
|
?>
|
|
?>
|