Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a source file called 2011-05-27_Myfilename.tex and I'd like to create a PDF file from it called only Myfilename.pdf.

Can this be configured from within the .tex file itself?

(It seems to be possible with

pdflatex -jobname=Myfilename.tex 2011-05-27_Myfilename.tex

However, as many different files are concerned, It would be easier to have an option like output=Myfilename in the LaTeX source code.)

share|improve this question
I'm used to making Makefile scripts to generate my PDFs. If that is your case, too, it's easy to enough to either rename the .tex or the .pdf in the process. –  ℝaphink May 27 '11 at 7:23
@Raphink: Thanks, that Makefile approach sounds like a good workaround, however I did not use it yet. As I'm using GUI editors it is quite easy to use the keyboard shortcut to run pdflatex. –  Martin May 27 '11 at 7:28

3 Answers 3

up vote 18 down vote accepted

I'm afraid you cannot alter the output name from within the LaTeX source: the \jobname primitive can be read but not altered. You can arrange two-file solutions which allow one LaTeX file to 'call' another, but I am not sure that will answer your problem here.

share|improve this answer
Just found this question and I have one more remark: obviously, you can do \def\jobname{whatever}, and if you do it early enough, it will affect the names of the .aux, .toc etc. files - but not the pdf. –  mbork Jul 31 '11 at 20:40

You can specify additional parameters (like jobname) at the very beginning of your main file (even before \documentclass):

%& -job-name=newfilenameialwayswanted

It slightly depends on your compiler but it should work.

An additional comment: If you use an IDE, this may cause troubles for file opening hotkeys (the file they will try to open will not be there), in this case, you can look for an option like "output profile" (TeXnicCenter name) - you can also change the filename this way.

So there're no totally convenient ways to change your output filename from source, but it is possible.

share|improve this answer

You can do as follows.

Hello World

\foreach \outputfilename in {a,b,c}{\immediate\write18{pdflatex -jobname=\outputfilename\space template}}
The files we created automatically are:

\foreach \outputfilename in {a,b,c}{\fbox{\includegraphics[scale=2]{\outputfilename}}\endgraf}

enter image description here

share|improve this answer
I knew about that, but I was a bit afraid of package collisions. Altough, it's a good answer (+1). –  masu Oct 21 '13 at 22:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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