TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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).

share|improve this question
up vote 4 down vote accepted

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

share|improve this answer

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,

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.