I have this MWE (test.tex):
\documentclass[11pt]{article}
\begin{document}
Text.\footnote{Footnote text.}
\end{document}
I want to compile it this way:
pdflatex -draftmode \
-output-directory=/tmp \
-jobname=footnotecheck \
'\AtBeginDocument{\newcounter{MyFootnote} \NewCommandCopy\MyOldFootnote\footnote \renewcommand{\footnote}[1]{\stepcounter{MyFootnote}\label{FootnoteMark\arabic{MyFootnote}}\MyOldFootnote{\label{FootnoteText\arabic{MyFootnote}}#1}}} \input{test}'
In this way I have this kind of strings in the .aux file (https://tex.stackexchange.com/a/381667/33634):
\newlabel{FootnoteMark1}{{}{1}{}{}{}}
\newlabel{FootnoteText1}{{1}{1}{}{}{}}
I use draftmode because I don't want/need a .pdf file to be produced (and it works).
Now I need to run the command the appropriate number of times. Ho can I prepare a .latexmkrc file for this command? I tryed:
$pdflatex = 'pdflatex -draftmode %O %S \
"\AtBeginDocument{\newcounter{MyFootnote} \let\MyOldFootnote\footnote \renewcommand{\footnote}[1]{\stepcounter{MyFootnote}\label{FootnoteMark\arabic{MyFootnote}}\MyOldFootnote{\label{FootnoteText\arabic{MyFootnote}}#1}}}" \
\input %S';
$out_dir = '/tmp';
$jobname = 'footnotecheck';
and the command:
latexmk -pdf test.tex
It works for $out_dir and $jobname but it doesn't redefine the \footnote command, and gives me the warning:
Failure to make 'footnotecheck.pdf'
Latexmk: Errors, so I did not complete making targets
Collected error summary (may duplicate other messages):
pdflatex: failed to create output file
Latexmk: If appropriate, the -f option can be used to get latexmk
to try to force complete processing.
$pdflatex: 1. You've got %S; that gets substituted by the source filename, so the command line isn't the one you are expecting: So remove that first %S. 2. Using-draftmodeimplies that no pdf file is created, and latexmk treats that as an error; puttouch %D;at the front of the command line to solve that problem. – John Collins Nov 16 '23 at 19:15$pdflatex: Look at earlier parts of the output from latexmk where it reports the command line(s) it actually passed to the command shell. That way you can check whether it actually matches what you intended. – John Collins Nov 16 '23 at 19:31