Adding compiling option for listings.

This commit is contained in:
Kremitzl 2021-11-17 21:53:03 +01:00
parent be170abc01
commit f18ed4ab9c
3 changed files with 22 additions and 1 deletions

1
.gitignore vendored
View File

@ -80,6 +80,7 @@ _minted*
*.swo *.swo
main.pdf main.pdf
listings-mode.tex
exercise-mode.tex exercise-mode.tex
public public
exercises/*/*.pdf exercises/*/*.pdf

View File

@ -23,6 +23,7 @@ tasks: exercises/**/*
# Compile a preview PDF containing all contents # Compile a preview PDF containing all contents
preview: main.tex preview: main.tex
echo "\newcommand\exercisemode{any}" > exercise-mode.tex echo "\newcommand\exercisemode{any}" > exercise-mode.tex
echo "\newcommand\listingsmode{minted}" > listings-mode.tex
pdflatex -shell-escape main.tex pdflatex -shell-escape main.tex
@echo @echo
@echo @echo
@ -43,6 +44,7 @@ publication-dir:
# Compile a printable PDF without exercises # Compile a printable PDF without exercises
publication-pdf-without-exercises: clean publication-dir main.tex publication-pdf-without-exercises: clean publication-dir main.tex
echo "\newcommand\exercisemode{none}" > exercise-mode.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 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 # Compile a printable PDF with exercises and without solutions
publication-pdf-with-exercises: clean publication-dir main.tex publication-pdf-with-exercises: clean publication-dir main.tex
echo "\newcommand\exercisemode{exercises}" > exercise-mode.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 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 # Compile a printable PDF with exercises and solutions
publication-pdf-with-solutions: clean publication-dir main.tex publication-pdf-with-solutions: clean publication-dir main.tex
echo "\newcommand\exercisemode{solutions}" > exercise-mode.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 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

View File

@ -34,6 +34,18 @@
\rule{\widefigurewidth}{0.4pt} \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 % Shell command
% ============== % ==============
% Mono-spaced text without syntax highlighting. % Mono-spaced text without syntax highlighting.
@ -58,7 +70,11 @@
% Mono-spaced text without syntax highlighting. % Mono-spaced text without syntax highlighting.
% Intended for LaTeX package names. % Intended for LaTeX package names.
\newcommand\pkg[1]{% \newcommand\pkg[1]{%
\texttt{#1}% \ifthenelse{\equal{\listingsmode}{minted}}{%
\texttt{#1}%
}{%
\texttt{#1}%
}
} }
% File paths % File paths