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-miliseconds
or for the nextn-changes
? It appears to me that section3.2.3 Numeric Event Flags
of thefswatch
documentation seems to allow for only using then-th
event flag. Yet I did not yet successfully implement passing such an argument to inhibit compilation. - Or are there arguments I could pass to the
pdflatex
report to reduce the three detected changes upon compilation to thereport.tex
to zero changes? - Does TexMaker have an option to reduce the amount of changes to the
report.tex
from two to one upon saving withctrl+s
?
.tex
and.png
files:inotifywait -m -e CLOSE_WRITE report.tex \ Chapters/* \ Appendices/* \ Images/* \ | xargs -n1 -I{} ./compile_script.sh
where every\\
is followed by a new line. – a.t. May 16 '21 at 12:56