2

I'm reading The TeXbook by Knuth.

Page 205 has

If you actually want a control sequence to allow arguments with \par tokens, you can define it to be a “long” macro by saying ‘\long’ just before ‘\def’. For example, the \bold macro defined by

\long\def\bold#1{{\bf#1}}

is capable of setting several paragraphs in boldface type...

I tried to have only one set of curly brackets. It worked with no problems.

\long\def\bold#1{\bf#1}

\bold{Hello

world}

Why did Knuth write two sets of curly brackets in {{\bf#1}}. Are there any corner cases?

1 Answer 1

9

With the definition

\long\def\bold#1{\bf#1}

\bold{hello world} is simply expanded to \bf hello world, so \bf is applied not only to the argument of \bold, but also to what follows. Indeed, consider the following example.

\documentclass{article}
\long\def\bold#1{\bf#1}
\begin{document}
\bold{Hello

world}

Hello world
\end{document}

This outputs which is obviously not the intended result.

Adding the second pair of curly brackets allows to restrict \bf to the argument of \bold.

0

You must log in to answer this question.

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