6

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)
Henri Menke
  • 109,596
Leo Simon
  • 2,199

2 Answers2

4

If you are using TeXstudio with TeX Live/MacTeX, you can include the line

% !TeX TXS-program:compile = txs:///pdflatex/[-jobname=myName]

at the beginning of your document to specify myName as the name of the output file.

3

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.

egreg
  • 1,121,712
  • I can confirm that the pdflatex executable included in MacTeX (2020) ignores the “magic comment” %& -jobname=myName or %& -job-name=myName.

    By contrast, the pdflatex executable included in MiKTeX for the Mac does take the magic comment %& -job-name=myName into account.

    – Holger Gerhardt Jun 27 '20 at 10:47