# Whole word as a macro argument when macro called without braces

I have a macro:

\newcommand{\sEmph}[1]{\textbf{\textcolor{NavyBlue}{#1}}}


Then I can do:

Some text is in \sEmph{blue}, and some in black.


with this result:

But if I omit the braces only the letter b is blue, like this:

Some text is in \sEmph blue, and some in black.


Q: Is there a way to make my macro work on words without using braces?

-
But why would you want to do this? How would you specify the termination of this macro application? At the next punctuation mark, or the next space? What about usages that span more than one word? – Werner Apr 12 '13 at 23:01
is it OK to terminate the word with a distinct character such as | or something like that? Otherwise you need to parse everything until a word (looking for punctuation etc.) is found which is harder. – percusse Apr 12 '13 at 23:01
I am aware that ambiguity is the problem. However, I need only the next word (up to the white space) to be considered the argument. So, basically, it's not possible, is it? – Kornelije Petak Apr 12 '13 at 23:08
@KornelijePetak: It is possible. See the solution of David Carlisle or mine with + replaced by a space. But it won't work with a word terminated by a comma, as in your example. – Przemysław Scherwentke Apr 12 '13 at 23:16
True, it won't work, but if I know that I will never use certain characters, like a # for example, I could use this as a separator and then do something like \sEmph this will all be bl#ue. making everything blue except the ue. characters. So that would let me decide where to stop the effect of the macro. Is that correct? Are there any problems with such scenario? Well, maybe not #, cause it has meaning in TeX, but some other that I know I will not use. – Kornelije Petak Apr 12 '13 at 23:19

You can go

\def\zz#1 {\textcolor{blue}{#1} }


then \zz has its argument delimited by a space

\zz word like this


will make word go blue, but it has to be delimited by an explict space.

 \zz word\ like this


would make word\ like blue and

... \zz word}..


will generate an error.

A major design aim of LaTeX is to give consistent syntax to all commands, mandatory arguments in {} optional arguments in [] etc, so LaTeX provides no real support for these delimited arguments and it's usually a bad idea to use them at the top level in the document.

-

An easy solution is the following: \def\sEmph#1+{\textbf{\textcolor{NavyBlue}{#1}}}, but you must use + character to terminate the word. If you need (La)TeX to recognize words as strings of letters terminated by any non-letter, it is much more complicated.

-