How to make spaces as command argument delimiters?
\documentclass{article}
\newcommand\foo[2]{#1 and #2.}
\begin{document}
\foo hi you
\end{document}
The expected output is
hi and you.
Of course I don't want to enclose the arguments with curly braces.
The following is not what I am looking for.
\documentclass{article}
\def\foo #1 #2 {#1 and #2.}
\begin{document}
\foo hi you
\end{document}
Best Answer
You can't do this with
\newcommand
. But it's possible with\def
:Now
\foo x y Something
will give the expected result. However this will break in cases such asbecause there's no space after
you
(the end-of-line counts as a space only if not followed by another end-of-line, when they are transformed into\par
).You can look in the TeXbook or in TeX by Topic for "delimited arguments".