Changing a simple TeX macro like

\def\macro#1 #2{#1 #2}


\def\macro#1 #2{#1}

alters the output of

\macro Hello world

surprisingly for me to


My expectation would have been to get just


I'm afraid, I fundamentally misunderstand TeX's working mechanisms. It would be great if someone would take the effort to explain the result.

1 Answer 1


TeX grabs arguments is two ways. The first is 'undelimited', which will absorb one balanced text for each argument. Here, balanced text means either one token or a single token group. For example



\foo bar



while with




as in the first case there are no braces (grouping) while in the second case there is.

The other way TeX absorbs tokens as parameters is 'delimited'. This is what happens when you specify some token or tokens must be present. In the definition

\def\foo#1 {<#1>}

TeX looks for everything up to the first space. So

\foo bar stuff



Notice that the space has been 'used up' by this matching.

In the case

\def\foo#1 #2{<#1><#2>}

you have two arguments. The first is delimited, and reads up to the first space, while the second is undelimited and so grabs a balanced text. Thus with

\foo Hello world

you see


What's important in the context of the question is that the 'remaining stuff' is still printed and is unaffected by \foo: that's why we still see orld here. In the example in the question, with no 'marker' tokens added in, that's why you might think that

\def\macro#1 #2{#1 #2}

is grabbing world when used as

\macro Hello world

while in fact #2 here is just w, and the orld is left in the input stream after \macro has acted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .