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

I have a macro:


Then I can do:

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

with this result:

enter image description here

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

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

enter image description here

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

share|improve this question
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
up vote 13 down vote accepted

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.

share|improve this answer

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.

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.