File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,3 +20,6 @@ title.pdf
2020.vscode /
2121.DS_Store
2222* .dSYM
23+ _minted /
24+ * synctex.gz
25+ * .bak *
Original file line number Diff line number Diff line change @@ -69,4 +69,8 @@ zip: dir
6969 @zip -r vorkurs.zip vorkurs vorkurs.pdf
7070 @echo " Zip-File erstellt. Fertig zum hochladen."
7171
72+ format :
73+ @echo " Formatieren des LaTeX-Projekts…"
74+ @bash scripts/format_latex.sh
75+ @echo " Fertig."
7276
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -e
3+
4+ echo " === LaTeX Auto-Formatter ==="
5+
6+ if ! command -v latexindent & > /dev/null; then
7+ echo " latexindent.pl not found. Please install TeX Live or MacTeX."
8+ exit 1
9+ fi
10+
11+ missing_modules=()
12+ for module in YAML::Tiny File::HomeDir Unicode::GCString File::Find::Rule; do
13+ perl -M$module -e1 2> /dev/null || missing_modules+=($module )
14+ done
15+
16+ if [ ${# missing_modules[@]} -ne 0 ]; then
17+ echo " The following Perl modules are missing:"
18+ for module in " ${missing_modules[@]} " ; do
19+ echo " - $module "
20+ done
21+ echo " "
22+ echo " Options:"
23+ echo " [i] Install missing modules automatically (requires cpan, may need sudo)"
24+ echo " [s] Skip installation and try formatting anyway"
25+ echo " [a] Abort"
26+ read -p " What do you want to do? [i/s/a]: " choice
27+ case " $choice " in
28+ i | I)
29+ for module in " ${missing_modules[@]} " ; do
30+ echo " Installing $module with cpan..."
31+ if ! cpan -i $module ; then
32+ echo " Permission denied or install failed. Retrying with sudo..."
33+ sudo cpan -i $module
34+ fi
35+ done
36+ ;;
37+ s | S)
38+ echo " Skipping installation. Formatting may fail."
39+ ;;
40+ * )
41+ echo " Aborted."
42+ exit 1
43+ ;;
44+ esac
45+ else
46+ echo " All required Perl modules are installed."
47+ fi
48+
49+ echo " Formatting all .tex files..."
50+ find . -name " *.tex" -exec latexindent -w {} \;
51+ echo " Done! All LaTeX files have been formatted."
52+
53+ echo " Cleaning up backup files..."
54+ find . -type f -name " *.bak*" -exec rm -v {} \;
55+ echo " Cleanup complete."
You can’t perform that action at this time.
0 commit comments