5

The following plain TeX manuscript produces (with pdftex) no pages of output and no errors.

\def\mac.#1 #2.{#1}%
\mac. a b.%
\bye

Why?

I expect it to produce one page of output with the text

a

If I change the manuscript by replacing the macro's body with Hello, world!, the manuscript produces the expected result: one page of output with the text

Hello, world!

1 Answer 1

10

You have a space after your . here: that's important. TeX is looking for the shortest match to the argument spec, which it can achieve by #1 being empty and that space being the one between #1 and #2. The latter is thus 'a b' (you can see that with for example \showtokens or \tracingall).

Only one parameter in a continuous set can be empty, so with

\def\mac.#1#2 #3.{#1}%

#1 is a (with the space discarded) and you get the output you expect.

1

You must log in to answer this question.

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