# Can latexmk be told to ignore specific intermediate files completely?

One latex run suffices to generate the DVI/PDF version of the LaTeX document

\documentclass{article}

\usepackage{comment}

\includecomment{comment}

\begin{document}

\begin{comment}
\noindent
Test
\end{comment}

\end{document}


By contrast, latexmk thinks that two latex runs are necessary. The reason for this is the following: Since comments are to be included the comment environment writes its content to an intermediate file (by default comment.cut). Latexmk treats comment.cut similar to other intermediate files (such as the toc and lof files) and thus provides for another latex run. What latexmk misses is that comment.cut is input right at the end of the comment environment and that it’s useless afterwards. Hence, the second latex run is superfluous.

Does anybody know whether it’s possible to configure latexmk such that it completely ignores specific intermediate files?

-
Maybe it would make sense to submit this is as a bug report to the latexmk developers? –  N.N. Jan 11 '12 at 7:42
@N.N.: If nobody suggests a reasonable workaround by means of customization I’ll do so. Possibly, similar issues arise with packages other than the comment package. –  mhp Jan 11 '12 at 9:22
I just meant that if this is non-intended or problematic behavior of latexmk it would make sense to let the developers know. –  N.N. Jan 11 '12 at 9:27
Have you tried to run latexmk with the -diagnostics option to better understand its behavior? It is described as follows in the manual: "Print detailed diagnostics during a run. This may help for debugging problems or to understand latexmk's behavior in difficult situations." –  N.N. Jan 11 '12 at 9:31
@N.N.: comment.cut is correctly detected as dependent file since it’s written by (pdf)latex. But, probably, it should not be treated as a source file. Then, the (pdf)latex rule might not consider it a prerequisite. –  mhp Jan 11 '12 at 11:05

@mhp: Your diagnosis is correct. comment.cut is detected as a dependent file, and latexmk does a rerun of the (pdf)latex rule when it sees that a dependent file has changed. It makes no attempt to determine whether the change has an actual effect on the output.
With current implementations of tex, the recorder option is available, and can be used by latexmk. There is then sufficient information to determine whether a file is read only after it has been written in the same run. It would be a useful optimization for latexmk to detect this situation, and deal with it. I'll add it to the list of improvements.