Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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...

share|improve this question
1  
I don't think that this is possible. Somewhat related question: Macro to retrieve the real name of the source file if pdflatex is invoked with -jobname –  Daniel Feb 14 '12 at 9:44
    
@Daniel: It's now possible. See my answer to the question you linked and to my answer below. –  Martin Scharrer May 8 '12 at 7:54
add comment

2 Answers

up vote 4 down vote accepted

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 \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.

share|improve this answer
    
Thanks, it work like a charm ! –  Sigmun Feb 14 '12 at 13:29
add comment

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
\documentclass{article}

\usepackage[realmainfile]{currfile}[2012/05/06]

\ifcurrfile{\themainfile}{\jobname.tex}{%
%or: \ifcurrfilebase{\jobname}{%
    \message{No \string\jobname\space used!}%
}{%
    \message{\string\jobname\space was used!}%
}


\begin{document}
 ...
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.