From 9d34ea87cdae2632cae397d8260fa5c8d21fb681 Mon Sep 17 00:00:00 2001 From: Adrian Amaglio Date: Mon, 14 Feb 2022 08:17:39 +0100 Subject: [PATCH] mktex --- mktex | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 mktex diff --git a/mktex b/mktex new file mode 100755 index 0000000..61d8e92 --- /dev/null +++ b/mktex @@ -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