After inspecting this question and the unaccepted answer, I tried to test it. First I tested the recommended command with:
fswatch -o report.tex | xargs -n1 -I{} pdflatex report.tex
Which led to an infinite compilation loop, which I consider slightly inefficient, and furthermore, it does not create a long enough window-of-opportunity in which the PDF is accessible. So I tried to debug why fswatch yields an infinite compilation loop using a ctrl+s command in TexMaker in the report.tex file:
fswatch -o report.tex | xargs -n1 -I{} echo "hello world"
hello world
hello world
There I observed the ctrl+s/saving of the report.tex triggers two detected changes by fswatch. Furthermore, I tested it on a f6 command in TexMaker, as well as on the pdflatex report.tex command, and observed fswatch detected 3 changes for both attempts:
fswatch -o report.tex | xargs -n1 -I{} echo "hello world"
hello world
hello world
hello world
The latter seems to be sufficient to cause the infinite compilation loop. Hence, I would like to ask, how can I ensure the report.tex is compiled once when a change is saved to it from TexMaker?
I think subquestions that may lead to a working answer may be as listed below, yet I did not find a satisfying answer to these:
- Does for example the fswatch have an argument to ignore changes for
n-milisecondsor for the nextn-changes? It appears to me that section3.2.3 Numeric Event Flagsof thefswatchdocumentation seems to allow for only using then-thevent flag. Yet I did not yet successfully implement passing such an argument to inhibit compilation. - Or are there arguments I could pass to the
pdflatexreport to reduce the three detected changes upon compilation to thereport.texto zero changes? - Does TexMaker have an option to reduce the amount of changes to the
report.texfrom two to one upon saving withctrl+s?
.texand.pngfiles:inotifywait -m -e CLOSE_WRITE report.tex \ Chapters/* \ Appendices/* \ Images/* \ | xargs -n1 -I{} ./compile_script.shwhere every\\is followed by a new line. – a.t. May 16 '21 at 12:56