I have a (probably) quite uncommon problem.


\def\head{\titel } % \titel = undefined

\func{\head} % func is defined and handles \titel without any issues
\func{\titel} % throws an exception

It is neither a good idea to post the actual code (>3 pages) nor possible to reproduce it in an MWE. If I could reproduce it, I could probably solve it myself. I already tried \unexpanded and \noexpand.

What I want to get here: Hints what could be the reason of this problem. If requested, I can give you the whole code. But this will be at least two files.


deleted, since no further useful information for the problem

Edit 2:

This is the core function. It prints every token of #4. If any token is undefined it calls function \GFM@<tokenWithRemoved'\'>. Actually this function should work recursive, but then it throws an error at the inner function (since argument is undefined). #4 may need double {{ }}.

\def\printLayout#1#2#3#4{{%#1=Liederbuch #2=Liednummer '#3=Liedvariante
    %Definition of subroutines
            \csname GFM@\tempDefA\endcsname%  !!!What will be called if undefined!!!
    %Actual routine

I decided to follow a different approach in this project. The Edit2 is for people with similar problems, who stumble over this question. You may, but dont need to resolve this problem.

  • 1
    \def\head{\titel} is fine, but without knowing what \func does we can't really help. Assuming \head is entirely free-form it's tricky to design a test for 'one or more undefined control sequences': we'll need some more spec. – Joseph Wright Jul 13 '16 at 13:33
  • @JosephWright func tests for each token of the argument, if it is undefined. If it is, it calls another function (\GFM@<value1>@<value2>@<value3>@titel; the values change). If it is defined, it is printed. – MaestroGlanz Jul 13 '16 at 13:41
  • \ifx\#1 won't work of course – user31729 Jul 13 '16 at 14:01
  • @ChristianHupfer Yep, you are right. :facepalm: – MaestroGlanz Jul 13 '16 at 14:02
  • 1
    @DavidCarlisle: Yes, but that's not what is intended ;-) – user31729 Jul 13 '16 at 14:03

You don't give much to go on, but this plain tex file shows the described behaviour, the first call works, the second gives an error.


\def\head{\titel } % \titel = undefined

\func{\head} % func is defined and handles \titel without any issues


  • That is clearly understandable. Shall I append the actual code? But this will be huge. I appended my workaround, which doesnt work either though it definitely should. – MaestroGlanz Jul 13 '16 at 13:57
  • @MaestroGlanz if it fits in the site limits and you really can not make it smaller then why not, but it has to be equivalent to the above, in the end, if you don't get an undefined command error by wrapping in one level of macro definition then expansion is being suppressed after one level of expansion, perhaps not exactly \expandafter\string but \meaning or \detokenize etc can have similar effect. – David Carlisle Jul 13 '16 at 14:01
  • I decided (for several reasons) to follow a different concept which is much more simplified, but (a little) less easy to use. I will append the core def to the question, to help user who will encounter a similar problem. – MaestroGlanz Jul 13 '16 at 16:31

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.