pdflatex command allows to specify an output name through --job-name= option. But can't insert the date and time automatically.

Emacs could do it:

(compile-command "pdflatex --job-name=myoutputname.pdf myfile.tex")

How can the compile-command be modified to automatically add the date and time in the output name?

  • It works perfectly though, but doesn't allow to insert the date automatically... Maybe the post should be in Emacs forum rather ? (Many thanks anyway !)
    – thomasb
    Sep 1, 2017 at 11:42
  • Yes, it was not supposed to work perfectly. It was just a pointer. I faced this issue before where I had to control the .pdf output name of around 4000 files (to be auto compiled by a script). Finding no other alternative, I generated each of 4000 plus .tex file in runtime (using LaTeX :-)) and then generated the .pdf's. And you are welcome.
    – Masroor
    Sep 1, 2017 at 13:05

1 Answer 1


Presumably you can replace

"pdflatex --job-name=myoutputname.pdf myfile.tex"


(concat "pdflatex --job-name=myoutputname-"
    (format-time-string "%Y-%m-%d")
     ".pdf myfile.tex")

which produces

"pdflatex --job-name=myoutputname-2017-09-01.pdf myfile.tex"
  • oh I just noticed you wanted time as well, but you can add more % fields to the format string:-) Sep 1, 2017 at 12:26
  • Yep, precisely : "%Y-%m-%d@%H-%M-%S" ;-p
    – thomasb
    Sep 1, 2017 at 16:36
  • Actually, I even wrote : (concat "pdflatex --job-name=" (format-time-string "myoutputname-%Y-%m-%d@%H-%M-%S") ".pdf myfile.tex"), for newbies too...
    – thomasb
    Sep 1, 2017 at 16:38
  • please for newbies, what do I have to write? writing "pdflatex --job-name=myoutputname.pdf myfile.tex" in my command works, but was does the concat mean?
    – acep
    Oct 7, 2017 at 19:38
  • 1
    @acep concat is the emacs lisp function to concatenate (join together) strings. Oct 7, 2017 at 19:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .