diff --git a/.gitignore b/.gitignore index 7c828ef..278812b 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,7 @@ _minted* *.swo main.pdf +listings-mode.tex exercise-mode.tex public exercises/*/*.pdf diff --git a/Makefile b/Makefile index faa6053..7d8a57a 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ tasks: exercises/**/* # Compile a preview PDF containing all contents preview: main.tex echo "\newcommand\exercisemode{any}" > exercise-mode.tex + echo "\newcommand\listingsmode{minted}" > listings-mode.tex pdflatex -shell-escape main.tex @echo @echo @@ -43,6 +44,7 @@ publication-dir: # Compile a printable PDF without exercises publication-pdf-without-exercises: clean publication-dir main.tex echo "\newcommand\exercisemode{none}" > exercise-mode.tex + echo "\newcommand\listingsmode{minted}" > listings-mode.tex pdflatex -shell-escape -jobname=script-only main.tex pdflatex -shell-escape -jobname=script-only main.tex pdflatex -shell-escape -jobname=script-only main.tex @@ -51,6 +53,7 @@ publication-pdf-without-exercises: clean publication-dir main.tex # Compile a printable PDF with exercises and without solutions publication-pdf-with-exercises: clean publication-dir main.tex echo "\newcommand\exercisemode{exercises}" > exercise-mode.tex + echo "\newcommand\listingsmode{minted}" > listings-mode.tex pdflatex -shell-escape -jobname=script-with-exercises main.tex pdflatex -shell-escape -jobname=script-with-exercises main.tex pdflatex -shell-escape -jobname=script-with-exercises main.tex @@ -59,6 +62,7 @@ publication-pdf-with-exercises: clean publication-dir main.tex # Compile a printable PDF with exercises and solutions publication-pdf-with-solutions: clean publication-dir main.tex echo "\newcommand\exercisemode{solutions}" > exercise-mode.tex + echo "\newcommand\listingsmode{minted}" > listings-mode.tex pdflatex -shell-escape -jobname=script-with-solutions main.tex pdflatex -shell-escape -jobname=script-with-solutions main.tex pdflatex -shell-escape -jobname=script-with-solutions main.tex diff --git a/commands.tex b/commands.tex index 36c776f..70ceddd 100644 --- a/commands.tex +++ b/commands.tex @@ -34,6 +34,18 @@ \rule{\widefigurewidth}{0.4pt} } +% Listings mode +% ============= +% The listings mode can be chosen by writing one of the following to the listings-mode.tex file before compilation: +% \newcommand\listingsmode{default} % to use lstlistings +% \newcommand\listingsmode{minted} % for a script with exercises only +% The following lines include that file or make \listingsmode default to 'default' so that any derivatives of this project will work even without the file. +\IfFileExists{listings-mode.tex}{ + \input{listings-mode.tex} +}{ + \newcommand\listingsmode{default} +} + % Shell command % ============== % Mono-spaced text without syntax highlighting. @@ -58,7 +70,11 @@ % Mono-spaced text without syntax highlighting. % Intended for LaTeX package names. \newcommand\pkg[1]{% - \texttt{#1}% + \ifthenelse{\equal{\listingsmode}{minted}}{% + \texttt{#1}% + }{% + \texttt{#1}% + } } % File paths