41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/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
 |