Next: , Previous: , Up: Command line interface   [Contents][Index]

### 28.3 Jobname

Running LaTeX creates a number of files, including the main PDF (or DVI) output but also including others. These files are named with the so-called jobname. The most common case is also the simplest, where for instance the command pdflatex thesis creates thesis.pdf and also thesis.log and thesis.aux. Here the job name is thesis.

In general, LaTeX is invoked as latex-engine options argument, where latex-engine is pdflatex, lualatex, etc. (see TeX engines). If argument does not start with a backslash, as is the case above with thesis, then TeX considers it to be the name of the file to input as the main document. The name of that root file, without the .tex extension, is the jobname. If argument does start with a backslash, or if TeX is in interactive mode, then it waits for the first \input command, and the jobname is the argument to \input.

There are two more possibilities for the jobname. It can be directly specified with the -jobname option, as in pdflatex -jobname=myname (see Command line input for a real example).

The final possibility is texput, which is the final fallback default if no other name is available to TeX. For example, if no -jobname option was specified, and the compilation stops before there is any output, then the log file will be named texput.log.

A special case of this is that in LaTeX versions of (approximately) 2020 or later, the jobname is also texput if the first \input occurs as a result of being called by either \documentclass or \RequirePackage. So this will produce a file named texput.pdf:

pdflatex "\documentclass{minimal}\begin{document}Hello!\end{document}"


However, this special case only applies to those two commands. Thus, with

pdflatex "\documentclass{article}\usepackage{lipsum}\input{thesis}"


the output file is lipsum.pdf, as \usepackage calls \input.

Within the document, the macro \jobname expands to the jobname. (When you run LaTeX on a file whose name contains spaces, the string returned by \jobname contains matching start and end quotes.) In the expansion of that macro, all characters are of catcode 12 (other) except that spaces are category 10, including letters that are normally catcode 11.

Because of this catcode situation, using the jobname in a conditional can become complicated. One solution is to use the macro \IfBeginWith from the xstring package in its star variant, which is insensitive to catcode. For example, in the following text the footnote “Including Respublica Bananensis Francorum.” is only present if the task name starts with my-doc.

If a democracy is just a regime where citizens vote then
all banana republics \IfBeginWith*{\jobname}{my-doc}%
{\footnote{Including Respublica Bananensis Francorum.}}{} are
democracies.


Manipulating the value of \jobname inside of a document does not change the name of the output file or the log file.