This commit is contained in:
Adrian Amaglio 2022-02-14 08:17:39 +01:00
parent b878661252
commit 9d34ea87cd

40
mktex Executable file
View File

@ -0,0 +1,40 @@
#!/bin/sh
# Author: Romain Deville (ty <3)
# Generate latex file two times to get page numbering and glossary right
if [[ $# -eq 1 ]] && ! [[ $1 == 'bib' ]]
then
if [[ $1 == 'clean' ]]
then
bash -c "rm -f *.aux *.bbl *.blg *.log *.out *.idx *.ilg *.ind *.toc *.fls *.fdb_latexmk
*synctex.gz *.d"
elif [[ $1 == 'veryclean' ]]
then
bash -c "rm -f *.aux *.bbl *.blg *.log *.out *.idx *.ilg *.ind *.toc *.fls *.fdb_latexmk
*synctex.gz *.d *.pdf"
fi
else
grep -lFm 1 'begin{document}' *.tex | while read f ; do
pdflatex_cmd="pdflatex -file-line-error -halt-on-error '$f'"
latex_file_without_ext="${f:0:-4}"
bash -c "$pdflatex_cmd" 2>/dev/null
[[ $? -eq 1 ]] && read
# Generate glossary
if [ -n "$(grep -E '\\usepackage.*{glossaries}' "$f") " ] ; then
makeglossaries "$latex_file_without_ext"
[[ $? -eq 1 ]] && read
fi
# Generate bib
if [ -n "$(grep -E '^[[:space:]]*\\bibliograph[yi]' "$f")" ] ; then
bibtex ${f%%.tex*}.aux
[[ $? -eq 1 ]] && read
fi
# get all right
bash -c "$pdflatex_cmd" 2>/dev/null
[[ $? -eq 1 ]] && read
"$pdflatex_cmd" 2>/dev/null
[[ $? -eq 1 ]] && read
done
fi