I am working with \newcommand and \ifdefined. I have an issue with the below code as it produces an error and I don't know what is wrong:







\newcommand{\OpenIssues}[1]{\ifcsname#1OpenIssues\endcsname \Failed#1 \else \ifdefined\NoOpenIssues NA \fi \fi 



Any help ?

  • the error is undefined command \Failed you have that command in the definition but have not defined it, what do you want it to do? Commented Nov 2, 2021 at 21:42
  • oh did you want to execute \FailedReq ? you need \csname Failed#1\endcsname` Commented Nov 2, 2021 at 21:44

2 Answers 2


It's exactly the same problem as in your previous question where you tried


in the hope that \#1OpenIssues becomes \ReqOpenIssues when the argument of the macro is Req.

Sorry, but TeX works with tokens that are formed at definition time. In that replacement text the tokens are


(the bullet just separates tokens for clarity). In particular that part of the replacement text never has #•1 which marks the place for the argument substitution.

Similarly here


is three tokens


and the argument replacement yields


(four tokens).

The primitive \ifcsname forms a control sequence name with the tokens up to the matching \endcsname; then it tests whether that control sequence is defined.

For the problem at hand you have to use the corresponding primitive that forms the control sequence and executes it, so

\csname Failed#1\endcsname

See What exactly do \csname and \endcsname do?


if #1 is req then \Failed#1 is the same as \Failed req and gives an error that \Failed is undefined.

You intended to execute \FailedReq so to generate that command name you should replace \Failed#1 by \csname Failed#1\endcsname

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .