I want to have a main document which inputs files whenever they are present, like this:
\documentclass{article}
\begin{document}
Before.
\IfFileExists{bli.tex}{\input{bli.tex}}{\typeout{No file bli.tex.}}
After.
\end{document}
and compile it with latexmk. If bli.tex exists, everything works as expected, changing bli.tex forces recompilation, all is well.
My issue is when I first run latexmk with no file bli.tex present, and then create bli.tex: a subsequent call to latexmk does nothing. I believe I can understand why this would be the case, as the use of bli.tex is not recorded when it is absent (even though there is an error message about a missing input file).
How can I set things up so that latexmk sees such file creations as triggers for recompilation?
I found the question latexmk with external references about a similar issue, with an answer with suggestions, but none of them seems to help me.
\InputIfFileExistswhich has some mild optimisations over\IfFileExists ... \inputyou could make the missing file an error then latexmk would always run unless it was there. – David Carlisle Apr 08 '21 at 23:06-gto force it to re-run, but I'm not sure you would count that as an answer – David Carlisle Apr 08 '21 at 23:11\InputIfFileExistsis an alternative, but it has the same behavior as far as latexmk is concerned (i.e., no recompilation when I would want it). – Vincent Beffara Apr 08 '21 at 23:11-gis not optimal since figuring out when to use it would amount to reinventing part of latexmk to begin with :-) I guess I could always runlatexmk -gwhatever happens, but it does feel sub-optimal – Vincent Beffara Apr 08 '21 at 23:14