Skip to content

Commit e848c28

Browse files
committed
Update .gitignore and add LaTeX formatting script
1 parent 37b0892 commit e848c28

3 files changed

Lines changed: 62 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ title.pdf
2020
.vscode/
2121
.DS_Store
2222
*.dSYM
23+
_minted/
24+
*synctex.gz
25+
*.bak*

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

scripts/format_latex.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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."

0 commit comments

Comments
 (0)