Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

\outer{\inner}

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:

\macro{\input{../path/to/file.tex}}

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.

share|improve this question

1 Answer 1

up vote 6 down vote accepted
 \expandafter\outer\expandafter{\inner}

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.

share|improve this answer
    
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

 
discard

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.