diff --git a/Makefile b/Makefile index 7ded4cf..938a933 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ watchscript : clean : - rm -f *~ $(BASENAME).aux $(BASENAME).log $(BASENAME).out $(BASENAME).toc $(BASENAME).lo? $(BASENAME).idx $(BASENAME)-term.i* $(BASENAME)-enterm.i* $(BASENAME)-code.i* + rm -f *~ $(BASENAME).aux $(BASENAME).log $(BASENAME).out $(BASENAME)-solutions.tex $(BASENAME).toc $(BASENAME).lo? $(BASENAME).idx $(BASENAME)-term.i* $(BASENAME)-enterm.i* $(BASENAME)-code.i* for sd in $(SUBDIRS); do $(MAKE) -C $$sd/lecture clean; done cleanall : clean diff --git a/bootstrap/lecture/bootstrap-chapter.tex b/bootstrap/lecture/bootstrap-chapter.tex index dc5b25b..a1064df 100644 --- a/bootstrap/lecture/bootstrap-chapter.tex +++ b/bootstrap/lecture/bootstrap-chapter.tex @@ -14,7 +14,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\input{bootstrap} +\include{bootstrap} \section{TODO} \begin{itemize} diff --git a/chapter.mk b/chapter.mk index 015c9dc..3c7da22 100644 --- a/chapter.mk +++ b/chapter.mk @@ -46,7 +46,7 @@ watchchapter : cleanchapter : cleanpythonplots cleangnuplots rm -f *~ rm -f $(BASENAME).aux $(BASENAME).log - rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out $(BASENAME)-chapter.idx $(BASENAME)-chapter-solutions.tex + rm -f $(BASENAME)-chapter.aux $(BASENAME)-chapter.log $(BASENAME)-chapter.out $(BASENAME)-chapter.idx $(BASENAME)-chapter-solutions.tex $(BASENAME)-solutions.tex cleanallchapter : cleanchapter diff --git a/debugging/lecture/debugging-chapter.tex b/debugging/lecture/debugging-chapter.tex index d707b86..75472c9 100644 --- a/debugging/lecture/debugging-chapter.tex +++ b/debugging/lecture/debugging-chapter.tex @@ -15,7 +15,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\input{debugging} +\include{debugging} \end{document} diff --git a/designpattern/lecture/designpattern-chapter.tex b/designpattern/lecture/designpattern-chapter.tex index aa790eb..a45a6d0 100644 --- a/designpattern/lecture/designpattern-chapter.tex +++ b/designpattern/lecture/designpattern-chapter.tex @@ -14,7 +14,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\input{designpattern} +\include{designpattern} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Sortieren von Vektoren} diff --git a/header.tex b/header.tex index b208c30..e78eb5d 100644 --- a/header.tex +++ b/header.tex @@ -282,6 +282,22 @@ % % The boolean showexercisesolutions controls whether solutions for the exercises % are actually included. +% +% \exercisesolutions controls where the solutions of the exercises are placed: +% - 'here': solutions are printed right after the exercises in the same box +% - 'chapter': solutions are printed at the end of each chapter +% - 'end': all solutions are printed at the end of the script +% +\newboolean{showexercisesolutions} +\setboolean{showexercisesolutions}{true} +\newcommand{\exercisesolutions}{chapter} % 0: here, 1: chapter, 2: end +% we need this also as numbers: +\ifthenelse{\equal{\exercisesolutions}{end}}{\newcommand{\exercisesolutionsnum}{2}}{% + \ifthenelse{\equal{\exercisesolutions}{chapter}}{\newcommand{\exercisesolutionsnum}{1}}{% + \newcommand{\exercisesolutionsnum}{0}}} +\newcommand{\codepath}{} +\newcommand{\setcodepath}[1]{\ifthenelse{\not\equal{\exercisesolutions}{here}}{\renewcommand{\codepath}{#1/}}{}\lstset{inputpath=#1}} +\newcommand{\exercisesection}[1]{} \usepackage{mdframed} \usepackage{xstring} \newlistof{exercisef}{loe}{\tr{Exercises}{\"Ubungen}} @@ -291,16 +307,16 @@ placement=t, chapterlistsgaps=on, ]{exercisef} -\newboolean{showexercisesolutions} -\setboolean{showexercisesolutions}{true} \newwrite\solutions % file descriptor for writing solutions % we need to know the name of the included file as \currentjobname: \usepackage{xpatch} -\makeatletter -\def\currentjobname{\jobname}% -\xpretocmd{\include}{\def\currentjobname{#1}\immediate\openout\solutions=\currentjobname-solutions}{}{} -\makeatother -\usepackage{needspace} +% the following does not work with \ifthenelse +\ifnum\exercisesolutionsnum=1 + \def\currentjobname{\jobname} + \xpretocmd{\include}{\def\currentjobname{#1}\immediate\openout\solutions=\currentjobname-solutions}{}{}\fi% +\ifnum\exercisesolutionsnum=2 + \def\currentjobname{\jobname} + \immediate\openout\solutions=\currentjobname-solutions\fi \newenvironment{exercise}[2]% { \setlength{\fboxsep}{2mm}% \newcommand{\saveenumi}{\theenumi}\renewcommand{\labelenumi}{(\alph{enumi})}% @@ -309,27 +325,59 @@ \begin{mdframed}[linewidth=0pt,backgroundcolor=exerciseback]% \captionof{exercisef}[\protect\StrSubstitute{#1}{_}{\_}]{}% \captionsetup{font={normal,sf,it}}% - \immediate\write\solutions{\unexpanded{% - \subsection}[Exercise \thechapter.\arabic{exercisef}]% - {\unexpanded{\needspace{4\baselineskip}}Exercise \thechapter.\arabic{exercisef}}}% - \immediate\write\solutions{\unexpanded{\label}{solution\arabic{exercisef}}}% - \immediate\write\solutions{\unexpanded{\lstinputlisting[belowskip=0ex,aboveskip=0ex,% - nolol=true, title={\textbf{Source code:} \protect\StrSubstitute{#1}{_}{\_}}]}{#1}}% - \ifthenelse{\equal{#2}{}}{}% - {\immediate\write\solutions{\unexpanded{\lstinputlisting[language={},% - nolol=true, title={\textbf{Output:}}, belowskip=0ex, aboveskip=1ex]}{#2}}}% - \immediate\write\solutions{}% + \ifthenelse{\equal{\exercisesolutions}{here}}{% + \newcommand{\exercisesource}{#1}% + \newcommand{\exercisefile}{\protect\StrSubstitute{#1}{_}{\_}}% + \newcommand{\exerciseoutput}{#2}% + }{% + \immediate\write\solutions{\unexpanded{\exercisesection}{Exercise \thechapter.\arabic{exercisef}}}% + \immediate\write\solutions{\unexpanded{\label}{solution\arabic{chapter}-\arabic{exercisef}}}% + \immediate\write\solutions{\unexpanded{\lstinputlisting[belowskip=0ex,aboveskip=0ex,% + nolol=true, title={\textbf{Source code:} \protect\StrSubstitute{#1}{_}{\_}}]}{\codepath#1}}% + \ifthenelse{\equal{#2}{}}{}% + {\immediate\write\solutions{\unexpanded{\lstinputlisting[language={},% + nolol=true, title={\textbf{Output:}}, belowskip=0ex, aboveskip=1ex]}{\codepath#2}}}% + \immediate\write\solutions{}% + }% }% - { \ifthenelse{\boolean{showexercisesolutions}}% - {\hspace*{\fill}\hyperref[solution\arabic{exercisef}]{Solution}}{}% + { \ifthenelse{\equal{\exercisesolutions}{here}}{% + \ifthenelse{\boolean{showexercisesolutions}}% + { \hypersetup{hypertexnames=false}% + \ifthenelse{\equal{\exercisesource}{}}{}% + { \addtocounter{lstlisting}{-1}% + \lstinputlisting[belowskip=0pt,aboveskip=1ex,nolol=true,% + title={\textbf{Solution:} \exercisefile}]% + {\exercisesource}% + \ifthenelse{\equal{\exerciseoutput}{}}{}% + { \addtocounter{lstlisting}{-1}% + \lstinputlisting[language={},title={\textbf{Output:}},% + nolol=true,belowskip=0pt]% + {\exerciseoutput}% + }% + }% + \hypersetup{hypertexnames=true}% + }{}}{% + \ifthenelse{\boolean{showexercisesolutions}}% + {\hspace*{\fill}\hyperref[solution\arabic{chapter}-\arabic{exercisef}]{\mbox{$\rightarrow$ solution}}}{}}% \renewcommand{\theenumi}{\saveenumi}% \end{mdframed}% } } -\newcommand{\printsolutions}{\immediate\closeout\solutions% - \ifthenelse{\boolean{showexercisesolutions}}{% - \clearpage\section{Solutions to the exercises}% - \input{\currentjobname-solutions}}{}} +\newcommand{\printsolutions}{\ifthenelse{\equal{\exercisesolutions}{chapter}% + \or\(\equal{\exercisesolutions}{end}\and\not\isundefined{\chapternumber}\)}{% + \immediate\closeout\solutions% + \ifthenelse{\boolean{showexercisesolutions}}{% + \clearpage\section{Solutions to the exercises}% + \renewcommand{\exercisesection}[1]{\subsection{#1}}% + \ifthenelse{\isundefined{\chapternumber}}{\lstset{inputpath=}}{}% + \input{\currentjobname-solutions} }{}}{}} +\newcommand{\printallsolutions}{\ifthenelse{\equal{\exercisesolutions}{end}}{% + \immediate\closeout\solutions% + \ifthenelse{\boolean{showexercisesolutions}}{% + \setcounter{secnumdepth}{0}\lstset{inputpath=}% + \clearpage\chapter{Solutions to the exercises}% + \renewcommand{\exercisesection}[1]{\section{#1}}% + \input{\currentjobname-solutions} }{}}{}} \setlength{\cftexercisefindent}{1.2em} \setlength{\cftexercisefnumwidth}{2.6em} diff --git a/likelihood/lecture/likelihood-chapter.tex b/likelihood/lecture/likelihood-chapter.tex index 38d02d4..e6503cf 100644 --- a/likelihood/lecture/likelihood-chapter.tex +++ b/likelihood/lecture/likelihood-chapter.tex @@ -14,7 +14,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\input{likelihood} +\include{likelihood} \section{TODO} \begin{itemize} diff --git a/plotting/lecture/plotting-chapter.tex b/plotting/lecture/plotting-chapter.tex index 72d666a..6a96c4a 100644 --- a/plotting/lecture/plotting-chapter.tex +++ b/plotting/lecture/plotting-chapter.tex @@ -14,7 +14,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\input{plotting} +\include{plotting} \subsection{Heatmaps} diff --git a/pointprocesses/lecture/pointprocesses-chapter.tex b/pointprocesses/lecture/pointprocesses-chapter.tex index bb88013..e71ae61 100644 --- a/pointprocesses/lecture/pointprocesses-chapter.tex +++ b/pointprocesses/lecture/pointprocesses-chapter.tex @@ -14,7 +14,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\input{pointprocesses} +\include{pointprocesses} \section{TODO} \begin{itemize} diff --git a/pointprocesses/lecture/pointprocessscetchA.eps b/pointprocesses/lecture/pointprocessscetchA.eps index 2ff01b6..95fada0 100644 --- a/pointprocesses/lecture/pointprocessscetchA.eps +++ b/pointprocesses/lecture/pointprocessscetchA.eps @@ -1,7 +1,7 @@ %!PS-Adobe-2.0 EPSF-2.0 %%Title: pointprocessscetchA.tex %%Creator: gnuplot 4.6 patchlevel 4 -%%CreationDate: Sat Nov 30 23:19:23 2019 +%%CreationDate: Sun Dec 1 14:45:38 2019 %%DocumentFonts: %%BoundingBox: 50 50 373 135 %%EndComments @@ -433,7 +433,7 @@ SDict begin [ /Author (jan) % /Producer (gnuplot) % /Keywords () - /CreationDate (Sat Nov 30 23:19:23 2019) + /CreationDate (Sun Dec 1 14:45:38 2019) /DOCINFO pdfmark end } ifelse diff --git a/pointprocesses/lecture/pointprocessscetchA.pdf b/pointprocesses/lecture/pointprocessscetchA.pdf index 031d805..149f7ba 100644 Binary files a/pointprocesses/lecture/pointprocessscetchA.pdf and b/pointprocesses/lecture/pointprocessscetchA.pdf differ diff --git a/pointprocesses/lecture/pointprocessscetchB.eps b/pointprocesses/lecture/pointprocessscetchB.eps index 58a25ce..c58c091 100644 --- a/pointprocesses/lecture/pointprocessscetchB.eps +++ b/pointprocesses/lecture/pointprocessscetchB.eps @@ -1,7 +1,7 @@ %!PS-Adobe-2.0 EPSF-2.0 %%Title: pointprocessscetchB.tex %%Creator: gnuplot 4.6 patchlevel 4 -%%CreationDate: Sat Nov 30 23:19:23 2019 +%%CreationDate: Sun Dec 1 14:45:38 2019 %%DocumentFonts: %%BoundingBox: 50 50 373 237 %%EndComments @@ -433,7 +433,7 @@ SDict begin [ /Author (jan) % /Producer (gnuplot) % /Keywords () - /CreationDate (Sat Nov 30 23:19:23 2019) + /CreationDate (Sun Dec 1 14:45:38 2019) /DOCINFO pdfmark end } ifelse diff --git a/pointprocesses/lecture/pointprocessscetchB.pdf b/pointprocesses/lecture/pointprocessscetchB.pdf index 2517ae1..39a9625 100644 Binary files a/pointprocesses/lecture/pointprocessscetchB.pdf and b/pointprocesses/lecture/pointprocessscetchB.pdf differ diff --git a/programming/lecture/programming-chapter.tex b/programming/lecture/programming-chapter.tex index 6d3ed40..2a76f64 100644 --- a/programming/lecture/programming-chapter.tex +++ b/programming/lecture/programming-chapter.tex @@ -14,7 +14,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\input{programming} +\include{programming} \section{TODO} \begin{itemize} diff --git a/programmingstyle/lecture/programmingstyle-chapter.tex b/programmingstyle/lecture/programmingstyle-chapter.tex index 58fddce..78243a6 100644 --- a/programmingstyle/lecture/programmingstyle-chapter.tex +++ b/programmingstyle/lecture/programmingstyle-chapter.tex @@ -14,7 +14,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\input{programmingstyle} +\include{programmingstyle} \end{document} diff --git a/regression/lecture/regression-chapter.tex b/regression/lecture/regression-chapter.tex index 7a76010..73155b4 100644 --- a/regression/lecture/regression-chapter.tex +++ b/regression/lecture/regression-chapter.tex @@ -14,7 +14,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\input{regression} +\include{regression} \section{Improvements} Adapt function arguments to matlabs polyfit. That is: first the data diff --git a/scientificcomputing-script.tex b/scientificcomputing-script.tex index 1e5fb9d..71657ea 100644 --- a/scientificcomputing-script.tex +++ b/scientificcomputing-script.tex @@ -32,23 +32,23 @@ \part{Programming basics} \graphicspath{{programming/lecture/}{programming/images/}} -\lstset{inputpath=programming/code} +\setcodepath{programming/code} \include{programming/lecture/programming} \graphicspath{{debugging/lecture/}{debugging/lecture/figures/}} -\lstset{inputpath=debugging/code} +\setcodepath{debugging/code} \include{debugging/lecture/debugging} \graphicspath{{plotting/lecture/}{plotting/lecture/images/}} -\lstset{inputpath=plotting/code/} +\setcodepath{plotting/code} \include{plotting/lecture/plotting} \graphicspath{{programmingstyle/lecture/}{programmingstyle/lecture/figures/}} -\lstset{inputpath=programmingstyle/code/} +\setcodepath{programmingstyle/code} \include{programmingstyle/lecture/programmingstyle} \graphicspath{{designpattern/lecture/}{designpattern/lecture/figures/}} -\lstset{inputpath=designpattern/code} +\setcodepath{designpattern/code} \include{designpattern/lecture/designpattern} @@ -56,29 +56,29 @@ \part{Data analysis} \graphicspath{{statistics/lecture/}{statistics/lecture/figures/}} -\lstset{inputpath=statistics/code} +\setcodepath{statistics/code} \include{statistics/lecture/statistics} \graphicspath{{bootstrap/lecture/}{bootstrap/lecture/figures/}} -\lstset{inputpath=bootstrap/code} +\setcodepath{bootstrap/code} \include{bootstrap/lecture/bootstrap} \graphicspath{{regression/lecture/}{regression/lecture/figures/}} -\lstset{inputpath=regression/code} +\setcodepath{regression/code} \include{regression/lecture/regression} \graphicspath{{likelihood/lecture/}{likelihood/lecture/figures/}} -\lstset{inputpath=likelihood/code} +\setcodepath{likelihood/code} \include{likelihood/lecture/likelihood} \graphicspath{{pointprocesses/lecture/}{pointprocesses/lecture/figures/}} -\lstset{inputpath=pointprocesses/code/} +\setcodepath{pointprocesses/code} \renewcommand{\texinputpath}{pointprocesses/lecture/} \include{pointprocesses/lecture/pointprocesses} -\graphicspath{{spectral/lecture/}{spectral/lecture/figures/}} -\lstset{inputpath=spectral/code/} -\renewcommand{\texinputpath}{spectral/lecture/} +%\graphicspath{{spectral/lecture/}{spectral/lecture/figures/}} +%\setcodepath{spectral/code/} +%\renewcommand{\texinputpath}{spectral/lecture/} %\include{spectral/lecture/spectral} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -99,10 +99,13 @@ \backmatter +%%%% solutions: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\printallsolutions + %%%% indices: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \printindex[term] -\printindex[determ] % for english text +\printindex[determ] % for english text % \printindex[enterm] % for german text %\setindexprenote{Some explanations.} diff --git a/statistics/lecture/statistics-chapter.tex b/statistics/lecture/statistics-chapter.tex index 1a87fc8..8945c92 100644 --- a/statistics/lecture/statistics-chapter.tex +++ b/statistics/lecture/statistics-chapter.tex @@ -14,7 +14,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} -\input{statistics} +\include{statistics} \end{document}