1

Currently when I generate a PDF file of my document, it produces the name

document1.pdf

I'd like to set it so that it adds the current date (or the date produced by \date{\today}), such as

document1_March_15_2019.pdf

or however it may produce the date. Is there a method to do that? The closest I found was this link but I'm not using an emac or pdftex, I think. I am using TexMaker on a Mac OS Mojave.

  • The command \date{\today} is a LaTeX command that will get its value during compilation from the TeX distro (for example TeX Live or MacTeX) that your TeXmaker is using. So, TeXmaker will never see this output of this command but will just let it printed in your pdf document via your TeX distro. So, try to find out if texmaker have available in a variable the current date and add this variable before the .pdf extension in your TeXmaker options at the output filename. – koleygr Mar 15 at 16:35
  • the pdf is made by latex (not texmaker) and is just the filename of your source file with .tex changed to .pdf so if you save the file as hs-nebula.tex then the generated file will be hs-nebula.pdf document1 is presumably just a default file name if you start a blank file without saving it to a specific name (although I don't use texmaker to be sure) – David Carlisle Mar 15 at 16:35
5

For editors that execute commands in a bash-based shell, you can modify the preferences of your editor to compile with

mydate=$(date +'%B_%d_%Y') ; pdflatex --jobname="document1_$mydate" %.tex

This will generate a pdf called document1_March_15_2019.pdf

  • 1
    Nice (+1)... I suggest an edit to remove the TeXmaker tag and the TeXmaker from the title to make the question/answer just specific to the OS (Linux/Mac) and not to the editor – koleygr Mar 15 at 16:43
  • @koleygr Feel free to edit – user36296 Mar 15 at 16:47
  • Just to clarify, do I add this to the PdfLaTeX box in texmaker >> Preferences or is this a user command? – HS-nebula Mar 15 at 16:50
  • Was commenting to ask the OP... but he did it before my question... – koleygr Mar 15 at 16:51
  • @HS-nebula You can do it either way. If you want to compile all your documents like this, you could directly modify the pdflatex preferences, if you only want to use it occasionally, a separate command might be better. – user36296 Mar 15 at 16:52

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.