Difference between revisions of "Command/definepalet"

From Wiki
Jump to navigation Jump to search
(→‎Description: inserted note concerning syntax oddities)
m (Visualize example)
Line 49: Line 49:
  
 
== Example ==
 
== Example ==
<texcode>
+
<context source=yes>
 
\setupcolors [x11]
 
\setupcolors [x11]
 
\definepalet [colorful] [primary=green]
 
\definepalet [colorful] [primary=green]
Line 56: Line 56:
  
 
\setuppalet  [colorful]
 
\setuppalet  [colorful]
\color[primary]{Ain’t I a colorful entity?}
+
\color[primary]{Ain't I a colorful entity?}
  
 
\setuppalet  [bleak]
 
\setuppalet  [bleak]
\color[primary]{Ain’t I a colorful entity?}
+
\color[primary]{Ain't I a colorful entity?}
  
 
\stoptext
 
\stoptext
</texcode>
+
</context>
  
 
== See also ==
 
== See also ==

Revision as of 13:39, 12 May 2013

\definepalet

Syntax

\definepalet[...][...,...=...,...]
[...] name
name name


Description

Allows on-the-fly switching of whole sets of color name definitions.

NB \definepalet relies on a non-standard argument parser that does not tolerate trailing commas [1]. Therefore the following syntax is illegal:

\definepalet [foo] [
  first=red,
  second=green, %% <= will fail
]

Use common ConTeXt coding style instead:

\definepalet [foo]
 [first=green,
  second=red]

Alternatively, replace the comma with a comment character:

\definepalet [foo] [
  first=green,
  second=red%
]

Example

\setupcolors [x11]
\definepalet [colorful] [primary=green]
\definepalet [bleak]    [primary=darkgray]
\starttext

\setuppalet  [colorful]
\color[primary]{Ain't I a colorful entity?}

\setuppalet  [bleak]
\color[primary]{Ain't I a colorful entity?}

\stoptext

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: