TransWikia.com

Having trouble with IfStrEq from xstring

TeX - LaTeX Asked by DavidBrodersen on October 4, 2020

precondition: The filename is lab00.tex

deffn{jobname}

StrLeft{fn}{1}[firstChar]

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

One Answer

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

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

Answered by egreg on October 4, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP