1

I am running latexmk in a silent and preview continuous mode.

latexmk -pdf -silent -pvc myfile.tex

However when I look at the terminal (which has brief log output), then I have no way to figure out the time(s) at which the file was compiled. In other words I would like a line

last compiled at Wed Sep 26 21:18:53 IST 2018

This is useful for me to trace the working version (in case of errors) from the backup sets.

I can write a small bash script, which will watch the file for update and then call pdflatex in batchmode and then print output with date. (Grep for errors/warning in the aux/log and print message accordingly.) However isnt it nothing but duplicating the latexmk?

-- Mike

  • Is the time stamp of the last compilation enough? You could retrieve this from the first line of the .log file. – user36296 Sep 26 '18 at 16:21
  • I want it printed along with the other output of latexmk. – Mike V.D.C. Sep 26 '18 at 16:50
  • Send a feature request to the maintainer – daleif Sep 26 '18 at 17:27
2

First failed attempt:

In ~/.latexmkrc file:

$latex = "date;latex --src-specials";

Doesnt work :-


Second failed attempt (I am giving it here, as this may give an idea of simpler / alternate solution to someone!)

latexmk -silent -pvc -e 'print "Last compiled at: ".localtime()."\n";' myfile.tex

From the manpage:

  -e <code>
          Execute the specified initialization code before processing.  
          The code is Perl code of the same form as is  used  in  latexmk's
          initialization files.  For more details, see the information on the 
          -r option, and the section about "Configuration/initialization (RC)
          files".  The code is typically a sequence of assignment statements
          separated by semicolons.

However this prints the required string only at the beginning. I believe that by modifying certain variables, like $latex, one can achieve what is needed.


The following is a complete working solution. The only catch is it needs root permission (or make a local copy the script).

Insert the following code in the latexmk script:

$datestring = localtime();
print "Last compiled at: $datestring\n";

These lines to be included in the function which actually calls $latex:

sub rdb_primary_run
2

Actually, you don't have to modify latexmk to get this effect, but just configure it. The following in a latexmkrc file will do the job

$pdflatex = 'internal mylatex pdflatex %O %S';
sub mylatex {
   my $ret = system @_;
   print "Last compilation at ", scalar(localtime()), "\n";
   return $ret;
}

You can make similar definitions for the $latex, $lualatex and $xelatex variables.

  • As this looks more like a system programming (or is it perl?), can you please care to explain the code or give some poiinters? – Mike V.D.C. Sep 29 '18 at 17:11
  • See the latexmk documentation, in particular the sections on configuration, on how to set variables in initialization files, and on the format of command specifications. The language is indeed Perl. – John Collins Oct 3 '18 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.