From e7b84f8b87da8ea1add3cda9ba3a07cf1f86e7b6 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 7 Jun 2017 02:14:31 +0200 Subject: Much more extensive pdf compiling --- gup/Gupfile | 2 ++ gup/pdf.gup | 76 ++++++++++++++++++++++++++++++++++++++++++++--- gup/ps.gup | 7 +++++ preamble.tex | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- shell.nix | 3 +- 5 files changed, 176 insertions(+), 9 deletions(-) create mode 100644 gup/ps.gup diff --git a/gup/Gupfile b/gup/Gupfile index 0478f35..8912143 100644 --- a/gup/Gupfile +++ b/gup/Gupfile @@ -1,5 +1,7 @@ pdf.gup: **/*.pdf +ps.gup: + **/*.ps abgabe.gup: **/abgabe.zip manifest.gup: diff --git a/gup/pdf.gup b/gup/pdf.gup index 3b3aa3a..96f46ca 100755 --- a/gup/pdf.gup +++ b/gup/pdf.gup @@ -1,9 +1,77 @@ #!/usr/bin/env zsh -base=(${2%.pdf}.(md|lhs)([1])) +ret=0 -gup -u ${base} preamble.tex +logged() { + printf ">>> ā€˜%sā€™ in %s\n" "$*" $(pwd) >&2 + ${@} + ret=$? + printf ">>> %d\n" $ret >&2 +} -for i ({0..1}); do - pandoc -t latex -o $1 -V "geometry=margin=2cm" -V "fontfamily=libertine" -H preamble.tex --listings --latex-engine=lualatex ${base} >&2 +typeset -a cleanupList +cleanupList=() +cleanup() { + for cmd in ${cleanupList}; do + eval $cmd + done +} +trap cleanup EXIT + +base=(${2%.pdf}.(md|lhs|tex)([1])) +metadata=(${2%.pdf}.meta.yml([1]N)) + +gup -u ${base} ${metadata} preamble.tex + +buildDir=$(pwd) + +base=${base:A} +metadata=${metadata:A} +cd ${base:h} + +input=${base} + +typeset -a extraArgs +extraArgs=(-R -V "geometry=margin=2cm" -V "fontfamily=libertine" -H ${buildDir}/preamble.tex --listings --latex-engine=lualatex --filter=pandoc-citeproc --biblatex) + + +if [[ -n ${metadata} ]]; then + input=$(mktemp) + cleanupList+=("rm -v ${input}") + + logged pandoc -f markdown -t native -s ${metadata} | head -n -1 >>${input} + logged pandoc -R -t native ${base} >>${input} + + extraArgs+=(-f native) +fi + +# logged pandoc ${extraArgs} -t latex ${base} | cat -n >&2 + +compileDir=$(mktemp -d) +cleanupList+=("cd /" "rm -rfv ${compileDir}") + +logged pandoc ${extraArgs} -t latex -o ${compileDir}/${base:t:r}.tex ${input} >&2 + +cd ${compileDir} +for f (bib); do + printf "Checking for ā€˜%sā€™\n" ${base:h}/${f} >&2 + [[ -e ${base:h}/${f} ]] || continue + logged rsync -av ${base:h}/${f} . +done + +max=5 +runs=0 +run=true +while ${run} && [[ ${runs} -lt ${max} ]]; do + output=$(mktemp) + cleanupList+=("rm -v ${output}") + logged lualatex ${base:t:r}.tex >${output} {$}l<{$}} +\newcolumntype{C}{>{$}c<{$}} + +\DeclareTranslation{English}{float-algorithm}{Algorithm} +\DeclareTranslation{German}{float-algorithm}{Algorithmus} + +\floatstyle{ruled} +\newfloat{algorithm}{tbp}{lop} +\floatname{algorithm}{\GetTranslation{float-algorithm}} \lstset{ frame=tb, @@ -30,5 +45,79 @@ keywordstyle= \providecommand{\limplies}{\ensuremath{\Rightarrow}} \providecommand{\seq}{\ensuremath{\Longrightarrow}} -\theoremstyle{definition} -\newtheorem*{def*}{Definition} +\DeclareTranslation{English}{thm-definition}{Definition} +\DeclareTranslation{German}{thm-definition}{Definition} +\DeclareTranslation{English}{thm-theorem}{Theorem} +\DeclareTranslation{German}{thm-theorem}{Satz} +\DeclareTranslation{English}{thm-example}{Example} +\DeclareTranslation{German}{thm-example}{Beispiel} +\DeclareTranslation{English}{thm-remark}{Remark} +\DeclareTranslation{German}{thm-remark}{Anmerkung} +\DeclareTranslation{English}{thm-lemma}{Lemma} +\DeclareTranslation{German}{thm-lemma}{Lemma} +\DeclareTranslation{English}{thm-proofsketch}{Proof Sketch} +\DeclareTranslation{German}{thm-proofsketch}{Beweisskizze} +\DeclareTranslation{English}{thm-show}{To show} +\DeclareTranslation{German}{thm-show}{Zu Zeigen} + +\makeatletter +\newtheoremstyle{definition.indented} + {3pt}% space before + {3pt}% space after + {\addtolength{\@totalleftmargin}{2.5em} + \addtolength{\linewidth}{-2.5em} + \parshape 1 2.5em \linewidth}% body font + {}% indent + {\bfseries}% header font + {.}% punctuation + {.5em}% after theorem header + {}% header specification (empty for default) +\newtheoremstyle{plain.indented} + {3pt}% space before + {3pt}% space after + {\addtolength{\@totalleftmargin}{2.5em} + \addtolength{\linewidth}{-2.5em} + \parshape 1 2.5em \linewidth + \itshape}% body font + {}% indent + {\bfseries}% header font + {.}% punctuation + {.5em}% after theorem header + {}% header specification (empty for default) +\newtheoremstyle{remark.indented} + {3pt}% space before + {3pt}% space after + {\addtolength{\@totalleftmargin}{2.5em} + \addtolength{\linewidth}{-2.5em} + \parshape 1 2.5em \linewidth}% body font + {}% indent + {\itshape}% header font + {.}% punctuation + {.5em}% after theorem header + {}% header specification (empty for default) +\makeatother + +\theoremstyle{definition.indented} +\newtheorem{defn}{\GetTranslation{thm-definition}} +\newtheorem*{defn*}{\GetTranslation{thm-definition}} + +\theoremstyle{plain.indented} +\newtheorem{thm}{\GetTranslation{thm-theorem}} +\newtheorem*{thm*}{\GetTranslation{thm-theorem}} +\newtheorem{lem}[thm]{\GetTranslation{thm-lemma}} +\newtheorem*{lem*}{\GetTranslation{thm-lemma}} + +\theoremstyle{remark.indented} +\newtheorem{rem}{\GetTranslation{thm-remark}} +\newtheorem*{rem*}{\GetTranslation{thm-remark}} +\newtheorem{eg}[rem]{\GetTranslation{thm-example}} +\newtheorem*{eg*}{\GetTranslation{thm-example}} +\newtheorem*{sketch}{\GetTranslation{thm-proofsketch}} +\newtheorem*{tshow}{\GetTranslation{thm-show}} + +\newcommand\restr[2]{{% we make the whole thing an ordinary symbol + \left.\kern-\nulldelimiterspace % automatically resize the bar with \right + #1 % the function + \vphantom{\big|} % pretend it's a little taller at normal size + \right|_{#2} % this is the delimiter + }} diff --git a/shell.nix b/shell.nix index 19a4096..60e1a1d 100644 --- a/shell.nix +++ b/shell.nix @@ -11,9 +11,10 @@ pkgs.stdenv.mkDerivation rec { (pkgs.callPackage ./mars.nix {}) pkgs.sqlite (pkgs.haskellPackages.ghcWithPackages (p: - with p; [ yesod yesod-bin pandoc monad-par persistent-sqlite containers base-unicode-symbols containers-unicode-symbols + with p; [ yesod yesod-bin pandoc pandoc-citeproc monad-par persistent-sqlite containers base-unicode-symbols containers-unicode-symbols ])) pkgs.texlive.combined.scheme-full + pkgs.biber ]; shellHook = '' export PROMPT_INFO="${name}" -- cgit v1.2.3