From 07d9ed97109265151fa0a3f4b827a3400665385c Mon Sep 17 00:00:00 2001 From: Lukas Burk Date: Mon, 11 Nov 2024 14:55:18 +0100 Subject: [PATCH] update service files --- .gitignore | 6 ++++++ scripts/check_files_used.sh | 32 +++++++++++++++++++++++++++++++- scripts/update-service.sh | 0 slides/README.md | 12 +++++++++--- style/common.tex | 2 ++ style/lmu-lecture.sty | 3 +++ style/preamble.tex | 4 +++- style/preamble_ueb.Rnw | 7 +++++-- style/preamble_ueb_coll.Rnw | 7 +++++-- 9 files changed, 64 insertions(+), 9 deletions(-) mode change 100644 => 100755 scripts/update-service.sh diff --git a/.gitignore b/.gitignore index 2e0b2e5f..d6e067ba 100644 --- a/.gitignore +++ b/.gitignore @@ -11,12 +11,18 @@ nospeakermargin.tex speakermargin.tex +# latex-math subcomponents we don't need here +latex-math/latex-math.pdf +latex-math/latex-math.Rmd +latex-math/.github + #--------------------------------------------# # Intermediate output (slides, exercises) # #--------------------------------------------# # The only slide PDF output in this repo should be in slides-pdf # include both slides-xyz (i2ml) and slideXY- / tXY- (iml) formats +slides/*/*slides*.pdf slides/*/slides*.pdf slides/*/t*.pdf diff --git a/scripts/check_files_used.sh b/scripts/check_files_used.sh index 23c5840a..e65891d3 100644 --- a/scripts/check_files_used.sh +++ b/scripts/check_files_used.sh @@ -1,6 +1,18 @@ #!/bin/bash set -eo pipefail +# This script checks which files are present in a given folder that were not used by a given set of tex-files. +# It does this by relying on *.fls-files, that are generated when tex is run with the 'record' option. +# The Makefile should do this when 'make most' is run. +# +# When a tex-file imports another file (e.g. a figure), the generated fls-file contains a line 'IMPORT '. +# This script compares the files listed in the given fls-files with the files that are present in a given folder. +# ------ + +# parse the 2nd command line argument first: +# if it is 'used', we list all the files that are used by tex files +# if it is 'unused', we list all files that are not used by tex files +# if is is 'missing', we list all files that the tex file wants to use but did not find. case "$2" in "used") commarg=-12 @@ -13,14 +25,23 @@ case "$2" in ;; esac +# check command line arguments: +# $1 must be a directory +# $2 must have been parsed successfully above +# $3 must be given (as far as this check is concerned) if [ -z "$commarg" ] || [ ! -d "$1" ] || [ -z "$3" ] ; then echo "USAGE: $0 {used|unused|missing} file1.tex [file2.tex ...]" >&2 exit 1 fi +# normalize the path given to '$1' to be relative to the pwd folderpath="$(realpath --relative-to=. -- "$1")"/ +# drop the first two arguments: +# from here on, $1 will be the 3rd given argument, $2 will be the 4th given argument etc. shift 2 + +# check if the fls-file for each given tex-file is present. flsfiles=() for f in $@ ; do ff="${f%.tex}.fls" @@ -31,7 +52,16 @@ for f in $@ ; do flsfiles+=("$ff") done - +# here we use 'comm' to make a set-intersection: +# the options argument (commarg) tells us what we list: +# '-12' would be set intersection +# '-23' lists lines only in the content of 'FILE1' (i.e. files found in 'folderpath' but not in any fls-file +# '-13' lists lines only in the content of 'FILE2' +# 'FILE1' (1st non-option argument) is the content of 'folderpath', normalized to be relative to pwd +# 'FILE2' (2nd non-option argument) is each line of the fls-files that starts with 'INPUT ', with the 'INPUT ' part removed. +# +# The 'awk' makes sure we only print lines that start with the 'folderpath' part. +# It is equivalent to `grep '^$folderpath'`, except that 'folderpath' could also contain regex special chars, so grep would not work. comm $commarg \ <(find ./"$folderpath" -type f | xargs realpath --relative-to=. -- | sort -u ) \ <(perl -nle'print $& while m{(?<=^INPUT ).*}g' ${flsfiles[@]} | xargs realpath --relative-to=. -- | sort -u ) | \ diff --git a/scripts/update-service.sh b/scripts/update-service.sh old mode 100644 new mode 100755 diff --git a/slides/README.md b/slides/README.md index d5281cd9..2f832493 100644 --- a/slides/README.md +++ b/slides/README.md @@ -10,7 +10,7 @@ slides//.tex ``` -where `` starts with `slide-` or `slide01` +where `` starts with `slide-` or `slide01-` **Figures** are created either manually and live in @@ -18,14 +18,20 @@ where `` starts with `slide-` or `slide01` slides//figure_man/ ``` -or created with an R script, with the outputs located in +or created with an R script in ``` slides//rsrc/ +``` + +with the outputs located in + +``` slides//figure/ ``` -respectively. +The script filename should make it obvious which figure it creates, and similarly the filename of the figure should match the script. +The figures should be saved by the script (using e.g. `ggsave()`). ### Important files: diff --git a/style/common.tex b/style/common.tex index 8dbcd875..d4d63e5e 100644 --- a/style/common.tex +++ b/style/common.tex @@ -9,6 +9,8 @@ % Spacing helpers, used often (mostly in exercises for \dlz) \newcommand{\lz}{\vspace{0.5cm}} % vertical space (used often in slides) \newcommand{\dlz}{\vspace{1cm}} % double vertical space (used often in exercises, never in slides) +\newcommand{\oneliner}[1] % Oneliner for important statements, used e.g. in iml, algods +{\begin{block}{}\begin{center}\begin{Large}#1\end{Large}\end{center}\end{block}} % Don't know if this is used or needed, remove? % textcolor that works in mathmode diff --git a/style/lmu-lecture.sty b/style/lmu-lecture.sty index 490d3395..8fe97eab 100644 --- a/style/lmu-lecture.sty +++ b/style/lmu-lecture.sty @@ -367,6 +367,9 @@ %-------------------------------------------------------------------% % Frame with breaks and verbatim // this is used very often +% Should not use 'containsverbatim', see https://tex.stackexchange.com/questions/69191/can-a-beamer-frame-have-both-containsverbatim-and-hidden-shown-block-options +% Should use 'fragile' instead, but everything breaks if fragile is used all the time +% See https://tug.ctan.org/macros/latex/contrib/beamer/doc/beameruserguide.pdf for details \newenvironment{vbframe} { \begin{frame}[containsverbatim,allowframebreaks] diff --git a/style/preamble.tex b/style/preamble.tex index cd8e5a98..be6b52e9 100644 --- a/style/preamble.tex +++ b/style/preamble.tex @@ -44,7 +44,7 @@ % \usepackage{bbm} % bm – Access bold symbols in maths mode - https://ctan.org/pkg/bm -% Required for latex-math +% Required for latex-math, preferred over \boldsymbol % https://tex.stackexchange.com/questions/3238/bm-package-versus-boldsymbol \usepackage{bm} @@ -92,6 +92,8 @@ % Note this requires biber to be in $PATH when running, % telltale error in log would be e.g. Package biblatex Info: ... file 'authoryear.dbx' not found % aside from obvious "biber: command not found" or similar. +% Tried moving this to lmu-lecture.sty but had issues I didn't quite understood, +% so it's here for now. \usepackage{textcase} % for \NoCaseChange \usepackage{hyperref} diff --git a/style/preamble_ueb.Rnw b/style/preamble_ueb.Rnw index 55d89c20..65db742e 100644 --- a/style/preamble_ueb.Rnw +++ b/style/preamble_ueb.Rnw @@ -24,6 +24,11 @@ \usepackage{algorithm} \usepackage{algpseudocode} + +\input{../../style/common} + +% Include latex-math here once such that it does not need to be included in each exercise +% which may fail as it needs to be included as part of the preamble \input{../../latex-math/basic-math.tex} \input{../../latex-math/basic-ml.tex} \input{../../latex-math/ml-ensembles.tex} @@ -31,8 +36,6 @@ \input{../../latex-math/ml-svm.tex} \input{../../latex-math/ml-gp.tex} -\input{../../style/common} - \tcbset{enhanced} \DeclareRobustCommand{\mybox}[2][gray!20]{% diff --git a/style/preamble_ueb_coll.Rnw b/style/preamble_ueb_coll.Rnw index 6bdca88e..46c0fdf5 100644 --- a/style/preamble_ueb_coll.Rnw +++ b/style/preamble_ueb_coll.Rnw @@ -23,6 +23,10 @@ \usepackage{cancel} \usepackage{bm} +\input{../../style/common} + +% Include latex-math here once such that it does not need to be included in each exercise +% which may fail as it needs to be included as part of the preamble \input{../../latex-math/basic-math.tex} \input{../../latex-math/basic-ml.tex} \input{../../latex-math/ml-ensembles.tex} @@ -30,7 +34,6 @@ \input{../../latex-math/ml-svm.tex} \input{../../latex-math/ml-gp.tex} -\input{../../style/common} \tcbset{enhanced} @@ -95,4 +98,4 @@ \begin{document} \SweaveOpts{concordance=TRUE} -\end{document} \ No newline at end of file +\end{document}