I am having some difficulty with the expansion of LaTeX. I would like to expand the contents of an \input command before passing them to macro, in a pattern similar to the following:


Essentially, what I would like to do is expand the contents of the macro (\inner) before running the macro (\outer), in a pattern similar to the following:


The file referenced by the \input command has to be run through \macro in order to run properly, but at present it returns the same error as it would if it had not been run through \macro.

I have been trying to apply a number of expansion methods, but have been unsuccessful. As I understand it, \expandafter\a\b will expand \b before \a. I would like to achieve a similar effect with the contents of a macro.


Is the literal answer to the question in the (original:-) title, but I'm not sure it will do anything useful for \input which does not (in its latex version) solely work by expansion.

Do you mean that you want to pass all the contents of the file to the macro?

If you do want to grab the contents of a file it is surprisingly tricky, the catchfile package addresses just that issue.

  • 1
    I wasn't aware that \input doesn't work solely by expansion. I've edited the question to suit. Dec 31 '12 at 3:09

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.