From e0b6ca4f33e415bb81640d8cfda8162dfe853fe5 Mon Sep 17 00:00:00 2001 From: Jan Benda Date: Sun, 1 Dec 2019 17:35:42 +0100 Subject: [PATCH] exercises either here, at end of chapter or at end of script --- Makefile | 2 +- bootstrap/lecture/bootstrap-chapter.tex | 2 +- chapter.mk | 2 +- debugging/lecture/debugging-chapter.tex | 2 +- .../lecture/designpattern-chapter.tex | 2 +- header.tex | 94 +++++++++++++----- likelihood/lecture/likelihood-chapter.tex | 2 +- plotting/lecture/plotting-chapter.tex | 2 +- .../lecture/pointprocesses-chapter.tex | 2 +- .../lecture/pointprocessscetchA.eps | 4 +- .../lecture/pointprocessscetchA.pdf | Bin 2778 -> 2786 bytes .../lecture/pointprocessscetchB.eps | 4 +- .../lecture/pointprocessscetchB.pdf | Bin 4694 -> 4694 bytes programming/lecture/programming-chapter.tex | 2 +- .../lecture/programmingstyle-chapter.tex | 2 +- regression/lecture/regression-chapter.tex | 2 +- scientificcomputing-script.tex | 31 +++--- statistics/lecture/statistics-chapter.tex | 2 +- 18 files changed, 104 insertions(+), 53 deletions(-) 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 031d80537466312365e68359552e3971d13272df..149f7ba117cfcb15e0c2a7a673105678fa42e731 100644 GIT binary patch delta 289 zcmca5`bc!cQD$B<3u8kA3yU;elVsDB$pLKglRq+NVG(U-vE((So#MRBv*woU+(9w>tipdAKqyVcONPhqT delta 303 zcmaDPdP{V}QD$BPqf|=+gH&T(lcbd7$pLKglRq+NVG(U-vE((>H8uz_GPW|bv@$ZD ze3nI1Jh4PU*DqhUOd-VBz)Hc$3M^-3JeilZ35yxKS?w`IB__+Wsi2B(4q$6%G6EXy zmtUq}Y@h(MQNhT-&{C62-#0(SC9xz`!^H|DU}$J;U}S7)X=J>ale3yJOe4nF)HE-~ zz`)!i#=zLPvM9mcHU_A|w>H!wP!qpwESH@fS8+*VQAtHnY8sc3iLo)4s;aBM8y5iF C`cSw4 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 2517ae1107795b4ba5aacb0bfc11514643de6d93..39a96256c7f05fc766e9bd525b04d6e7ac9d446e 100644 GIT binary patch delta 269 zcmcbna!qA}B{#2`MY5%3nn9YbNwR6mWC33J$*J5~7@`W3|8QII8tEDsh8UVynV4D` zTTXW5(G)MuQ_yuu)lF6iQ82UuBCwp5#pFhwCJZy;FhnFKPv%v@5S8Ejm^Xt-2xzoR zYO;cYp#s!Ki^;J9;+#eXhK434rpA_=YXxc;oy;svot!P5oZKuNjV#@q+>9M9%`D8! WEsRXe9L)_~EbMFushDgnBn<$XLPVkf delta 269 zcmcbna!qA}B{#2uQL3eZL8`H?Nm5GkWC33J$*J5~7@`W3|8QII8tNJwgcuoH8CqHy z8BccP(G*WCQPB0v*DX^BF*dMLFtP&6Ss71m=;G++ VYT)W