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

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.

share|improve this question
up vote 14 down vote accepted

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.

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.