deleting auto-generated files, iff pdf was successfully rendered
This commit is contained in:
@@ -19,6 +19,9 @@ FILE="$1"
|
|||||||
# append .tex file extension, iff not already passed
|
# append .tex file extension, iff not already passed
|
||||||
[[ "$FILE" != *.tex ]] && FILE="${FILE}.tex"
|
[[ "$FILE" != *.tex ]] && FILE="${FILE}.tex"
|
||||||
|
|
||||||
|
# remove the .tex extension from the file name to get the base name
|
||||||
|
BASE="${FILE%.tex}"
|
||||||
|
|
||||||
# Check that the file exists
|
# Check that the file exists
|
||||||
if [[ ! -f "$FILE" ]]; then
|
if [[ ! -f "$FILE" ]]; then
|
||||||
echo -e "${BOLD}${RED}Error${RESET}${RED}: File '$FILE' not found.${RESET}"
|
echo -e "${BOLD}${RED}Error${RESET}${RED}: File '$FILE' not found.${RESET}"
|
||||||
@@ -28,8 +31,24 @@ fi
|
|||||||
# Detect active \usepackage{fontspec} (ignore commented lines)
|
# Detect active \usepackage{fontspec} (ignore commented lines)
|
||||||
if grep -Eq '^[^%]*\\usepackage\{fontspec\}' "$FILE"; then
|
if grep -Eq '^[^%]*\\usepackage\{fontspec\}' "$FILE"; then
|
||||||
echo -e "${BLUE}Detected fontspec → Using XeLaTeX${RESET}"
|
echo -e "${BLUE}Detected fontspec → Using XeLaTeX${RESET}"
|
||||||
xelatex -synctex=1 -interaction=nonstopmode -file-line-error "$FILE"
|
LATEX_CMD=(xelatex -synctex=1 -interaction=nonstopmode -file-line-error "$FILE")
|
||||||
else
|
else
|
||||||
echo -e "${BLUE}No active fontspec → Using pdfLaTeX${RESET}"
|
echo -e "${BLUE}No active fontspec → Using pdfLaTeX${RESET}"
|
||||||
pdflatex -synctex=1 -interaction=nonstopmode -file-line-error "$FILE"
|
LATEX_CMD=(pdflatex -synctex=1 -interaction=nonstopmode -file-line-error "$FILE")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
"${LATEX_CMD[@]}"
|
||||||
|
|
||||||
|
rm -f \
|
||||||
|
"${BASE}.aux" \
|
||||||
|
"${BASE}.bbl" \
|
||||||
|
"${BASE}.bcf" \
|
||||||
|
"${BASE}.blg" \
|
||||||
|
"${BASE}.fdb_latexmk" \
|
||||||
|
"${BASE}.fls" \
|
||||||
|
"${BASE}.log" \
|
||||||
|
"${BASE}.out" \
|
||||||
|
"${BASE}.run.xml" \
|
||||||
|
"${BASE}.synctex.gz" \
|
||||||
|
"${BASE}.toc" \
|
||||||
|
"${BASE}.xdv"
|
||||||
|
|||||||
Reference in New Issue
Block a user