I am having difficulty in using xtring
to check the file name of the .tex file.
All three of the cases shown below produce the wrong output. Surprisingly in my actual more complicated usage, the first two of these work just fine, so I am really confused as to why I am unable to get this simple example to work. The following needs to be saved as "FileName-A-B.tex", and as far as I am concerned it should have printed out the first part of the 'If
statements and not the else
part.
I want to check the portions between the dashes in the file name.
\documentclass{article}
\usepackage{xstring}
\begin{document}
The .tex file name is "\jobname" \newline
% Check that the file name begins with "FileName-"
\IfBeginWith{\jobname}{FileName-}{
Yes, file name does begin with [FileName]
}{
Error: File name does NOT begin with [FileName]
}
% Check that the file name ends with "B"
\IfEndWith{\jobname}{-B}{
Yes, file name ends with "B"
}{
Error: File name does NOT end with [B]:
}
%Now check what that there is an "A" in between the dashes
\StrBetween[1,2]{\jobname}{-}{-}[\mystring]%
\IfStrEq{\mystring}{A}{
Yes, file has an [A] in the middle
}{
Error: File name does NOT have an [A] in the middle,
it has [\mystring] instead.
}
\end{document}