Due to some commands in my preamble (\synctex=1,\makenomenclature,\settocdepth{subsection}) which are not fully compatible with --jobname procedure, I would like to add a test before these three line to detect if --jobname is specified at the compilation. Do you know a way to do such test ?

Or maybe you have another way to get my file compiled with and without --jobname option...


2 Answers 2


I should stress that this only works if \jobname is not equal to the file name.

The only method I know of is to hard-code you document name in the file. So for instance if your file is named test.tex you could do this testing:

  \message{My own job: \jobname}
  \message{Other job: \jobname}

before the \documentclass. In this way you know whether you use your regular jobname or have supplied it. I do not think you can do it automatically, although I might be wrong.

The reason for doing the above \edefs is that \jobname is a character where \myjob is a letter. Therefore you need to transfer them to the same macro, done by the \edef and \meaning. If in doubt you can do \message{\meaning} in each step to see what is done.


The v0.6 of the currfile can now detect the real main file using the -recorder compiler argument. You can test if this name is identical to the jobname using \ifcurrfile... and so determine if the jobname was changed:

% Compile with: (pdf|xe|lua|)latex -recorder filename
% Needs two runs with MiKTeX, one with TeX Live


%or: \ifcurrfilebase{\jobname}{%
    \message{No \string\jobname\space used!}%
    \message{\string\jobname\space was used!}%


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .