Created
January 12, 2025 17:49
-
-
Save jackfromeast/a2d6c9bf7b0d82362f976f087de539a8 to your computer and use it in GitHub Desktop.
latexdiff for multi-files latex project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! Need to install inkscape to automatically convert svg to pdf. | |
| #!/bin/bash | |
| if [ "$#" -ne 2 ]; then | |
| echo "Usage: $0 <submission-version-folder> <latest-version-folder>" | |
| exit 1 | |
| fi | |
| SUBMISSION_FOLDER="$1" | |
| LATEST_FOLDER="$2" | |
| OUTPUT_DIFF="diff.tex" | |
| if [ ! -d "$SUBMISSION_FOLDER" ] || [ ! -d "$LATEST_FOLDER" ]; then | |
| echo "Error: One or both directories do not exist." | |
| exit 1 | |
| fi | |
| compile_latex() { | |
| local folder="$1" | |
| echo "Compiling LaTeX files in folder: $folder" | |
| cd "$folder" || exit | |
| pdflatex --shell-escape main.tex | |
| bibtex main | |
| pdflatex --shell-escape main.tex | |
| pdflatex --shell-escape main.tex | |
| cd - > /dev/null || exit | |
| } | |
| compile_latex "$SUBMISSION_FOLDER" | |
| compile_latex "$LATEST_FOLDER" | |
| echo "Generating the diff file..." | |
| latexdiff --config="PICTUREENV=(?:tabular)[\w\d*@]*" --flatten "$SUBMISSION_FOLDER/main.tex" "$LATEST_FOLDER/main.tex" > "$OUTPUT_DIFF" | |
| echo "Diff file generated: $OUTPUT_DIFF" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment