0

precondition: The filename is lab00.tex

\def\fn{\jobname}

\StrLeft{\fn}{1}[\firstChar]

\IfStrEq{\firstChar}{l}{true}{false}

1 Answer 1

3

The result is “false”, because although the package claims to compare “strings”, it actually takes into consideration category codes.

The first character in your \jobname is an l of category code 12, by general rule of TeX about generated strings of characters. However, you're comparing it with a standard category code 11 l.

You could do

\def\fn{\jobname}
\StrLeft{\fn}{1}[\firstChar]
\IfStrEq{\firstChar}{\detokenize{l}}{true}{false}

because \detokenize uses the same internal machinery that outputs characters with category code 12.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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