Yet another question about passing parameters when compiling. I thought I had a good (for me) solution, by compiling with different jobnames and do conditional compilation on the basis of the jobname, using etoolbox and \ifdefstring; but it does not work. What's wrong with the following code? It seems that the \ifdefstring always evaluate to false.
%
% Save this file as A.tex
% compile it with 'latex A.tex'
% compile it again with 'latex -jobname B A.tex'
% you end up with A.dvi and B.dvi.
%
\documentclass{article}
\usepackage{etoolbox}
\begin{document}
The current jobname is: \jobname
\ifdefstring{\jobname}{A}{This file should be named A.dvi}%
{This file should be named B.dvi}
\end{document}
EDIT: Actually I did not understand the proposed answer (and I tried it unsuccesfully): I should say I am not a TeXpert, only a LaTeX user. I would like to get an answer in terms of the usage of the package etoolbox, which, as far as I understand, is the implementation bit of such affairs whithin LaTeX3. I wrote the above bit of code using the instructions of etoolbox, which says that \ifdefstring{<command>}{<string>}{<true>}{<false>} executes true or false according to wether the command matches the string. I guessed that the problem was that \jobname is not a command in the sense of LaTeX, and I tried to define \newcommand{\Jobname}{\jobname} to "commandify" it, but it did not work. I think that, since LaTeX users which are not TeXperts browse this forum, it would be nice to have a full LaTeX solution if possible. Thank you all (and sorry for making this required edit so late, I was offline for a couple of days).
Is there a way of transforing catcode 12 into catcode 11? I tried the suggested combiantion \edef and \detokenize, unsuccesfully.
– Gherardo Aug 16 '18 at 10:48\ifdefstring{\jobname}{abc}{file is abc.pdf}{not abc}? Which string do you\detokenize? Note that the jobname may not be a single character. I've tried using\detokenizeon\jobnameorabcor both, but allifdefstrings resulted in false. – Ryo Feb 01 '23 at 04:27