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

What I would like is to suppress the expansion of the group as a parameter to a macro so that it can be expanded later. For example we want to pass the paramater unmodified as a string to lua or to a file.

Let us suppose we have a macro \foo which accepts a parameter.


if we call it as: \foo{\bar{abc}} the \bar gets expanded before \foo gets to see it. Of course we can manually suppress the expansion with \foo{\noexpand\bar{abc}}, but can it be done automatically?

share|improve this question
I'd say \directlua{foo([[\unexpanded{#1}]])} – egreg Oct 4 '12 at 11:13

It doesn't really answer your question, but I think you are thinking about expansion wrong.

if we call it as: \foo{\bar{abc}} the \bar gets expanded before \foo gets to see it.

The argument to \foo is not expanded before \foo gets to see it. It is expanded inside \foo. Consider the following


If you want to expand \bar before \foo get to see it you need an \expandafter: \expandafter\foo\expandafter{\bar{abc}}

share|improve this answer
You actually want two of them: \expandafter\foo\expandafter{\bar{abc}}. What you wrote only expands the {, which has no effect. – Ryan Reich Oct 4 '12 at 13:58
@RyanReich thank you, I fixed it. – StrongBad Oct 4 '12 at 14:03

Without a full example to test this is untested but I would assume that you could go

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.