Monday, May 20, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 2726  / 2 Years ago, tue, september 20, 2022, 12:06:31

I have a few tens of .tex files in a directory.



How can I compile them all with a single command from the terminal?



Moreover: is it possible to avoid all the files that are generated by the compiler (.bak, .log, .aux, .out, .bib files)?



I usually compile with pdflatex file.tex.


More From » command-line

 Answers
7

You can do it with for command



for f in *.tex; do pdflatex $f; done


I find this syntax easier to remember than find.



Regarding deleting auxiliary files consider using latexmk -c -pdf or latexmk -C -pdf instead of pdflatex. latexmk is latex make, which builds only the files that need to be built. I am not sure, which auxiliary files get deleted exactly, but I think most of them will be deleted with -c or -C switch.



for f in *.tex; do latexmk -C -pdf $f; done


According to manual it should also work like this



latexmk -C -pdf *.tex


Another option would be to delete files manually after the processing is done. That would be accomplished like this:



for f in *.tex; do pdflatex $f; done; rm *.bak *.log *.aux *.out *.bib


I am not sure if this still qualifies for a oneliner.


[#4919] Tuesday, September 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zzlingots

Total Points: 414
Total Questions: 130
Total Answers: 117

Location: Sudan
Member since Tue, Sep 15, 2020
4 Years ago
;