I want to use the same source file to compile various target files using the -jobname option. I want to ensure that the option is not forgotten, so my approach was to check whether the \jobname is equal to the source file name. The check does not work as expected:
% save as file mwe.tex
\documentclass{article}
\usepackage{etoolbox}
\begin{document}
\typeout{=== JOB: {\jobname} ===}
\ifstrequal{\jobname}{mwe}{\errmessage{Please specify a different jobname.}}{}
Job \jobname
\end{document}
If I compile this file with pdflatex -jobname foo mwe.tex, I get the following output:
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
restricted \write18 enabled.
entering extended mode
(./mwe.tex
LaTeX2e <2011/06/27>
Babel <3.9h> and hyphenation patterns for 78 languages loaded.
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2013/texmf-dist/tex/latex/etoolbox/etoolbox.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/etex-pkg/etex.sty)) (./foo.aux)
=== JOB: {foo} ===
[1{/usr/local/texlive/2013/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./foo.aux) )</usr/local/texlive/2013/texmf-dist/fonts/type1/public/amsfonts/cm
/cmr10.pfb>
Output written on foo.pdf (1 page, 10274 bytes).
Transcript written on foo.log.
The problem is: If I compile it with pdflatex mwe.tex, it shows the job name mwe, but the expected error message does not appear:
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013)
restricted \write18 enabled.
entering extended mode
(./mwe.tex
LaTeX2e <2011/06/27>
Babel <3.9h> and hyphenation patterns for 78 languages loaded.
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2013/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2013/texmf-dist/tex/latex/etoolbox/etoolbox.sty
(/usr/local/texlive/2013/texmf-dist/tex/latex/etex-pkg/etex.sty)) (./mwe.aux)
=== JOB: {mwe} ===
[1{/usr/local/texlive/2013/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./mwe.aux) )</usr/local/texlive/2013/texmf-dist/fonts/type1/public/amsfonts/cm
/cmr10.pfb>
Output written on mwe.pdf (1 page, 11747 bytes).
Transcript written on mwe.log.
I read about the catcode issue caused when using \jobname in combination with \ifthen -- however, according to the etoolbox documentation, \ifstrequal is catcode-agnostic. What else is going (wr)on(g) here?
\expandafter\ifstrequal\expandafter{\jobname}{mwe}or\ifdefstring{\jobname}{mwe}– cgnieder Oct 26 '14 at 12:41\expandafter\ifstrequal\expandafter{– percusse Oct 26 '14 at 12:42