I'm using texmaker and PdfLaTeX. With the exception of changing the .tex filename, does anyone know how to modify the output file name based on a parameter?

I am aware that the following line...

%& -job-name=XYZ

if placed at the beginning of the document would be parsed as an additional parameter. In the above case this would instruct the generation of XYZ.pdf when typeset, therefore:

%& -job-name=XYZ_26Dec2012

would accordingly produce XYZ_26Dec2012.pdf

How can I get the 26Dec2012 to change based on the actual date (automatically), therefore keeping a chronology of working documents as they change over time?

  • 3
    A 'pure' solution is not possible, unless you are able to extend your engine to interpret special characters in the job-name. Without that support, one would need to execute some *TeX code first and then set the job-name. This is not possible, as discussed in How to influence the name of the pdf file created with pdfLaTeX (from within the source code)?. Hence, the remaining solutions involve writing a script to invoke the engine with an appropriate job-name, copying the file after compilation, or configuring the editor somehow to do one of these things. Dec 26, 2012 at 13:11
  • I suspected as much. After posting the above, I found some Python scripts somewhere that pretty much did that. Cant be arsed, too much effort for a bees-d*ck of a benefit.... Dec 26, 2012 at 13:15
  • 4
    You could also use some VCS (e.g. Git), in which you commit both source and PDF file, so that you can go back to meaningful point (these tend not to coincide with date changes).
    – You
    Dec 26, 2012 at 14:02
  • I'd also recommend a VCS for a history. If you don't want this, you can extend your "Quick Build" command with a script, that copies XYZ.pdf to XYZ_26Dec2012.pdf. Mar 17, 2013 at 23:47
  • Would you consider using arara in Texmaker to build your documents?
    – StrongBad
    May 24, 2013 at 16:58

1 Answer 1


If you use a unix system where the date command is available, you could replace



XYZ_$(date +"%d%b%Y")

as the -jobname value, either in your first line at the beginning of your document (untested, I don't use texmaker) or in your compile command (tested).

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.