\definestartstop—a forgotten macro

Recently, I needed a macro, which I call \important, that will typeset its arguments in italic font and dark red color. At first, I used the definition

\def\important#1%
  {\startcolor[darkred]\italic#1\stopcolor}

or its slightly refined alternative

\def\important%
  {\groupedcommand{\startcolor[darkred]\italic}{\stopcolor}}

The second alternative behaves like the first, but is slightly more robust. It does not grab the contents of its arguments, and hence works better if something inside #1 does category code jugglery.

Although, the above definition works fine, it does not have a ConTeXt flavour. What use is an easy to use macro package if you have to resort to TeX programming for such a simple macro?

Enter \definestartstop. The above command can be defined as

\definestartstop[important]
                [style=italic,
                 color=darkred]

Much better.

But, wait a minute. The command is called \definestartstop. It defines an environment \startimportant ... \stopimportant. But, as a bonus, it also defines an inline \important{...}.

As a concluding note, I leave you with the following exercise. Guess the output of the following:

\definestartstop[important]
                [before=\startframedtext,
                  after=\stopframedtext,
                  style=italic,
                  color=darkred]

\setupcolors[state=start]

\starttext

some normal text \important{some important text} some more normal text

\startimportant
  \input knuth
\stopimportant

\stoptext
Advertisements

One thought on “\definestartstop—a forgotten macro

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s