[NTG-context] Checking existence of a macro (control sequence) by Lua

context at vivaldi.net context at vivaldi.net
Thu May 28 00:42:58 CEST 2020


is it possible to check whether a macro exists (or - is it a 
non-\undefined control sequence) with Lua? Suppose:


     IsDefined = function(ctl_seq)
       print("CS " .. ctl_seq ..
                                 (tex.IsCS(ctl_seq) -- Or what to come 
                                                    "is defined" or "is 
unknown") .. ".")

     -- So the function should print to the console:

     IsDefined("MyMacro") --> "CS MyMacro is defined."
     IsDefined("MyMac") --> "CS MyMac is defined."
     IsDefined("bf") --> "CS bf is defined."
     IsDefined("dummy") --> "CS dummy is unknown."


Is it possible?

Best regards,


More information about the ntg-context mailing list