[Tex/LaTex] Defining the pdf output file within the document file using %& -job-name

jobnamepdftex

My understanding is that if I create a file called noName.tex with the first line

%& -jobname=myName

then when I run pdflatex on that file, the output file will be named myName.pdf rather than noName.pdf, just as if I'd typed

pdflatex -jobname=myName noName.tex

But in the following example, the first line is ignored by pdflatex, and the output is named noName.pdf.

Here is noName.tex:

%& -job-name=myName
\documentclass{minimal}
\begin{document}
Hello World
\end{document}

Could somebody advise what the correct syntax would be please? Thanks very much.

The version of pdflatex I'm using is:

This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian) (format=pdflatex 2014.6.25)

Best Answer

The %& magic line has been supported by implementations of TeX from many years. However, the feature is implemented differently in the various TeX distributions.

Note that no editor/front-end I know of interprets such a line: this is specific for the TeX engine.

In TeX Live, the line can contain only the specification of a format to be loaded and a TCX file, see section 3.5.2.2 in the documentation of Web2c (texdoc web2c, page 11 for TeX Live 2015):

%&format -translate-file=tcxfile

Either part can be empty. Note that, in TeX Live, Knuth TeX doesn't honor this magic line.

As far as I know, other command line options such as -jobname can be specified with MiKTeX. They'll definitely not work with TeX Live.