# Omitting arguments in macro expansion

Changing a simple TeX macro like

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


into

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


alters the output of

\macro Hello world


surprisingly for me to

Helloorld


My expectation would have been to get just

Hello


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

-

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

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


with

\foo bar


prints

<b>ar


while with

\foo{bar}


prints

<bar>


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


prints

<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

<Hello><w>orld


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.

-