Extended Makefile and commands for publication artifacts.

This commit is contained in:
Kremitzl 2021-02-28 23:10:32 +01:00
parent 5e4374e310
commit 013f0f9fa8
8 changed files with 133 additions and 7 deletions

3
.gitignore vendored
View File

@ -80,3 +80,6 @@ _minted*
*.swo
main.pdf
exercise-mode.tex
public

View File

@ -1,9 +1,60 @@
default: all
SHELL=/bin/bash
all: listings main.tex
default: preview
# Remove builds and LaTeX output.
clean:
@echo Cleaning up temporary files.
@rm -rf public/*
@rm -f {main,script-only}.{aux,loc,log,out,pdf,soc,toc}
# Compile listings (only needed when listings have changed)
listings: listings/**/*
./compile_listings
pdflatex --shell-escape main.tex
latex: main.tex
pdflatex --shell-escape main.tex
# Compile a preview PDF containing all contents
preview: main.tex
echo "\newcommand\exercisemode{any}" > exercise-mode.tex
pdflatex -shell-escape main.tex
@echo
@echo
@echo Run \'make publication\' a few times to generate PDF and ZIP file for publication.
# Build all PDF and ZIP variants
publication: publication-pdf-without-exercises publication-pdf-with-exercises publication-pdf-with-solutions publication-zip-with-exercises publication-zip-with-solutions
#
# Building blocks from here on:
#
# Directory for files to be published
publication-dir:
mkdir -p public/
# Compile a printable PDF without exercises
publication-pdf-without-exercises: publication-dir main.tex
echo "\newcommand\exercisemode{none}" > exercise-mode.tex
pdflatex -shell-escape -jobname=script-only main.tex
mv script-only.pdf public/
# Compile a printable PDF with exercises and without solutions
publication-pdf-with-exercises: publication-dir main.tex
echo "\newcommand\exercisemode{exercises}" > exercise-mode.tex
pdflatex -shell-escape -jobname=script-with-exercises main.tex
mv script-with-exercises.pdf public/
# Compile a printable PDF with exercises and solutions
publication-pdf-with-solutions: publication-dir main.tex
echo "\newcommand\exercisemode{solutions}" > exercise-mode.tex
pdflatex -shell-escape -jobname=script-with-solutions main.tex
mv script-with-solutions.pdf public/
# Build a ZIP file with tasks and without solutions
publication-zip-with-exercises: publication-dir main.tex
zip public/project-with-exercises main.tex praeamble.tex commands.tex literature.bib content/* graphics/* listings/**/*.{tex,pdf} exercises/**/{task.tex,*.raw.tex}
# Build a ZIP file with tasks and solutions
publication-zip-with-solutions: publication-dir main.tex
zip public/project-with-solutions main.tex praeamble.tex commands.tex literature.bib content/* graphics/* listings/**/*.{tex,pdf} exercises/**/{task.tex,*.done.tex}

View File

@ -96,3 +96,63 @@
\label{#1}
\end{figure}
}
% Exercise mode
% =============
% The exercise mode can be chosen by writing one of the following to the exercise-mode.tex file before compilation:
% \newcommand\exercisemode{none} % for a blank script without exercises
% \newcommand\exercisemode{exercises} % for a script with exercises only
% \newcommand\exercisemode{solutions} % for a script with solutions only
% \newcommand\exercisemode{any} % for a script containing all available material
% The following lines include that file or make \exercisemode default to 'any' so that any derivatives of this project will work even without the file.
\IfFileExists{exercise-mode.tex}{
\input{exercise-mode.tex}
}{
\newcommand\exercisemode{any}
}
% Exercises
% =========
% Includes the task.tex file within the given subfolder of exercises and adds a heading.
\newcommand\exercise[1]{
\ifthenelse{\equal{\exercisemode}{none}}{
% Exercises disabled.
}{
\subsection*{Übung}
\input{exercises/#1/task.tex}
}
}
% Exercise Material
% =================
% Takes a project-relative path, and inserts matching exercise material and/or solutions, depending on the exercise mode.
\newcommand\exercisematerial[1]{
% Mode 'exercises': raw material only
\ifthenelse{\equal{\exercisemode}{exercises}}{
\IfFileExists{#1.raw.tex}{
\input{#1.raw.tex}
}{}
}{}
% Mode 'solutions': completed material only
\ifthenelse{\equal{\exercisemode}{solutions}}{
\IfFileExists{#1.done.tex}{
\input{#1.done.tex}
}{}
}{}
% Mode 'any': all existing material. If both raw and completed material exist, headings are added for each.
\ifthenelse{\equal{\exercisemode}{any}}{
\IfFileExists{#1.raw.tex}{
\IfFileExists{#1.done.tex}{
\subsubsection*{Vorschau des ungelösten Materials}
}{}
\input{#1.raw.tex}
}{}
\IfFileExists{#1.done.tex}{
\IfFileExists{#1.raw.tex}{
\subsubsection*{Vorschau des gelösten Materials}
}{}
\input{#1.done.tex}
}{}
}{}
}

View File

@ -0,0 +1 @@
Nonsense.

View File

@ -0,0 +1,2 @@
\emph{Lorem ipsum} dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \emph{Excepteur} sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@ -0,0 +1,2 @@
Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

View File

@ -0,0 +1,6 @@
\begin{enumerate}
\item Erste Aufgabe, lorem ipsum
\item Zweite Aufgabe, dolor sit amet
\end{enumerate}
\exercisematerial{exercises/text-markup/foo}
\exercisematerial{exercises/text-markup/bar}

View File

@ -25,6 +25,7 @@
\input{content/project-structure.tex}
\input{content/special-characters.tex}
\input{content/text-markup.tex}
\exercise{text-markup}
\input{content/formatting-paragraphs.tex}
\input{content/lists.tex}
\input{content/maths.tex}