\def\fileversion{v1} \def\filedate{91/12/04} \immediate\write\sixt@@n{File: `color.sty' \fileversion\space <\filedate> (SPQR, from LL)} % Sebastian Rahtz % 5 Granary Court % St Andrewgate % York Y01 2JR % %spqr@uk.ac.soton.ecs % what this really is! %---------------------------------------- % COLOR.DOC, 21 March 1990 % derived from % PS-SLIDES DOCUMENT -- released 14 November 1989 % for SliTeX version 2.09 % Copyright (C) 1988 by Leslie Lamport % \typeout{`color' -- released <21 Mar 90>} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ABOUT THIS DOCUMENT STYLE % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This style puts \special commands in the .dvi file that, when printed % % on the proper color printer, produces colored output. It is currently % % configured to work when the .dvi file is run through the dvips program, % % or dvitops. See the case statement that follows. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % DIFFERENCES BETWEEN color.sty AND ORDINARY SLiTeX % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % * The \colors command is made a no-op. Colors that are not predefined % must be defined with the \newpscolor command (see below). % % * The \colorslides and \blackandwhite commands are the same, except that % \colorslides prints only slides and overlays, not notes. % % * The meaning of the \invisible declaration has been changed, as described % below. The old \visible command is the same as the new \white command. % % * The default page style is `plain'. (The alignment marks are no longer % of any use.) % % * The positioning of the body of the slide and the slide number have % been changed to accomodate the QMS printer's small effective page % size. % % Except for these differences, a SLiTeX input file prepared for the % ordinary `slides' style SHOULD work with the `ps-slides' style. There % are probably some SLiTeX commands that will interact incorrectly with % color-changing commands. These problems will be corrected when % reported. The most likely bug is a color declaration `escaping from % its scope', having a more global effect than it should. Such a problem % can be worked around by adding redundant color-changing commands. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % THE \special COMMAND % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % \@drawcolor produces a \special command that sets the printer's color % % to the RGB value indicated by the control sequences \@red, \@green, % % and \@blue. This command must be changed to customize the document % % style to work under other systems % % % \@ifundefined{driver@setup}% { \typeout{WARNING *** driver setup codes are unknown in this setup ***} \typeout{*** No color changes ***} \def\@drawcolor{} } { \typeout{Driver type \the\driver@setup} % 0. dvi2lj: no rotation possible % 1. dvi2ps (Les Carr) % 2. dvitops (James Clark) % 3. dvips (Tom Rokicki) \ifcase\driver@setup % case 0 not available \typeout{WARNING *** A color mechanism is not defined for this setup ***} \def\@drawcolor{} \or % case 1 \typeout{WARNING *** A color mechanism is not defined for this setup ***} \def\@drawcolor{} \or % case 2 (dvitops, Adobe-encoded) \newcount\regionno \def\@drawcolor{% \special{dvitops: begin \the\regionno}% \special{dvitops: rgbcolor \the\regionno\space \@red\space \@green\space \@blue}% \global\advance\regionno by 1 } \or % case 3 (dvips, Rokicki, virtual fonts) \def\@drawcolor{\special{ps: \@red\space \@green\space % \@blue\space setrgbcolor\space}} % \else % \typeout{WARNING *** This driver setup is unknown - no color mechanism ***} \def\@drawcolor{} \fi } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % NEW AND CHANGED COMMANDS % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % \newpscolor{\PUCE}{RED}{GREEN}{BLUE} % \renewpscolor{\PUCE}{RED}{GREEN}{BLUE} % % Define \PUCE to produce a new color with the indicated RGB values, % where RED, GREEN, and BLUE are decimal numbers between 0 and 1 % (inclusive). For example: % Black = [RED: 0, GREEN: 0, BLUE: 0] % White = [RED: 1, GREEN: 1, BLUE: 1] % Red = [RED: 1, GREEN: 0, BLUE: 0] % Light yellow = [RED: .5, GREEN: .5, BLUE: 0] % For \newpscolor \PUCE must not already be defined; for % \renewpscolor, it must already be defined (but not necessarily as a % color). % % % The following colors are predefined: % % \black, \red, \green, \blue, \yellow, \magenta, \cyan, \white % % For ordinary printers, which assume white paper, \white text is invisible. % Unlike in ordinary SLiTeX, color-changing commands can be used in % math mode. % % % \invisible % \visible % % Ordinary declarations of visibility of the text. Invisible text % is not printed. (TeX prints it in a font that whose letters are all % print as spaces.) % Visibility is independent of color, so you can have invisible red text, % visible green text, and even visible white text. (Visible white text % can be seen only when printed by a weird printer that prints on % nonwhite paper.) % % % \norestore % \restore % % The \norestore declaration inhibits the proper scoping of color % declarations, causing color declarations to act as if they were global. % The \restore command causes the current and future colors to become the % ones they would have been had there been no \norestore command. % Both \norestore and \restore are global declarations. Example: % % \black black {\green green % \norestore {\red red} red % \restore % green} % black % % The \norestore declaration is handy for color commands inside a tabbing % or tabular environment. However, there are some anomalies: % % * A \restore command inside a tabbing environment may not work exactly % as it should. Try putting the command immediately after a \=, \\, or % \>. % % * An \fbox, \framebox, or \frame command may do weird things in the % scope of a \norestore if there's a color declaration in its argument. % % * A \background may behave strangely inside the scope of a \norestore. % % % \background{\yellow}{TEXT} % % Typesets TEXT in an \mbox with a yellow box behind it. The yellow box % is the width of TEXT plus a border of width \bgborder around it. % % % \hollowbackground % \filledbackground % % A \hollowbackground declaration causes any \background command in its % scope to produce an outline, much like \fbox, instead of a filled box. % This is useful for checking the slides with Proof or on a % black-and-white printer. A \filledbackground declaration has the % opposite effect. % % % \nogray % % A declaration that makes every color other than \white be equivalent to % \black, and issues a \hollowbackground declaration % % \norestore and \restore % \def\norestore{\gdef\@aftergroup{}} \def\restore{\gdef\@aftergroup{\@drawcolor}\@drawcolor} % % \@setcolor{RED}{GREEN}{BLUE} sets the current RGB value within SLiTeX % and calls \@drawcolor to produce the PostScript commands to change % their values in the output. % \def\@setcolor#1#2#3{\edef\@red{#1}\edef\@green{#2}\edef\@blue{#3}\@drawcolor \aftergroup\@aftergroup} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % \newpscolor{\PUCE}{RED}{GREEN}{BLUE} : % defines \PUCE to produce a new color with the indicated RGB values. % \PUCE must not already be defined. % \renewpscolor{\PUCE}{RED}{GREEN}{BLUE} : % same as \newpscolor but assumes \PUCE is already defined. % \def\newpscolor#1#2#3#4{\newcommand{#1}{\@setcolor{#2}{#3}{#4}}} \def\renewpscolor#1#2#3#4{\renewcommand{#1}{\@setcolor{#2}{#3}{#4}}} %% DEFINE SOME STANDARD COLORS \newpscolor{\black}{0}{0}{0} \newpscolor{\red}{1}{0}{0} \newpscolor{\yellow}{1}{1}{0} \newpscolor{\magenta}{1}{0}{1} \newpscolor{\green}{0}{1}{0} \newpscolor{\cyan}{0}{1}{1} \newpscolor{\blue}{0}{0}{1} \newpscolor{\white}{1}{1}{1} % REDEFINE \colorslides SO IT PRODUCES ONLY SLIDES, NO NOTES, % AND WITHOUT ANY COLOR LAYER \def\colorslides#1{\newpage\setcounter{page}{0}\@bwtrue\@visibletrue \if@onlyslidesw \xdef\@doslidelist{\@doglslidelist}% \@setlimits\@doslidelist\@doslidelow\@doslidehigh\fi \xdef\@doglnotelist{999998,999999,999999}% \xdef\@donotelist{\@doglnotelist}% \@setlimits\@donotelist\@donotelow\@donotehigh\@onlynoteswtrue \normalsize\setcounter{slide}{0}\setcounter{overlay}{0}% \setcounter{note}{0}\@makingslidestrue\input #1\@makingslidesfalse} % REDEFINE \colors TO BE A NO-OP \def\colors#1{} % Change to bowels of tabular environment needed to fix a bug that occurs % when a color command occurs in the last element. % \def\@tabclassz{\ifcase \@lastchclass \@acolampacol \or \@ampacol \or \or \or \@addamp \or \@acolampacol \or \@firstampfalse \@acol \fi \edef\@preamble{\@preamble \ifcase \@chnum \hfil{\ignorespaces\@sharp\unskip}\hfil \or {\ignorespaces\@sharp\unskip}\hfil \or \hfil\hskip\z@ {\ignorespaces\@sharp\unskip}\fi}} % The following modify the tabbing environment to get the scope of the % color commands to be the same as for other declarations in a tabbing % environment. % \def\@startfield{\global\setbox\@curfield\hbox\bgroup\begingroup} \def\@stopfield{\endgroup\egroup} \def\@contfield{\global\setbox\@curfield\hbox\bgroup\begingroup \unhbox\@curfield} \def\visible{\@mmodetest\@visibletrue\@currsize\@currfont \white\ignorespaces} \let\visible=\visible \let\endvisible=\relax % The following modifies \fbox to make it work right with color commands. % However, \fbox, \framebox, and \frame will do weird things % if \norestore is in effect. % \long\def\fbox#1{\leavevmode\setbox\@tempboxa\hbox{#1}\@tempdima\fboxrule \advance\@tempdima \fboxsep \advance\@tempdima \dp\@tempboxa \hbox{\lower \@tempdima\hbox {\vbox{\if@visible \hrule \@height \else \vskip\fi\fboxrule \hbox{\if@visible\vrule \@width \else \hskip \fi\fboxrule \hskip\fboxsep \vbox{\vskip\fboxsep \box\@tempboxa\@aftergroup \vskip\fboxsep}\hskip \fboxsep \if@visible\vrule \@width\else\hskip \fi\fboxrule} \if@visible\hrule \@height \else \vskip \fi\fboxrule}}}} % The command \background{\yellow}{TEXT} typesets TEXT in an \mbox with a % yellow box behind it. The yellow box is the width of TEXT plus a % border of width \bgborder around it. % % The declaration \hollowbackground causes any \background command in its % scope to produce an outline, much like \fbox, instead of a filled box. % The declaration \filledbackground has the opposite effect. % % \newsavebox{\@bgbox} \newlength{\bgborder} \bgborder=3pt\relax \newif\if@hollowbg \@hollowbgfalse \newcommand{\hollowbackground}{\@hollowbgtrue} \newcommand{\filledbackground}{\@hollowbgfalse} \newcommand{\background}[2]{\sbox{\@bgbox}{#2}% \@tempdima=\ht\@bgbox \advance\@tempdima \dp\@bgbox \advance\@tempdima 2\bgborder \@tempdimb=\wd\@bgbox \advance\@tempdimb2\bgborder \makebox[0pt][l]{#1\raisebox{-\dp\@bgbox} {\raisebox{-\bgborder}{\if@hollowbg \frame{\invisible\rule{\@tempdimb}{\@tempdima}}\else \rule{\@tempdimb}{\@tempdima}\fi}}}% \hspace*{\bgborder}\box\@bgbox\@aftergroup{\hspace*{\bgborder}}} % \nogray is a declaration that converts every color other than \white % to be equivalent to \black, and issues a \hollowbackground declaration % \let\@@setcolor=\@setcolor \def\nogray{\def\@setcolor##1##2##3{\@@setcolor{0}{0}{0}} \def\white{\@@setcolor{1}{1}{1}}\hollowbackground } %% INITIALIZATION % \def\@red{0} \def\@green{0} \def\@blue{0} \gdef\@aftergroup{\@drawcolor} \@drawcolor % \endinput