I try to expand a macro containing a string with another string. It is in the document and thus I want to avoid using @.

I tried the following using etoolbox


It does not work. The \demcocodefile is not expanded (thus the \expandafter).


What you're expanding is \fileAcronym and not \democodefile, since \expandafter expands whatever comes immediately after the next token. You could use


but it may be more concise (since you're only using strings) to rather use


Assuming that \democodefile expands to the string you want to append something to, creating \fileAcronym that expands to the augmented string, the easiest way is to say


Without \appto:


With less characters


(\unexpanded\expandafter can be replaced by \expandonce, if you already load etoolbox).

An “abstract” version:


With that code in the preamble you can say, in the document,


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.