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:
\def\myjob{test}
\edef\myjob{\meaning\myjob}
\edef\tmpjob{\jobname}
\edef\tmpjob{\meaning\tmpjob}
\ifx\myjob\tmpjob
\message{My own job: \jobname}
\else
\message{Other job: \jobname}
\fi
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 \edef
s 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.