Is this a bug in latexmk, or perhaps the standalone package, or is it expected behaviour?
If I start with a file containing an error such as too many closing } characters, and compile my latex file using
latexmk --pdf mwe.ltx
then it reports the error correctly. However, when I fix the error, and recompile using the same command, I still get an error such as the following, even though the latex file is correct.
(./mwe.sta)
! Extra }, or forgotten \endgroup.
l.555 }
%
Here is the MWE; I named it mwe.ltx
\documentclass{article}
\usepackage[subpreambles=true]{standalone}
\begin{document}
test
} %% this is an error, and will correctly cause compilation to fail, but remove it and compilation still fails until you remove the mwe.st
\end{document}
To reproduce the error,
1) compile the file with latexmk --pdf mwe.ltx
2) after it reports an error, fix it by removing the extraneous } character
3) recompile the file with the same latexmk command line.
latexmkit also happens with standard pdflatex. The generated.stafile still contains the bad}and needs to be manually removed. It seems to be missing\endstandalonepreambles– daleif Jan 31 '20 at 10:51xto stop the compilation, then\endstandalonepreamblesis never written to the.stafile and you get problems when the.stais read next time. I tend to use-halt-on-errorwithlatexmkbut that is the same as pressingxthus the writing of the end part is never finished. – daleif Jan 31 '20 at 10:55Simply removing the .sta file is not so easy when make is being called in a sequence of makefiles. I.e., how to know which .sta files to remove and which ones to leave in place?
I wonder whether it would be possible in the makefile to detect the exit code of latexmk and remove the specific .sta, without removing all of them?
– Jim Newton Jan 31 '20 at 13:53.staextension so I'm not surelatexmk -cwill remove the.stafile. You can probably code some custom dependency for.stafiles, though not sure if it is worth it. – daleif Jan 31 '20 at 13:55latexmk -c file.texa bit more. Have a collegue who wanted to delete some log files and wroterm *;lognote the;, so he just deleted everything in this folder. He should have usedlatexmk -c *.tex– daleif Jan 31 '20 at 14:23latexmk -c file.texwill delete auto generated files except.pdf,.bbletc. Is this one long files, or are files split into say separate files (for each chapter). Then changing chap4 does not touch the master file, and without the aux files to know which docs are a part of the project, latexmk does not know what it should recompile. – daleif Jan 31 '20 at 14:27latexmk -corlatexmk -Cto delete the .sta file, put$clean_ext .= ' sta';in a latexmkrc file. (b) You can also set$cleanup_includes_generatedto 1 (see the latexmk documentation), but that is rather dangerous. (c) If your Makefile calls latexmk on a single source file, surely it is possible to arrange the Makefile so that it deletes just the one top level .sta file. If all else fails, write a little script to call latexmk and do the deletion when needed; then use your script instead of latexmk. – John Collins Feb 02 '20 at 16:52$pdflatex = 'pdflatex %O %S|| (echo === Deleting %Y%R.sta ...; rm -v %Y%R.sta; false)';in a latexmkrc file. That will delete the .sta file if pdflatex gives an error, and report an error back to latexmk. This definition should work on unix-like systems including linux (it was tested on macOS). – John Collins Feb 02 '20 at 17:19