\def\filedate{2003/12/28} \def\docdate{2003/12/28} \def\fileversion{1.00} \def\basename{spectrum} % % \iffalse meta-comment % % Package spectrum to use with LaTeX2e % Copyright 1998-2003 by Wolfgang May. All rights reserved. % % This package is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. % % Written and maintained by % Wolfgang May % % IMPORTANT NOTICE: % % Error Reports in case of UNCHANGED versions to % % Wolfgang May % Institut f"ur Informatik, Universit"at G"ottingen % e-mail: may@informatik.uni-goettingen.de % % You are not allowed to change this file. % % You are allowed to distribute this file under the condition that % it is distributed UNCHANGED. You are NOT ALLOWED to take money for % the distribution or use of either this file or a changed version, % except for a nominal charge for copying etc. % \fi % % \CheckSum{910} %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z %% Digits \0\1\2\3\4\5\6\7\8\9 %% Exclamation \! Double quote \" Hash (number) \# %% Dollar \$ Percent \% Ampersand \& %% Acute accent \' Left paren \( Right paren \) %% Asterisk \* Plus \+ Comma \, %% Minus \- Point \. Solidus \/ %% Colon \: Semicolon \; Less than \< %% Equals \= Greater than \> Question mark \? %% Commercial at \@ Left bracket \[ Backslash \\ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} % % \RecordChanges % \changes{v1.00}{98/07/10}{First version} % \changes{v1.00}{03/12/28}{Some changes (address)} % % \MakeShortVerb{\|} % \makeatletter % \def\packeddescr{% % \begin{list}{}{\leftmargin0.5cm % \labelwidth\z@\itemindent-\leftmargin % \topsep=0pt\itemsep=0.05cm\parsep=0.05cm % \let\makelabel\nlabel}} % \def\nlabel#1{#1\hfill} % \def\nlist#1{\begin{list}{}{\settowidth\labelwidth{#1}% % \setlength\leftmargin\labelwidth % \addtolength\leftmargin\labelsep % \let\makelabel\nlabel}} % \def\endnlist{\end{list}} % \def\endpackeddescr{\end{list}} % % \def\Codelabel#1{\@bsphack % \protected@write\@auxout{}{\string\newlabel{#1}{{\number\the % \c@CodelineNo}{\thepage}}}\@esphack} % \newcounter{tmpcount} % \def\Coderef#1#2{\setcounter{tmpcount}{0}\@ifundefined{r@#1}\relax % {\setcounter{tmpcount}{\ref{#1}}}\relax % \addtocounter{tmpcount}{#2}\arabic{tmpcount}} % \makeatother %\title{\fadeletters[70][0]{Spectrum}\black} % \author{Wolfgang May\\ % Institut f\"ur Informatik, \\ % Universit\"at G"ottingen \\ % Germany \\ % \small\texttt{may@informatik.uni-goettingen.de}} % \date{\filedate} %\maketitle %\begin{abstract} % \noindent % The \specletters[50][70]{Spectrum}\black\ style allows % \specletters[0][100]{running colors}\black\ following the % \emph{hsb (hue-saturation-brightness)} color model or % \fadeletters[10][80]{fading out}\black\ and % \fadeletters[80][10]{fading in}\black\ in a text. % In addition to change the color with every letter, it is possible % to change it with every word, every \emph{group}, every line, % or with every line in a tabular. The style requires the dvips % package. %\end{abstract} % %\section{The Functionality and Commands} %\black % % Typesetting text with % \specletters[0][100]{running}\black\ or % \fadeletters[10][80]{fading}\black\ letters is achieved by % following a path through the \emph{hsb (hue-saturation-brightness)} % color model: By changing the \emph{hue} value with constant % saturation and brightness, the colors run through the optical % spectrum (i.e.\ the rainbow colors). When changing the % \emph{brightness} value with constant hue and saturation, % a color fades in and out. % % The user interface is surprisingly simple: the style provides % principally $2\cdot 6 = 12$ commands with a closely related % syntax: Text passages can be either % \specletters[0][100]{spectrum}\black\ or % \fadeletters[10][80]{faded}\black\ by the commands % \begin{itemize} % \item |\spec|\meta{granularity}|{|\meta{text}|}| where % \meta{granularity} gives the granularity of coloring steps: % letters, words, or expressions (i.e.\ \LaTeX\ groups) in % which the coloring of \meta{text} changes, % \item |\begin{speclines}| \ldots |\end{speclines}| where % the text in-between is colored a new color with every line, % \item |\begin{spectabular}[|\meta{pos}|]{|\meta{column-spec}|}| % \ldots |\end{spectabular}| or % \item |\begin{specarray}[|\meta{pos}|]{|\meta{column-spec}|}| % \ldots |\end{specarray}| where a tabular or arry is typeset % with changing the color with every line. % \item The analogous commands |\fade|\meta{granularity} provide % fading colors. % \end{itemize} % % Additionally, up to three optional arguments can be given to % specify the range and stepwidth of colors: % % \begin{itemize} % \item In the following, $c_1$, $c_1$, and $s$ are natural numbers. % The spectrum is mapped to the range from 0 (red) to 100 (again, red). % For fading, 0 means black (no brightness) and 100 means white % (very bright). % \item |\specletters[|$c_1$|][|$c_2$|]{|\meta{text}|}|: % The coloring starts by $c_1$ and finally reaches $c_2$ at the % end of the text. The stepwidth is computed by dividing the % specified range by the number of steps which is automatically % computed by analyzing \meta{text}. This can only be done % for granularity \emph{letters}, \emph{words} and \emph{expressions}. % \item |\specletters[|$c_1$|][|$\pm s$|]{|\meta{text}|}|: % The coloring starts by $c_1$ and is increased/decreased by $s$ with every % step. The hsb-color palette is passed through cyclically. % \item |\specletters[|$c_1$|][|$c_2$|][|$\pm s$|]{|\meta{text}|}|: % The coloring starts by $c_1$ and is increased/decreased by $s$ with every % step. When $c_2$ is reached, the direction is inverted. Thus, % the coloring alternates inside the given scope. % \end{itemize} % % In addition, the current color is always accessible by pstricks' % color setting commands as |linecolor| or |fillcolor|. Although, % when a spectrum command is active, |linecolor| is automatically set to % the current color. Thus, this feature is mainly needed for % fillcolor (see example later). % % Moreover, |\spectrumcolorval| outputs the current value of hue % or saturation, dependent on which parameter is running. % %\paragraph{Letters.}\ \\ % |\specletters[50][90]{specletters is very ...}| % \specletters[50][90]{specletters is very easy: the color % is incremented with every letter. Note that spaces do not add an % additional step.} On the other hand, one should not forget to % reset the color with \black|\black| after the end of the % spectrum's scope (if needed). % |\specletters[90][50]{it can also ...}| % \specletters[90][50]{it can also be run downwards}. \black In addition, % since the spectrum's text is shorter, the steps have been bigger.\black % %\paragraph{Words.}\ \\ % |\specwords[10][-5]{Now ...}|\specwords[10][-5]{Now, every % word is set with the same color, the color is changed between % the words. If the text is long enough, the color range is passed % cyclically, returning to red and entering another round.}\black % %\paragraph{Expressions}\ \\ % |\specexpr[50][80][+5]{{now,} {every expression} {is}|\\ % |{typeset} {with} {the} {same} {color.} {It} {also} {allows}| % |{\LaTeX}|\\ % |{commands} {inside} {the} {spectrum} {text.}}| % \specexpr[50][80][+5]{{now,} {every expression} {is} % {typeset} {with} {the} {same} {color.} {It} {also} % {allows} {\LaTeX} {commands} {inside} {the} {spectrum} {text.}} % \black Additionally, this paragraph it shows that the color % now moves up and down inside the specified range. % % |\specexpr[50][80][+5]{if there are no groups, every letter and every|\\ % |space is treated as an expression.}| % \specexpr[50][80][+5]{if there are no groups, every letter and every % space is treated as an expression.}\black % % The latter is especially useful when typesetting non-english texts: % many languages have \emph{umlauts} which produce errors with % |\specletters|. See the later examples. % %\paragraph{Lines}\ \\ % |\begin{speclines}[40][60][+4]| % \begin{speclines}[40][60][+4] % In this paragraph, every line is typeset in another color. Note % that a fixed stepwidth is given and the colors move up and down % the specified range. This is done automatically by a modified % output routine. % % |\end{speclines}[40][60][+4]| % \end{speclines}\black % %\paragraph{Tabular} % %The following table is typeset by ... % % |\begin{spectabular}[38][-2][t]{llrrrrrr}| \\ % |1. BV 09 Borussia Dortmund & 34 & 19 & 11 & 4 & 76-38 & +38 & 68 \\|\\ % \vdots \\ % |18. Krefelder FC Uerdingen & 34 & 5 & 11 & 18 & 33-56 & -23 & 26 \\|\\ % |\end{spectabular}|. % \footnote{\specwords[50][80]{In Germany, the last three teams are % relegated. Kaiserslautern managed to be re-promoted the subsequent % year and become champion two years later, i.e.\ in 1998.}} % %\begin{spectabular}[36][-2][t]{llrrrrrr} % 1. BV 09 Borussia Dortmund & 34 & 19 & 11 & 4 & 76-38 & +38 & 68 \\ % 2. FC Bayern M\"unchen & 34 & 19 & 5 & 10 & 66-46 & +20 & 62 \\ % 3. FC Schalke 04 & 34 & 14 & 14 & 6 & 45-36 & + 9 & 56 \\ % 4. Borussia M\"onchengladbach &34 & 15 & 8 & 11 & 52-51 & + 1 & 53 \\ % 5. Hamburger SV & 34 & 12 & 14 & 8 & 52-47 & + 5 & 50 \\ % 6. FC Hansa Rostock & 34 & 13 & 10 & 11 & 47-43 & + 4 & 49 \\ % 7. Karlsruher SC & 34 & 12 & 12 & 10 & 53-47 & + 6 & 48 \\ % 8. TSV M\"unchen 1860 & 34 & 11 & 12 & 11 & 52-46 & + 6 & 45 \\ % 9. SV Werder Bremen & 34 & 10 & 14 & 10 & 39-42 & - 3 & 44 \\ %10. VfB Stuttgart & 34 & 10 & 13 & 11 & 59-62 & - 3 & 43 \\ %11. SC Freiburg & 34 & 11 & 9 & 14 & 30-41 & -11 & 42 \\ %12. 1. FC K\"oln & 34 & 9 & 13 & 12 & 33-35 & - 2 & 40 \\ %13. TSV Fortuna D\"usseldorf & 34 & 8 & 16 & 10 & 40-47 & - 7 & 40 \\ %14. TSV Bayer 04 Leverkusen & 34 & 8 & 14 & 12 & 37-38 & - 1 & 38 \\ %15. FC St. Pauli Hamburg & 34 & 9 & 11 & 14 & 43-51 & - 8 & 38 \\ %16. 1. FC Kaiserslautern & 34 & 6 & 18 & 10 & 31-37 & - 6 & 36 \\ %17. Eintracht Frankfurt & 34 & 7 & 11 & 16 & 43-68 & -25 & 32 \\ %18. Krefelder FC Uerdingen & 34 & 5 & 11 & 18 & 33-56 & -23 & 26 \\ %\end{spectabular}\black % % \paragraph{Optional Arguments.} % If some of the optional arguments are missing, the values of the % previous call to |\spectrum| or |\fade| are used. Here, especially % the case that \emph{no} argument is given -- i.e.\ there is even no % starting value -- is of interest: Then, the current value is used, and % the previous sequence is continued, either cyclic or alternating. % % |\specletters[20][+1]{This sequence rund from light green into|\\ % |dark blue.}| % \specletters[20][+1]{This sequence starts runs from light green into % dark blue. }\black % The next sequence also uses umlauts, continuing the color sequence from % the first one: % |\specexpr{{C'}est une suite de bleu fonc{\'e} {\`a} rouge}.| % \specexpr{{C'}est une suite de bleu fonc{\'e} {\`a} rouge}. % \black It can be continued % |\specexpr{bis schlie{\ss}lich|\\ % |wieder gr{\"u}n erreicht ist.}| % \specexpr{bis schlie{\ss}lich wieder gr{\"u}n erreicht ist.}\black\\ % |\specexpr{Since the primary statement yielded to a cyclic| % |coloring,|\\ % |this is continued through the other sequences.| % \specexpr{Since the primary % statement yielded to a cyclic coloring, this is continued % through the other sequences.}\black % % The same can be done with alternating sequences: % |\specexpr[60][100][+4]{Det| % |{\"a}r en f{\"o}ljd som alltid alternerar | % |mellan bl{\aa} och r{\"o}{d.}}| % \specexpr[60][100][+4]{Det {\"a}r en f{\"o}ljd som alltid alternerar % mellan bl{\aa} och r{\"o}{d. }} % \black % |\specletters{and it can|\\ % |be continued later, still alternating with the same scope.}| % \specletters{and it can be continued later, still alternating % with the same scope. }\black % % % If only one argument is given, it is taken as a new initial value, % retaining the scope of the previous command: % |\specletters[80]{e.g., starting again with pink|\\ % |and alternating between blue and red.}| % \specletters[80]{e.g., starting again with pink and alternating % between blue and red. }\black % % If the initial sequence is given by its start and end % value, i.e.\ % |\specletters[40][70]{the|\\ % |stepwidth is computed automatically}|, % \specletters[40][70]{the stepwidth is computed automatically}, % \black % |\specletters{the continuation alternates between these values| % |with the|\\ % |computed stepwidth.}| % \specletters{the continuation alternates between these values % with the computed stepwidth. }\black % % |\specletters[30][+3]{A cyclic sequence can also be continued}| % \specletters[30][+3]{A cyclic sequence can also be continued.} \black % |\specletters[60]{The continuation starts| % |with the new value (60=blue), using the same stepwidth.}| % \specletters[60]{The continuation starts with the new value % (60=blue), using the same stepwidth. }\black % % \bigskip % % |\specexpr| is of special interest for coloring elements of figures % for presentations. The following is taken from a PhD thesis on % active database languages at our chair.\label{page-Statelog-figure} % %{\psset{arrowsize=2pt 3} %\psset{nodesep=3pt} %\psset{linewidth=2pt} %\newcommand{\block}{\rule[0.12em]{0.45em}{0.4em}} %\newcommand{\lefta}{\Rnode{l}{}~~~\Rnode{r}{}\ncline{<-}{l}{r}} %\newcommand{\righta}{\Rnode{xl}{}~~~\Rnode{xr}{}\ncline{->}{xl}{xr}} %\paragraph{The Spectre of Rule-Based Database Languages}\ \\ \bigskip %\specexpr[25][95] %{{\emph{Deductive Rules}}\hfill % {\emph{Production Rules}}\hfill % {\emph{Active Rules}}}\\\bigskip %\specexpr[25][95]{{\textbf{declarative}}\hfill{\textbf{procedural}}} \\\bigskip %{\psset{arrowsize=4pt 6}\psset{fillstyle=hlines} %\specexpr[25][95]{{\lefta}\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block{\righta}}}\black\\\bigskip %\specexpr[25][95] %{{\begin{tabular}{@{}c@{}} % S-Datalog\\ % WF-Datalog % \end{tabular}} % \dotfill % {\begin{tabular}{@{}c@{}} % RDL\\ % I-/P-Datalog % \end{tabular}} % \dotfill {A-RDL}\dotfill {Ariel} \dotfill {Starburst} \dotfill {Postgres} % }} % % \black % produced by the following source code: %\begin{verbatim} %\psset{arrowsize=2pt 3} %\psset{nodesep=3pt} %\psset{linewidth=2pt} %\newcommand{\block}{\rule[0.12em]{0.45em}{0.4em}} %\newcommand{\lefta}{\Rnode{l}{}~~~\Rnode{r}{}\ncline{<-}{l}{r}} %\newcommand{\righta}{\Rnode{xl}{}~~~\Rnode{xr}{}\ncline{->}{xl}{xr}} %\paragraph{The Spectre of Rule-Based Database Languages}\ \\\bigskip %\specexpr[25][95] %{{\emph{Deductive Rules}}\hfill % {\emph{Production Rules}}\hfill % {\emph{Active Rules}}}\\\bigskip %\specexpr[25][95]{{\textbf{declarative}}\hfill{\textbf{procedural}}} \\\bigskip %{\psset{arrowsize=4pt 6}\psset{fillstyle=hlines} %\specexpr[25][95]{{\lefta}\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block\block\block\block\block\block\block\block\block\block\block %\block{\righta}}}\black\\\bigskip %\specexpr[25][95] %{{\begin{tabular}{@{}c@{}} % S-Datalog\\ % WF-Datalog % \end{tabular}} % \dotfill % {\begin{tabular}{@{}c@{}} % RDL\\ % I-/P-Datalog % \end{tabular}} % \dotfill {A-RDL}\dotfill {Ariel} \dotfill {Starburst} \dotfill {Postgres} % }\end{verbatim} % % |\specexpr| is especially useful in combination with pstricks % commands: \vspace*{2cm} % %\psset{linewidth=0.4pt} %\begin{center} % \hspace*{4cm} % \specexpr[50][65]{% % {\psellipse(0,2)(0.8,0.6) % \rput{0}(0,2){\rnode{u0}{$\bullet$}} % \rput{0}(-0.4,1.6){\rnode{u11}{$\bullet$}} % \rput{0}(0.5,2){\rnode{u12}{$\bullet$}}} % {\psellipse(-0.2,1.9)(1.5,0.8) % \rput{0}(-1,2.2){\rnode{u21}{$\bullet$}} % \rput{0}(0.7,2.4){\rnode{u22}{$\bullet$}} % \rput{0}(1,1.9){\rnode{u23}{$\bullet$}}} % {\psellipse(-0.5,2.2)(2,1.2) % \rput{0}(-2,1.9){\rnode{u31}{$\bullet$}} % \rput{0}(0.3,2.9){\rnode{u32}{$\bullet$}} % \rput{0}(1.05,2.8){\rnode{u33}{$\bullet$}}} % {\psellipse(-1,2.1)(3,1.5) % \rput{0}(-3,3){\rnode{u41}{$\bullet$}} % \rput{0}(-3.2,1.2){\rnode{u42}{$\bullet$}} % \rput{0}(-2.5,2.9){\rnode{u43}{$\bullet$}} % \rput{0}(1.8,1.8){\rnode{u44}{$\bullet$}}}} % \hspace*{4cm} %\end{center} % \specexpr[15][0]{% % {\ncarc{->}{u0}{u11} % \ncarc{->}{u0}{u12}} % {\ncarc{->}{u11}{u21} % \ncarc{->}{u12}{u22} % \ncarc{->}{u12}{u23}} % {\ncarc{->}{u21}{u31} % \ncarc{->}{u21}{u33} % \ncarc{->}{u22}{u33} % \ncarc{->}{u23}{u33} % \ncarc{->}{u22}{u32}} % {\ncarc{->}{u31}{u41} % \ncarc{->}{u31}{u42} % \ncarc{->}{u31}{u43} % \ncarc{->}{u33}{u44}}} % % % % \specexpr[0][100]{% % {\[\rnode{center}{\bullet}\]} % \SpecialCoor % {\uput{5cm}[20]{0}(center)% % {\psframebox[linecolor=black,fillcolor=spectrumcolor]{\black I}}} % {\uput{5cm}[40]{0}(center)% % {\psframebox[linecolor=black,fillcolor=spectrumcolor]{\black I}}} % \NormalCoor} % \vspace*{5cm} % \subsection{Shortcomings and Incompatibilities} % % If a spectrum sequence distributes over two pages and a footnote % appears on the first of those pages, the footnote % is colored instead of the first letter of appearing on the % next page. % % Since for |\speclines|, the output routine is modified, there % are many incompatibilities. % % % \section{Code Documentation}\label{sec:code} % \iffalse % \subsection{The documentation driver file} % % The next bit of code contains the documentation driver file for % \TeX{}, i.e., the file that will produce the documentation you are % currently reading. It will be extracted from this file by the % \texttt{docstrip} program. Since it is the first code in the file % one can alternatively process this file directly with \LaTeXe{} to % obtain the documentation. % % \begin{macrocode} %<*driver> \documentclass{ltxdoc} \makeatletter \input{dvips.def} \input{dvipsone.def} \makeatother \usepackage{spectrum} \usepackage{pstricks,pst-node} \parindent0pt\hfuzz2pt \setlength{\textwidth}{360pt} \begin{document} \DocInput{spectrum.dtx} \end{document} % % \end{macrocode} %\fi % \section{Documentation of the Macros} % \setcounter{CodelineNo}{0} %\iffalse %<*package>\fi % \begin{macrocode} \typeout{Style `\basename', Version \fileversion\space <\filedate>} \ProvidesPackage{spectrum}[\filedate \space\fileversion] % \end{macrocode} % % The color is set by generating raw postscript output, here, % commands of the form |h s b sethsbcolor| where |h| (hue), |s| % (saturation), and |b| (brightness) are values between 0 and 1. % The internal granularity of color/saturation/brightness is 10000. % % \setcounter{CodelineNo}{0} % \begin{macrocode} \let\eop=\par \newcount\spec@currentcolor\global\spec@currentcolor -1 \newcount\spec@currentsatur\global\spec@currentsatur 9999 \newcount\spec@currentbright\global\spec@currentbright 9999 % \end{macrocode} % % Setting default values: color=-1 means black/white. % Saturation 9999 means at least 1, thus full color saturation; % analogous for brightness. % % \begin{macrocode} \newcount\spec@colorval \newcount\spec@startvalue\global\spec@startvalue 0 \newcount\spec@endvalue\global\spec@endvalue 10000 \newcount\spec@leap \newcount\exprlength \newcount\@tempcnt \newtoks\spec@tabpos\spec@tabpos{c} \newif\ifspec@cyclic\global\spec@cyclictrue \def\spec@thespace{ } % \end{macrocode} % % \subsection{Parsing the \LaTeX\ Source} % % \begin{macrocode} \def\spectrum@lines@string{lines} \def\spectrum@tabular@string{tabular} % \end{macrocode} % % \Codelabel{spectrum} % \begin{macrocode} \def\spectrum#1{\begingroup\obeyspaces \gdef\spec@what{color}% \global\spec@currentsatur 9999% \global\spec@currentbright 9999% \gdef\spec@granularity{#1}% \@ifnextchar[%] {\spec@read@firstarg}% {\spec@default@firstarg}} % \end{macrocode} % % Spaces are obeyed in the argument. % Calling |\spectrum| makes |color| the running parameter and sets % saturation and brightness to maximal. Granularity is set to ||. % If no optional argument is given, as a default, the current value of % the running parameter is taken. % % \Codelabel{fade} % \begin{macrocode} \def\fade#1{\begingroup\obeyspaces \gdef\spec@what{bright}% \ifnum\spec@currentcolor=-1\global\spec@currentsatur 0% \else\global\spec@currentsatur 9999\fi \gdef\spec@granularity{#1}% \@ifnextchar[%] {\spec@read@firstarg}% {\spec@default@firstarg}} % \end{macrocode} % % Analogous to |\spectrum|: Fading makes |brightness| the running % parameter. If color is black/white (-1), saturation is set to 0, % else to maximal (9999). % % \begin{macrocode} \def\spec@read@firstarg[#1]{% \ifcat#1\noexpand\the \global\csname spec@current\spec@what\endcsname=#1% \global\multiply\csname spec@current\spec@what\endcsname by100% \else \ifcat#19\global\csname spec@current\spec@what\endcsname=#1% \global\multiply\csname spec@current\spec@what\endcsname by100% \else\spec@check@tabular#1\fi\fi \spec@default@firstarg} % \end{macrocode} % % If the optional argument is |c|, |t|, or|b|, then it is due to % an array specification. In this case, |\spec@check@tabular| % is called (see line \Coderef{spectabular}{2}). % Else, the optional argument, multiplied by 100, gives the % |\spec@startvalue|. % The current value of the running parameter (given by |\spec@what|) % is set to |\spec@startvalue|. % % \begin{macrocode} \def\spec@default@firstarg{% \@ifnextchar[%] {\spec@read@secondarg}% {\spec@exec}}% % \end{macrocode} % % If no other optional argument (providing either the upper bound of the % spectrum/brightness range) follows, the old value of |\spec@leap| is % taken as default value. % % \begin{macrocode} \def\spec@read@secondarg[%] {\global\spec@cyclictrue \@ifnextchar+{\spec@read@stepsize}% {\@ifnextchar-{\spec@read@stepsize}% {\@ifnextchar c{\spec@read@tabpos}% {\@ifnextchar t{\spec@read@tabpos}% {\@ifnextchar b{\spec@read@tabpos}{\spec@read@scope}}}}}}% % \end{macrocode} % % Again, we have to take care about optional tabular positioning. % Otherwise, it is checked if a positive or negative step amount is % given (branching to |\spec@read@stepsize|). % If no, the optional parameter gives an upper bound of the % range of the running parameter (branching to |\spec@read@scope|). % % \begin{macrocode} \def\spec@read@tabpos#1]{\spec@check@tabular{#1}\spec@exec} % \end{macrocode} % % In case of a tabular positioning argument, it is read and % |\spec@check@tabular| is called (see line \Coderef{spectabular}{2}). % % \begin{macrocode} \def\spec@read@scope#1]{% \global\spec@startvalue\csname spec@current\spec@what\endcsname \global\spec@endvalue=#1% \global\multiply\spec@endvalue by100% \global\spec@cyclicfalse \@ifnextchar[%] {\spec@read@leap}% {\spec@calc@leap}} % \end{macrocode} % % Otherwise, the optional argument, multiplied by 100, gives the upper % bound of the range of the running parameter; in this case, the % spectrum is not cyclic but has to change its running direction when % reaching one of the bounds. % % If another optional argument follows, this gives the stepwidth or % is a tabular positioning argument, else, % the stepwidth is computed using the length of the spectrum text. % % \begin{macrocode} \def\spec@read@leap[%] {\@ifnextchar+{\spec@read@stepsize}% {\@ifnextchar-{\spec@read@stepsize}% {\@ifnextchar c{\spec@read@tabpos}% {\@ifnextchar t{\spec@read@tabpos}% {\@ifnextchar b{\spec@read@tabpos}% {\PackageError{\basename}{+/- required in third opt arg}\@ehc}}}}}} % \end{macrocode} % % Checking if the argument gives a tabular positioning or a stepwidth. % % \begin{macrocode} \def\spec@read@stepsize#1]{% \global\spec@leap=#1% \global\multiply\spec@leap by100% \spec@exec} % \end{macrocode} % % Stepwidth is multiplied internally by 100, and the spectrum % typesetting is started by calling |\spec@anyth@exec|. % % \begin{macrocode} \def\spec@calc@leap#1{% \ifx\spec@granularity\spectrum@lines@string {\PackageError{\basename}{Scope with lines requires stepsize}\@ehc}\fi \ifx\spec@granularity\spectrum@tabular@string {\PackageError{\basename}{Scope with tabular requires stepsize}\@ehc}\fi \spec@scope@calc@leap{#1}% \spec@exec{#1}} % \end{macrocode} % % This is executed if a range but no stepwidth is give, In this cases, % the stepwidth is computed using the length of the spectrum text. This % is not possible for granularity ``lines'' or ``tabular''. % Otherwise, the stepwidth is computed and the spectrum typesetting is % started. % % \begin{macrocode} \def\spec@exec{% \spec@sethsb \csname spec@\spec@granularity GoOn\endcsname} % \end{macrocode} % % At first, the current hsb-color is set, then the typesetting is % started with the appropriate granularity. % % \begin{macrocode} \def\spec@End#1{\endgroup}% % \end{macrocode} % % at the end, the |groupp| must be closed, and one character must be % thrown away. % % \begin{macrocode} \def\spec@scope@calc@leap#1{% \exprlength=0% \csname cardinality@\spec@granularity\endcsname#1\eop \spec@leap\spec@endvalue \advance\spec@leap by -\spec@startvalue \global\divide\spec@leap by\exprlength} % \end{macrocode} % % \begin{macrocode} \def\endcardinality#1{} % \end{macrocode} % % Again, at the end, one character must be thrown away. % % \subsection{Generating postscript output} % % \begin{macrocode} \@ifundefined{Raw@PS}{\def\Raw@PS{\Gin@PS@raw}}{\relax} % \end{macrocode} % % supplies for compatibility with old versions of dvips. % % \begin{macrocode} \def\spec@setvalue#1{.\ifnum\csname#1\endcsname<1000 0\fi \ifnum\csname#1\endcsname<100 0\fi \ifnum\csname#1\endcsname<10 0\fi \the\csname#1\endcsname 0} % \end{macrocode} % % Given a value $n$ between 0 and 9999, this produces the output % $n/10000$ in decimal, for evaluation by the |sethsbcolor| command % of postscript. % % \begin{macro}{\sethsb} % \Codelabel{sethsb} % \begin{macrocode} \def\spec@sethsb{% \begingroup \@tempcnt\spec@currentcolor \divide\@tempcnt by 10000% \multiply\@tempcnt by -10000% \advance\@tempcnt by \spec@currentcolor \spec@currentcolor\@tempcnt \ifnum\spec@currentcolor=-1\spec@currentcolor0\fi% \@tempcnt\spec@currentbright \divide\@tempcnt by 10000% \multiply\@tempcnt by -10000% \advance\@tempcnt by \spec@currentbright \spec@currentbright\@tempcnt \Raw@PS{% \spec@setvalue{spec@currentcolor} \spec@setvalue{spec@currentsatur} \spec@setvalue{spec@currentbright} sethsbcolor}% \global\def\color@spectrumcolor{% \spec@setvalue{spec@currentcolor} \spec@setvalue{spec@currentsatur} \spec@setvalue{spec@currentbright} sethsbcolor}% \endgroup \psset{linecolor=spectrumcolor} \global\spec@colorval=\the\csname spec@current\spec@what\endcsname \divide\spec@colorval by 100} \def\spectrumcolorval{\the\spec@colorval} % \end{macrocode} % % % \begin{packeddescr} % \item[Lines \Coderef{sethsb}{1}--\Coderef{sethsb}{12}:] % Locally calculates values of hue and brightness modulo % 10000. % |\spec@currentcolor=-1| is the black/white switch -- % any nonnegative hue value does the work saturation is 0 then. % \item[Lines \Coderef{sethsb}{13}--\Coderef{sethsb}{18}:] % produces output of the form |h s b sethsbcolor| % to be interpreted by postscript % \item[Lines \Coderef{sethsb}{19}--\Coderef{sethsb}{23}:] % defines |\color@spectrumcolor| to do exactly this when % called. |\color@spectrumcolor| is e.g.\ called by % |linecolor=spectrumcolor| in pstricks, thus making the % current color also accessible for pstricks commands. % \item[Line \Coderef{sethsb}{24}:] % sets the pstricks attribute linecolor to the current % color. % \item[Lines \Coderef{sethsb}{25},\Coderef{sethsb}{26}:] % sets |\spec@colorval| to the current color value with % granularity 100. % \item[Line \Coderef{sethsb}{27}:] % makes the current color value accessible to the user % in the |\spectrumcolorval| counter. % \end{packeddescr}\end{macro} % % \begin{macro}{\step} % % makes a step in the spectrum. % % \Codelabel{step} % \begin{macrocode} \def\spec@step{% \global\advance\csname spec@current\spec@what\endcsname by\spec@leap% \ifspec@cyclic \ifnum\csname spec@current\spec@what\endcsname<0% \global\advance\csname spec@current\spec@what\endcsname by 10000\fi \ifnum\csname spec@current\spec@what\endcsname>9999% \global\advance\csname spec@current\spec@what\endcsname by -10000\fi \else \ifnum\spec@leap<0% \ifnum\csname spec@current\spec@what\endcsname<\spec@endvalue% \global\spec@leap-\spec@leap \global\advance\csname spec@current\spec@what\endcsname by \spec@leap \global\advance\csname spec@current\spec@what\endcsname by \spec@leap \spec@swapstartend \fi\fi \ifnum\spec@leap>0% \ifnum\csname spec@current\spec@what\endcsname>\spec@endvalue% \global\spec@leap-\spec@leap \global\advance\csname spec@current\spec@what\endcsname by \spec@leap \global\advance\csname spec@current\spec@what\endcsname by \spec@leap \spec@swapstartend \fi\fi \fi \spec@sethsb} % \end{macrocode} % \begin{packeddescr} % \item[Line \Coderef{step}{2}:] increments color or brightness by % |\spec@leap|. % \item[Lines \Coderef{step}{3}--\Coderef{step}{18}:] if the values % are not intended to be cyclic, it must be checked if the end value % is already reached. If so, the sign of |\spec@leap| is inverted % (changing the direction) and start and end value are swapped. % \item[Lines \Coderef{step}{19}--\Coderef{step}{24}:] checks the % range to be between 0 and 9999. % \end{packeddescr} % % \begin{macrocode} \def\spec@swapstartend{\@tempcnta\spec@endvalue \global\spec@endvalue\spec@startvalue \global\spec@startvalue\@tempcnta} % \end{macrocode} % \end{macro} % % macro to exchange start and end value. % % \subsection{Granularity: Expressions} % % \begin{macrocode} \def\specexpr{\spectrum{expr}} \def\fadeexpr{\fade{expr}} % \end{macrocode} % % \begin{macrocode} \def\cardinality@expr{\take@expr@next} \def\take@expr@next{\futurelet\nextToken\take@@expr@next} \def\take@@expr@next{% \ifx\nextToken\eop \advance\exprlength by-1\let\nextaction\endcardinality\else \let\nextaction=\take@@@expr@next \advance\exprlength by1\fi \nextaction} \def\take@@@expr@next#1{% \ifx#1\spec@thespace\advance\exprlength by-1\fi \take@expr@next} % \end{macrocode} % % Count the number of expressions in the spectrum scope by a loop. % % \begin{macrocode} \def\spec@exprGoOn#1{\spec@exprDoIt#1\eop} \def\spec@exprDoIt{\futurelet\nextToken\spec@exprLookAtToken} \def\spec@exprLookAtToken{% \ifx\nextToken\eop\let\nextaction=\spec@End\else \let\nextaction=\spec@exprOutputAndNextExpr\fi \nextaction}% % \end{macrocode} % % Separate the spectrum expressions. Every expression is typeset % by |\spec@exprOutputAndNextExpr|. % % \begin{macrocode} \def\spec@exprOutputAndNextExpr#1{#1% \ifx#1\spec@thespace\else\spec@step\fi \spec@exprDoIt} % \end{macrocode} % % Typeset the expression, if it is not a space, take the next color % and go on. This ignores spaces not always correctly. % % \subsection{Granularity: Words} % \begin{macrocode} \def\specwords{\spectrum{words}} \def\fadewords{\fade{words}} % \end{macrocode} % % \begin{macrocode} \def\cardinality@words{\take@words@next} \def\take@words@next{\futurelet\nextToken\take@@words@next} \def\take@@words@next{% \ifx\nextToken\eop\let\nextaction\endcardinality\else \let\nextaction=\take@@@words@next \ifcat a\nextToken\else \ifcat -\nextToken\else \advance\exprlength by1\fi\fi\fi \nextaction} \def\take@@@words@next#1{\take@words@next} % \end{macrocode} % % Count the number of words in the spectrum scope by a loop. % % \begin{macrocode} \def\spec@wordsGoOn#1{\spec@wordsDoIt#1\eop} \def\spec@wordsDoIt{\futurelet\nextToken\spec@wordsLookAtToken} \def\spec@wordsLookAtToken{% \ifx\nextToken\eop\let\nextaction=\spec@End\else \ifcat a\nextToken\let\nextaction=\spec@wordsOutput\else \ifcat -\nextToken\let\nextaction=\spec@wordsOutput\else \let\nextaction=\spec@wordsNextWord\fi\fi\fi \nextaction}% % \end{macrocode} % % Separate the spectrum words. Every single letter is typeset % by |\spec@wordsOutput|. At the end of a word, % |\spec@wordsNextWord| is called. % % \begin{macrocode} \def\spec@wordsOutput#1{#1\spec@wordsDoIt} \def\spec@wordsNextWord#1{#1\spec@step\spec@wordsDoIt} % \end{macrocode} % % |\spec@wordsOutput| typesets a single letter. % |\spec@wordsNextWord| is called at the end of a word, typesetting % the current symbol (in general, this is a space) and taking the % next color. % % \subsection{Granularity: Letters} % % \begin{macrocode} \def\specletters{\spectrum{letters}} \def\fadeletters{\fade{letters}} % \end{macrocode} % % \begin{macrocode} \def\cardinality@letters{\take@letters@next} \def\take@letters@next{\futurelet\nextToken\take@@letters@next} \def\take@@letters@next{% \ifx\nextToken\eop \advance\exprlength by-1\let\nextaction\endcardinality\else \let\nextaction=\take@@@letters@next \ifcat a\nextToken\advance\exprlength by1\else \ifcat -\nextToken\advance\exprlength by1\fi\fi\fi \nextaction} \def\take@@@letters@next#1{\take@letters@next} % \end{macrocode} % % Count the number of letters in the spectrum scope by a loop. % % \begin{macrocode} \def\spec@lettersGoOn#1{\spec@lettersDoIt#1\eop} \def\spec@lettersDoIt{\futurelet\nextToken\spec@lettersLookAtToken} \def\spec@lettersLookAtToken{% \ifx\nextToken\eop\let\nextaction=\spec@End\else \ifcat a\nextToken\let\nextaction=\spec@lettersOutput\else \ifcat -\nextToken\let\nextaction=\spec@lettersOutput\else \let\nextaction=\spec@lettersNextWord\fi\fi\fi \nextaction}% % \end{macrocode} % % Handle individual letters. Every single letter is typeset % by |\spec@lettersOutput|. At the end of a word, % |\spec@lettersNextWord| is called. % % \begin{macrocode} \def\spec@lettersOutput#1{#1\spec@step\spec@lettersDoIt} \def\spec@lettersNextWord#1{ \spec@lettersDoIt} % \end{macrocode} % % |\spec@lettersOutput| takes the next color and typesets a single letter. % |\spec@lettersNextWord| is called at the end of a word, typesetting % the current symbol (in general, this is a space), not taking the % next color. % % \subsection{Granularity: Lines} % The following is adapted from |lineno.sty|: % % \begin{macrocode} \def\speclines{\spectrum{lines}} \def\fadelines{\fade{lines}} % \end{macrocode} % % The colors have to be attached by the output % routine. We simply set the |\interlinepenalty| to -100000. % The output routine will be called after each line in the % paragraph, except the last, where we trigger by |\par|. % The |\spec@penalty| is small enough to compensate a bunch of % penalties (e.g., with |\samepage|). % % \begin{macrocode} \newcount\spec@penalty\spec@penalty=-100000 \mathchardef\spec@penaltypar=25000 % \end{macrocode} % % \begin{macro}{\output} % % So let's make a hook to |\output|, the direct way. The \LaTeX\ % macro |\@reinserts| puts the footnotes back on the page. % % \begin{macrocode} \output=\expandafter{% \expandafter \spec@LineBrTest \expandafter \if@tempswa \the\output \else \@reinserts \MakeLineStep \fi} % \end{macrocode} % \end{macro} % % The float mechanism inserts |\interlinepenalty|s during % |\output|. So carefully reset it before going on. Else % we get double color step on every float placed in % horizontal mode. % % Neither a |\linelabel| nor a |\marginpar| should % insert a penalty. Nor should any other % float. So let us suppress the |\interlinepenalty| % altogether with the |\@nobreak| switch. % % Since (ltspace.dtx, v1.2p)[1996/07/26], the |\@nobreaktrue| does % it's job globally. We need to do it locally here. % % \begin{macro}{LineBreakTest} % % \begin{macrocode} \def\my@nobreaktrue{\let\if@nobreak\iftrue} \def\spec@LineBrTest{% \ifnum\interlinepenalty<-\spec@penaltypar \advance\interlinepenalty-\spec@penalty \my@nobreaktrue \fi \@tempswatrue \ifnum\outputpenalty>-\spec@penaltypar\else \ifnum\outputpenalty>-175000\relax \@tempswafalse \fi \fi } % \end{macrocode} % \end{macro} % % put in the natural |\interlinepenalty|, except % after the last line. % % \begin{macro}{\MakeLineStep} % % \begin{macrocode} \def\MakeLineStep{\unvbox\@cclv \nointerlineskip \ifnum\outputpenalty=-\spec@penaltypar\else \@tempcnta\outputpenalty \advance\@tempcnta -\spec@penalty \penalty\@tempcnta \fi \spec@step\spec@sethsb} % \end{macrocode} % \end{macro} % % The line numbering is controlled via |\par|. \LaTeX\ % saved the \TeX-primitive |\par| in |\@@par|. We push it % one level further out, and redefine |\@@par| to insert % the |\interlinepenalty| needed to trigger the color step % And we need to allow pagebreaks after a paragraph. % % \begin{macrocode} \let\@@@par\@@par \def\spec@linepar{\ifvmode\@@@par\else\ifinner\@@@par\else \advance\interlinepenalty\spec@penalty \@@@par \penalty-\spec@penaltypar \kern\z@ \advance\interlinepenalty -\spec@penalty \fi\fi\everypar{\leavevmode\spec@sethsb}} % \end{macrocode} % % The basic commands to enable and disable color steps: % |\@par| and |\par| are only touched, when they are |\let| % to |\@@@par|/|\spec@linepar|. % % \begin{macro}{LinesGoOn} % % \begin{macrocode} \def\spec@linesGoOn{% \let\@@par\spec@linepar \ifx\@par\@@@par\let\@par\spec@linepar\fi \ifx\par\@@@par\let\par\spec@linepar\fi} % \def\endspeclines{\let\@@par\@@@par \ifx\@par\spec@linepar\let\@par\@@@par\fi \ifx\par\spec@linepar\let\par\@@@par\fi \spec@End{}} \let\endfadelines\endspeclines % \end{macrocode} % \end{macro} % % \subsection{Granularity: Arrays and Tabulars} % % \Codelabel{spectabular} % \begin{macrocode} \def\spectabular{\spec@tabpos{c}\spectrum{tabular}} \def\spec@check@tabular#1{% \spec@tabpos{#1}% \ifx\spec@granularity\spectrum@tabular@string\else {\PackageError{\basename}{[c/t/b] only allowed for tabular}\@ehc}\fi} % \end{macrocode} % % arguments |[c]|, |[t]|, and |[b]| can only occur for tabulars and arrays. % % \Codelabel{} % \begin{macrocode} \def\spec@tabularGoOn{\let\@halignto\@empty\spec@tabular} \def\spec@tabular{\leavevmode \hbox \bgroup $\let\@acol\@tabacol \let\@classz\@tabclassz \let\@classiv\@tabclassiv \let\\\@tabularcr\spec@tabarray} \def\spec@tabarray{\m@th \@ifnextchar[\spec@array{\spec@array[\the\spec@tabpos]}} % \end{macrocode} % % The original tabular/array environment is copied for the spectrum % variant. % % \Codelabel{specarray} % \begin{macrocode} \def\spec@array[#1]#2{% \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi \bgroup \setbox\@arstrutbox\hbox{% \vrule \@height\arraystretch\ht\strutbox \@depth\arraystretch \dp\strutbox \@width\z@}% \@mkpream{#2}% \edef\@preamble{% \ialign \noexpand\@halignto \bgroup \noexpand\spec@step %% inserted for spectrum style \@arstrut \@preamble \tabskip\z@skip \cr}% \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox \let\tabularnewline\\% \let\par\@empty \let\@sharp##% \set@typeset@protect \lineskip\z@skip\baselineskip\z@skip \@preamble} % \end{macrocode} % % Line \Coderef{specarray}{12} is added for the spectrum variant, % taking the next color with every linebreak. % % \begin{macrocode} \def\endspectabular{\endtabular\spec@End{}} % \end{macrocode} %\iffalse %\fi % % \section{Acknowledgements} % % The modification of the output routine is adapted from Stephan % B\"ottcher's \texttt{lineno.sty}. % In addition, I would % thank those people who answered my questions in the newsgroups % comp.text.tex and comp.lang.postscript, especially Denis Girou % who maintains this wonderful pstricks stuff. % The figure on page~\ref{page-Statelog-figure} is due to my % colleague Bertram Lud\"ascher's PhD thesis. % % \Finale \endinput % Local Variables: % TeX-command-default: "LaTeX" % TeX-master: t % End: % mode: latex