1 <?xml version="1.0" encoding="utf-8"?>
3 This file is part of groff, the GNU roff type-setting system.
5 Copyright (C) 2004-2018 Free Software Foundation, Inc.
6 Written by Peter Schaffter (peter@schaffter.ca).
8 Permission is granted to copy, distribute and/or modify this document
9 under the terms of the GNU Free Documentation License, Version 1.3 or
10 any later version published by the Free Software Foundation; with no
11 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
14 A copy of the Free Documentation License is included as a file called
15 FDL in the main directory of the groff source package.
18 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
19 <html xmlns="http://www.w3.org/1999/xhtml">
22 <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
23 <title>Mom -- Colour</title>
24 <link rel="stylesheet" type="text/css" href="stylesheet.css" />
27 <body style="background-color: #f5faff;">
29 <!-- ==================================================================== -->
31 <div id="top" class="page">
33 <!-- Navigation links -->
34 <table style="width: 100%;">
36 <td><a href="toc.html">Back to Table of Contents</a></td>
37 <td style="text-align: right;"><a href="graphical.html#top">Next: Graphical objects</a></td>
41 <h1 class="docs">Coloured text</h1>
43 <div style="text-align: center;">
44 <a href="#index-color">List of color macros</a>
47 <div class="rule-medium"><hr/></div>
49 <h2 class="docs">Introduction</h2>
52 Mom’s support for coloured text is straightforward. You begin
53 by telling mom about the colours you want with
54 <kbd><a href="#newcolor">NEWCOLOR</a></kbd>
56 <kbd><a href="#xcolor">XCOLOR</a></kbd>.
57 Afterward, any time you want text to be coloured, you either colour
59 <a href="definitions.html#inlines">inline escape</a>
60 that contains the colour name (e.g. <kbd>\*[red]</kbd>
61 or <kbd>\*[blue]</kbd>) or invoke the macro
62 <kbd><a href="#color">COLOR</a></kbd>
63 with the name of the colour you want.
66 <p id="color-example">
67 For example, say you want to have the name “Jack” in the
68 sentence “All work and no play makes Jack a dull boy”
69 appear in yellow. You'd begin by telling mom about the colour,
70 yellow. There are two ways of doing this; see
71 <kbd><a href="#newcolor">NEWCOLOR</a></kbd>
73 <kbd><a href="#xcolor">XCOLOR</a></kbd>
74 for a full explanation of the difference between the two.
78 If you use XCOLOR, you'd enter this:
80 <span class="pre-in-pp">
83 If you use NEWCOLOR, you might enter:
85 <span class="pre-in-pp">
86 .NEWCOLOR yellow RGB #FFFF00
90 <p id="color-example2" style="margin-top: -1em;">
91 After “defining” (or “initializing”) the
92 colour “yellow”, you'd colourize the name, Jack, either
95 <span class="pre-in-pp">
96 All work and no play makes \*[yellow]Jack\*[black] a dull boy.
99 <kbd><a href="#color">COLOR</a></kbd>
102 <span class="pre-in-pp">
103 All work and no play makes
109 Notice, in both examples, that a) you have to set the colour back
110 to black after “Jack”, and b) you don’t have to
111 define or intialize the colour, black. Mom predefines it for you.
115 For information on using colour during
116 <a href="docprocessing.html#intro-macros-docprocessing">document processing</a>,
118 <a href="docprocessing.html#color">Colour support in document processing</a>.
121 <div class="box-tip">
123 <span class="note">Note:</span>
124 Mom’s colour support is for text only. She doesn’t
125 support “fill” (or “background”) colour for
126 solid, enclosed graphical objects (polygons, ellipses) drawn with
127 groff’s <kbd>\D</kbd>
128 <a href="definitions.html#inlines">inline escapes</a>,
129 although you may give a colour as one of the arguments to
130 mom’s “box” and “circle” macros,
131 <a href="graphical.html#dbx">DBX</a>
133 <a href="graphical.html#dcl">DCL</a>
134 when the first argument to these macros is <kbd>SOLID</kbd>.
138 <div class="box-tip">
140 <span class="experts">Experts:</span>
141 If you’re accustomed to using groff’s
142 <kbd>.defcolor</kbd> to define colours, and groff’s inline
143 <kbd>\m[<colorname>]</kbd> to call them, you may continue to
144 do so without confusing mom.
148 <div class="macro-list-container">
149 <h3 id="index-color" class="macro-list">Coloured text macros</h3>
151 <ul class="macro-list">
152 <li><a href="#newcolor">NEWCOLOR</a></li>
153 <li><a href="#xcolor">XCOLOR</a></li>
154 <li><a href="#color">COLOR</a></li>
155 <li><a href="#color-inline">\*[<colorname>]</a> (inline escape)</li>
159 <div class="rule-medium" style="margin-bottom: 1.5em;"><hr/></div>
163 <div class="macro-id-overline">
164 <h3 id="newcolor" class="macro-id">Creating (initializing) a colour with NEWCOLOR</h3>
167 <div class="box-macro-args">
168 Macro: <b>NEWCOLOR</b> <kbd class="macro-args"><colour name> [<colour scheme>] <colour components></kbd>
172 NEWCOLOR lets you create a colour, rather like an artist mixing
173 paint on a palette. The colour isn’t used immediately;
174 NEWCOLOR merely tells mom how to mix the colour when you need it.
175 If you haven’t invoked <kbd>.NEWCOLOR</kbd> (or
176 <kbd><a href="#xcolor">.XCOLOR</a></kbd>),
177 mom doesn’t have a clue what you mean when you reference a
179 <a href="#color">COLOR</a>
181 <a href="#color-inline"><kbd>\*[<color name>]</kbd></a>).
185 The first argument to NEWCOLOR is a name for your colour. It
186 can be anything you like—provided it’s just one word
187 long—and can be caps, lower case, or any combination of the
192 The second argument, which is entirely optional, is the
193 “colour scheme” you want mom to use when mixing the
194 colour. Valid arguments are
196 <span class="pre-in-pp">
197 RBG (3 components: red green blue)
198 CYM (3 components: cyan yellow magenta)
199 CMYK (4 components: cyan magenta yellow black)
202 If you omit the second argument, mom assumes you
207 The final argument is the components of your colour. This can be
208 hexadecimal string starting with a pound sign (<kbd>#</kbd>) (for
209 colour values in the 0-255 range) or two pound signs (<kbd>##</kbd>)
210 (for colour values in the 0-65535 range), or it can be a series of
211 decimal digits, separated by spaces, one digit per component, with
212 the argument enclosed in double quotes. (If this is all gibberish
214 <a href="#color-tip">Tips for newbies</a>.)
218 Thus, to tell mom about a colour named “YELLOW”, you
219 could enter one of the following:
221 <span class="pre-in-pp">
222 .NEWCOLOR YELLOW #FFFF00 \"or ##FFFFFFFF0000 or "1 1 0"
223 .NEWCOLOR YELLOW RGB #FFFF00 \"or ##FFFFFFFF0000 or "1 1 0"
224 .NEWCOLOR YELLOW CYM #00FF00 \"or ##0000FFFF0000 or "0 1 0"
225 .NEWCOLOR YELLOW CYMK #00FF0000 \"or ##0000FFFF00000000 or "0 0 1 0"
227 After you've told mom about a colour, you can then get her to set
228 text in that colour either with the
229 <a href="definitions.html#inlines">inline escape</a>,
230 <a href="#color-inline"><kbd>\*[<colorname>]</kbd></a>,
232 <a href="#color">COLOR</a>.
234 <a href="#color-example">example</a>,
238 <div class="box-tip">
240 <span class="note">Note:</span>
241 The colorname you give to NEWCOLOR may be used with groff’s
242 <kbd>\m[<colorname>]</kbd> inline escape (the <kbd>\m</kbd>
243 escape is used to set text and rule colours). Thus, assuming
244 a colorname “blueblack” set with NEWCOLOR,
245 <kbd>\*[blueblack]</kbd> and <kbd>\m[blueblack]</kbd> are
246 equivalent. Furthermore, the colorname can be given as an argument
247 to <b>groff</b>’s
248 <a href="definitions.html#primitives">primitive</a>
249 request, <kbd>.gcolor</kbd> (which does the same thing as
250 <kbd>\m[<colorname>]</kbd>).
253 <p class="tip-bottom">
254 Equally, the colorname may be used with
255 <kbd>\M[<colorname>]</kbd> and <kbd>.fcolor</kbd>, which set
256 the “fill” colour for solid graphical objects.
260 <div class="box-tip">
261 <p id="color-tip" class="tip-top">
262 <span class="tip">Tips for newbies:</span>
263 Colour manipulation can be tremendously confusing if you don’t
264 have a background in graphic arts or computing. My advice, if color
265 intimidates you, is to stick to using mom’s default RGB colour
266 scheme, and to fire up a color chooser that gives you the RGB values
267 you want for the colour you select. Plug those values into the
268 components argument to NEWCOLOR, and you’ll get the colour
269 you want. Both the KDE and gnome desktops have colour selectors
270 that provide you with the shorter RGB hexadecimal string. If
271 you’re not running KDE or gnome, the X utility, xcolorsel,
272 provides you with a similar functionality, although it only provides
273 RGB values for 256 pre-defined colours. If you use xcolorsel, be
274 sure to click the button “Display format” and select
275 “8 bit truncated rgb”.
278 <p class="tip-bottom">
279 Alternatively, you can use mom’s simpler
280 <kbd><a href="#xcolor">XCOLOR</a></kbd>
281 macro to initialize one of the 256 pre-defined X colours by
282 supplying the name of the color as an argument.
288 <div class="macro-id-overline">
289 <h3 id="xcolor" class="macro-id">Initializing a colour with XCOLOR</h3>
292 <div class="box-macro-args">
293 Macro: <b>XCOLOR</b> <kbd class="macro-args"><X colorname> [<alias>]</kbd>
297 <kbd style="font-style: normal"><X colorname></kbd> <i>must be all one word, all lower case.</i>
300 <a href="#xcolor-names" style="font-style: normal;">Finding X color names</a>
301 for how to get a list of valid colour names.)
305 XCOLOR is similar to NEWCOLOR in that it tells mom to initialize a
306 colour, but it’s easier to use. All you have to do is pass
307 it, as an argument, the valid name of one of the 256 pre-defined
308 X colours. The name must be all one word, and, breaking with mom
309 policy, it must be entered in lower case.
313 For example, if you want to intialize the X colour, coral, all you
316 <span class="pre-in-pp">
321 <span class="pre-in-pp">
325 will colourize subsequent text coral until you instruct mom to
326 return to black, or some other pre-defined, initialized colour.
328 <a href="definitions.html#inlines">inline escape</a>
329 <kbd>\*[coral]</kbd> will equally colourize text coral after you've
330 initialized the colour with XCOLOR.)
334 The downside of XCOLOR is that you can’t create custom
335 colours. This restriction, however, is mitigated by the fact that
336 for many users, 256 colours is more than enough to play around with.
340 While some X colours have fanciful names (peachpuff, papayawhip,
341 thistle, snow), many are self-explanatory and self-descriptive
342 in ordinary colour terms. “blue” is pure (rgb)
343 blue, “green” is pure (rgb) green, and so on.
344 Furthermore, for many X colors, there exist four variants, each
345 representing increasingly darker shades of the same colour.
346 For example, “blue1” is a relatively bright blue;
347 “blue2”, “blue3” and “blue4” are
348 increasingly darker shades. For that reason, you may find XCOLOR is
349 a better choice than NEWCOLOR when it comes to initializing common
354 The whimsical nature of X colour names sometimes makes for names
355 that are long to type in, e.g. “mediumspringgreen”. The
356 optional second argument to XCOLOR allows you to come up with more
357 convenient name by which to reference the colour. For example, you
360 <span class="pre-in-pp">
361 .XCOLOR mediumspringgreen mygreen
364 <span class="pre-in-pp">
365 .XCOLOR mediumspringgreen MYGREEN
367 so that whenever you want text mediumspringgreen-ed, you
368 can use either <kbd>.COLOR mygreen</kbd> (or
369 <kbd>.COLOR MYGREEN</kbd>) or the inline escape
370 <kbd>\*[mygreen]</kbd> (or <kbd>\*[MYGREEN]</kbd>.)
373 <h3 id="xcolor-names" class="docs">Finding X color names</h3>
376 There are two ways of finding the names of the pre-defined X
377 colours. One is to consult the file, rgb.txt, included with all
378 X11 installations. The location of the file on a Debian GNU/Linux
379 distribution is typically /etc/X11/rgb.txt. Other distributions and
380 other X installations may have the file in another location. The
381 file lists the colour names, but doesn’t show you what the
382 colours actually look like.
386 A better way to get the colour names, as well as to see what the
387 colours look like, is to fire up a colour chooser (like xcolorsel)
388 that both lists the colour names and shows a swatch of the colour
393 Whichever method you use to find X color names, remember that the
394 names, passed as arguments to XCOLOR, must be all one word, all in
398 <div class="box-tip">
400 <span class="note">Note:</span>
401 Both the colorname and the alias you give to XCOLOR may be
402 used with groff’s <kbd>\m[<colorname>]</kbd>
403 inline escape (the <kbd>\m</kbd> escape is used to set
404 text and rule colours). Thus, assuming an X-colorname
405 “mediumspringgreen” set with XCOLOR, and an alias,
406 “mygreen”, <kbd>\*[mediumspringgreen]</kbd>,
407 <kbd>\m[mediumspringgreen]</kbd>, <kbd>\*[mygreen]</kbd> and
408 <kbd>\m[mygreen]</kbd> are all equivalent. Furthermore, both the
409 colorname and the alias can be given as an argument to groff’s
410 <a href="definitions.html#primitives">primitive</a>
411 request, <kbd>.gcolor</kbd> (which does the same thing as
412 <kbd>\m[<colorname>]</kbd>).
415 <p class="tip-bottom">
416 The colorname initialized with XCOLOR <i>but not the
417 alias</i> may also be used with groff’s inline escape,
418 <kbd>\M[<colorname>]</kbd>, and the corresponding primitive,
419 <kbd>.fcolor</kbd>, both of which set the “fill” colour
420 for solid graphical objects. If you need a colour initialized with
421 XCOLOR for <kbd>\M</kbd> or <kbd>.fcolor</kbd>, you MUST give the
422 full colorname; the alias won’t work.
428 <div class="macro-id-overline">
429 <h3 id="color" class="macro-id">Invoking a color</h3>
432 <div class="box-macro-args">
433 Macro: <b>COLOR</b> <kbd class="macro-args"><colorname></kbd>
436 <p id="color-inline" class="requires" style="font-style: normal;">
437 Inline: <kbd>\*[<colorname>]</kbd>
441 Once you've told mom about a colour (via
442 <a href="#newcolor">NEWCOLOR</a>
444 <a href="#xcolor">XCOLOR</a>,
445 you use either the macro COLOR or the
446 <a href="definitions.html#inlines">inline escape</a>,
447 <kbd>\*[<colorname>]</kbd>, to cause mom to
448 set subsequent text in that colour. See the
449 <a href="#color-example2">example</a>,
450 above, which shows both in action.
453 <div class="box-tip">
455 <span class="note">Note:</span>
456 You can use the <kbd>\*[<colorname>]</kbd> inline escape in
458 <a href="docprocessing.html#top">document processing</a>
460 <a href="definitions.html#stringargument">string argument</a>.
461 However, you must remember to reset the colour at the end of the
462 argument (typically with <kbd>\*[black]</kbd>) unless you want all
463 subsequent invocations of that particular macro to be colourized.
467 Furthermore, if you use <kbd>\*[<colorname>]</kbd> in the
468 string argument passed to
469 <a href="docelement.html#head">HEAD</a>,
470 <a href="docelement.html#subhead">SUBHEAD</a>
472 <a href="docelement.html#parahead">PARAHEAD</a>,
473 and you've requested that any of these types of heads be numbered,
474 the numbers themselves will not be coloured, only the text you
475 passed the macro. If you wish the numbers to be colourized as well,
476 you must explicitly tell mom that you wish all of the head(s),
477 subhead(s) or parahead(s), including the numbers, colourized by
478 invoking the appropriate
479 <a href="docelement.html#docelement-control">control macro</a>.
482 <p class="tip-bottom">
483 For colorizing underscored text, see
484 <a href="goodies.html#underscore-color">Colorizing underscored text</a>
485 in the notes at the end of
486 <a href="goodies.html#underscore">UNDERSCORE</a>.
490 <div class="rule-long"><hr/></div>
492 <!-- Navigation links -->
493 <table style="width: 100%; margin-top: 12px;">
495 <td style="width: 33%;"><a href="toc.html">Back to Table of Contents</a></td>
496 <td style="width: 33%; text-align: center;"><a href="#top">Top</a></td>
497 <td style="width: 33%; text-align: right;"><a href="graphical.html#top">Next: Graphical objects</a></td>
503 <div class="bottom-spacer"><br/></div>