% \iffalse meta-comment % -------------------------------------------------------------- % Part of the TeXPower bundle % Copyright (C) 1999-2004 Stephan Lehmke % Copyright (C) 2003-2005 Hans Fredrik Nordhaug % % This program is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License % as published by the Free Software Foundation; either version 2 % of the License, or (at your option) any later version. % % This program 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. See the % GNU General Public License for more details. % -------------------------------------------------------------- % % texpower.dtx,v 1.13 2005/04/09 23:37:36 hansfn Exp % % \fi % % \iffalse % %<*driver> \ProvidesFile{texpower.dtx} % %\NeedsTeXFormat{LaTeX2e} %\ProvidesPackage{texpower} %<*texpower> [2005/04/08 v0.2 Create Dynamic Presentations with LaTeX.] % % %<*driver> \documentclass{ltxdoc} \EnableCrossrefs \CodelineIndex \RecordChanges \usepackage{longtable} \usepackage[bookmarksopen,colorlinks]{hyperref} \begin{document} \DocInput{texpower.dtx} \end{document} % % % \fi % % \CheckSum{5957} % % \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 \~} % % \GetFileInfo{texpower.dtx} % % \DoNotIndex{\newcommand,\newenvironment} % % \title{The \textsf{texpower} package\thanks{This document % corresponds to \textsf{texpower}~\fileversion, dated \filedate.}} % \author{ Stephan Lehmke \\ \texttt{Stephan.Lehmke@cs.uni-dortmund.de}} % % \maketitle % % \tableofcontents % % \section{Introduction} % LaTeX Package for creating `dynamic' presentations. % % The user documentation is found in \texttt{manual.tex} and the FAQ. % Only the implementation documentation is covered in this document. % % The TeXPower Bundle can be found at |http://texpower.sourceforge.net/| % % \section{Disclaimer} % % This is still work in progress. % % During the subsequent error correction and extension of the % functionality, the syntax and implementation of the macros are % liable to change. % % Even though we are using dtx-files, these are still not fully % documented dtx-files. % % \StopEventually{\PrintChanges\PrintIndex} % % \section{Implementation} % % \changes{v0.0.1}{1999/10/26}{First pre-alpha version.} % % \changes{v0.0.2}{2000/02/15}{Squashing a bug...} % % \changes{v0.0.3}{2000/03/13}{Tidying up command syntax; adding some in-line documentation.} % % \changes{v0.0.4}{2000/03/17}{In-line documentation for the first pre-alpha version completed.} % % \changes{v0.0.5}{2000/03/17}{Fixed some problems with incompatible versions of hyperref (spotted % by Marc van Dongen). (Apr 14: this code no longer exists)} % % \changes{v0.0.6}{2000/03/20}{Added papersize settings. (Mar 28: these are now in fixseminar.sty)} % % \changes{v0.0.7}{2000/04/07}{Removed dependency on hyperref; added support for color emphasis; % respect the display option; now loading tpsettings.cfg and tpoptions.cfg; added \cs{bstep}, % \cs{switch}, \cs{rebstep}, \cs{reswitch}.} % % \changes{v0.0.7a}{2000/04/28}{\cs{pause} and \cs{stepwise} now use \cs{leaders} for inserting duplicated % parts of pages. This way, processing of whatsits is turned off in the duplicates so that table of % contents entries are no longer duplicated when a section occurs on a page where \cs{pause} or % \cs{stepwise} is used (spotted by heiner richter). Thanks to Heiko Oberdiek for his suggestion how % \cs{leaders} can be successfully applied for this purpose. \cs{stepwise} now does the right thing if % no \cs{step} command occurs in contents. There was a bug in \cs{save@TP} which would become % apparent if \cs{stepwise} was the first thing on a page. Spotted and fixed by Ross Moore (thanks!).} % % \changes{v0.0.7b}{2000/05/04}{Changed hyperref version check from 2000/03/22 to 2000/03/23. % Spotted by Ross Moore.} % % \changes{v0.0.7c}{2000/05/06}{\cs{eject} changed to \cs{newpage} in \cs{stepwise} to cure some problems % with the foils package. Spotted by Ross Moore.} % % \changes{v0.0.7d}{2000/05/18}{\cs{everydisplay} finally removed from colormath option because it % only causes trouble. Maybe I should look for a less fragile solution for the whole thing. Fixed a % bug in texpower's definition of \cs{set@page@color} (used only if pdftex.def doesn't define it) % which would cause a fatal error if two \cs{pagecolor} commands occur. Added command % \cs{replacecolor}.} % % \changes{v0.0.8}{2000/05/24}{Now providing two methods for creating duplicates of page contents % (used by \cs{pause} and \cs{stepwise}). The former default method using \cs{leaders}, which leads to % problems with footnotes (spotted by Heiner Richter), is now activated by the newly introduced % option robustduplicates. The new default method uses \cs{unvbox} as the \cs{pause} command from % texpause.sty, but redefines \cs{write} for suppressing duplicate toc and bookmark entries due to % duplicated whatsits. Changed the way \cs{liststepwise} and \cs{parstepwise} are implemented. Instead % of wrapping the whole contents in a minipage (which caused a lot of problems), an invisible % \cs{hrule} is inserted in front of contents, which seems to do the job as well. With option % robustduplicates, this seems to be unneccessary for \cs{parstepwise}. Now all counters are saved % before \cs{stepwise} starts and restored for every \cs{step}. This remedies problems with equation % numbers etc. Added a modification for the slides class so that slides are not centered if the % display option is given. Option slifonts now also handles math fonts. Added a \cs{hidetext} % command which respects line breaks (needs soul package).} % % \changes{v0.0.8a}{2000/06/02}{Fixed a bug in the code which disables \cs{pageDuration} if the % pdfpageduration key doesn't exist (spotted by Friedrich Eisenbrand).} % % \changes{v0.0.8b}{2000/06/09}{Added additional `dimmed' and `enhanced' color sets for all standard % colors, with corresponding commands \cs{dimcolors} and \cs{enhancecolors}. Added a `color stack % correction' option fixcolorstack, which should avoid that the duplication of ``color push'' and % ``color pop'' specials confuses the driver's color stack (spotted by Ross Moore). Added new % display commands \cs{hidedimmed}, \cs{hidevanish}, \cs{highlightenhanced}. Added \cs{step} variants % \cs{dstep} and \cs{vstep}. Added patches for \cs{[}, equation, eqnarray, and eqnarray* when the % colormath option is used. Now also saving and restoring footnotes at \cs{pause} and \cs{stepwise}. % Added a command \cs{releasecounter} to keep a counter from `freezing' during the execution of % \cs{stepwise}.} % % \changes{v0.0.8c}{2000/06/13}{The default duplication method will now (only) attack % \cs{protected@write}. There's a new option hackwrite which restores the former default method (of % attacking \cs{write}). Corrected a bug newly introduced into \cs{switch} with version 0.0.8b. % Corrected a bug in the color correction code (spotted by Ross Moore).} % % \changes{v0.0.8d}{2000/06/15}{Corrected a minor quirk in \cs{hidetext}. Added a command % \cs{addTPcolor} for defining new `standard' colors. In printout versions, the last step will no % longer think it's `first activated'.} % % \changes{v0.0.8e}{2000/06/21}{Yet another rewrite of the page duplication code. I hope it's % perfect this time :) The options robustduplicates and hackwrite are obsolete now. Thanks to % Martin Schroeder for permission to use his everyshi code. Fixed a small quirk in \cs{dstep} and % \cs{vstep}. \cs{darkbackground} and relatives now set both page and text color.} % % \changes{v0.0.8f}{2000/06/27}{A small change in the definition of \cs{liststepwise} to enhance % vertical spacing.} % % \changes{v0.0.8g}{2000/07/19}{Color management extended and largely rewritten. A small change to % make page transition and page duration settings local to groups. \cs{dstep} and \cs{vstep} now % understand the usual optional arguments.} % % \changes{v0.0.9}{2000/10/17}{Added support for structured backgrounds (command % \cs{backgroundstyle}). New commands for gradient rules and boxes. Added a hack to keep hyperref % from producing duplicate page anchors (suggested by Thomas Emmel). Some slight changes in the % mode of accounting in \cs{step} to hopefully give better results for `complicated' orders of % activating steps using \cs{step}'s optional arguments. Added (experimental) commands \cs{multistep} % and \cs{movie} for aiding in (simple) animations. \cs{pagecolor} hack removed, as pdftex.def on CTAN % now supports \cs{pagecolor}. \cs{set@color} hack for seminar removed (made unneccessary by % enhancements to powersem). Added rudimentary support for panels. Added rudimentary support for % navigation elements. Now put a hyper anchor ``firstpage.n'' on the first element of the sequence % for page n.} % % \changes{v0.0.9a}{2002/02/01}{Tidying up the inline documentation. When the color package is % loaded before texpower, texpower's color management is no longer activated automatically. % Definitions of standard colors moved to file tpcolors.cfg. Option `slifonts' is obsolete now. The % code is now part of the much more sophisticated package ``tpslifonts''. Now the `colormath' % option cooperates with array.sty (and thus colortbl.sty). New option ``nineminutes'' to % circumvent a strange behaviour of acrobat/acroread v4.05 and later wrt. page duration. Option % `fixcolorstack' now checks also for VTeX. \cs{hidedimmed}, \cs{highlightenhanced} and \cs{dstep} now % check for math mode. Now using ifpdf package if available.} % % \changes{v0.0.9b}{2002/11/13}{colormath adapted to different handling of `equation' by amsmath % 2.x. Adapted for new version of soul package. Added another patch to colormath for handling % array package's ``m'' columns without color change. `Turn on' seminar parameters in panel boxes % even before \cs{begin\{document\}}. Added a command \cs{overlays}, sibling of \cs{multistep}, which % prints all steps over each other. Added a command \cs{steponce}, sibling of \cs{step}, which is % active only for one step. Removed a bug in color correction code introduced in v0.0.8g.} % % \changes{v0.0.9c}{2003/04/29}{A small fix to give \cs{overlays} a width. \cs{mklength} is now a user % command. The \cs{@nobreak} switch and \cs{everypar} are now saved and restored by \cs{stepwise}, % hopefully enhancing cooperation with section headings and list environments. Changed % \cs{newcommand} to \cs{providecommand} to allow background.sty to be loaded in parallel (thanks to % Hans Fr. Nordhaug for the original patch).} % % \changes{v0.0.9d}{2003/05/15}{Release.} % % \changes{v0.1}{2003/06/03}{Removed font stuff (now resides in tpslifonts). A small fix to avoid % warnings about extremely overfull hboxes when measuring steps. Our dabbling with \cs{shipout} % created display errors with some packages like pdfscreen. Thanks to Maarten Fokkinga for spotting % it. Fixed.} % % \changes{v0.1a}{2003/06/04}{Color management extended a little to integrate better with LaTeX. % Made \cs{step}-like commands give better error messages when outside \cs{stepwise}.} % % \changes{v0.1b}{2004/07/27}{Moved to dtx format. No other code changes.} % % \changes{v0.2}{2005/04/07}{Fixed bugs \#1029803 and \#1073319 reported at SourceForge. % Made the handling of whatsits smarter (making write to file and hyperref % commands) stepwise-aware. Added option/command to turn on/off the old % aggressive/robust filtering. Added fragilesteps environment.} % % We need the programming tools provided by these packages. % \begin{macrocode} \RequirePackage{ifthen} \RequirePackage{calc} \RequirePackage{keyval} % \end{macrocode} % % \subsection{Options and general setup} % % \subsubsection{General options} % % The option verbose turns on some automatic messages. % \begin{macrocode} \newboolean{verbose@TP} \DeclareOption{verbose}{\setboolean{verbose@TP}{true}} % \end{macrocode} % The (global) option display is respected and turns on the `dynamic' features. % \begin{macrocode} \provideboolean{display} \DeclareOption{display}{\setboolean{display}{true}} % \end{macrocode} % The option printout turns off the `dynamic' features. Can be used to undo a default setting of display. % \begin{macrocode} \DeclareOption{printout}{\setboolean{display}{false}} % \end{macrocode} % The option fixcolorstack switches on a `color stack correction' method which undoes damage to the driver's color stack % when ``color push'' and ``color pop'' specials are duplicated. % \begin{macrocode} \newboolean{fixcolorstack@TP} \DeclareOption{fixcolorstack}{\setboolean{fixcolorstack@TP}{true}} % \end{macrocode} % The option oldfiltering reverts to the old (pre v0.2) aggressive/robust filtering of whatsits. % \begin{macrocode} \newboolean{oldfiltering@TP} \DeclareOption{oldfiltering}{\setboolean{oldfiltering@TP}{true}} \newcommand{\oldfilteringon}{\setboolean{oldfiltering@TP}{true}} \newcommand{\oldfilteringoff}{\setboolean{oldfiltering@TP}{false}} % \end{macrocode} % The option nineminutes sets the page duration of every single page to a high value (of about nine minutes; this seems % to be a hardcoded upper limit in acrobat 5; see below). This way, a setting in acrobat reader's fullscreen dialogue % is masked. Otherwise, pages without an explicit page duration setting don't get any page duration setting at all, so % they will follow the dialogue setting. % \begin{macrocode} \newboolean{nineminutes@TP} \DeclareOption{nineminutes}{\setboolean{nineminutes@TP}{true}} % \end{macrocode} % % \subsubsection{Color options} % % The following switch indicates whether color management should be turned on at all. % \begin{macrocode} \newboolean{TPcolor} % \end{macrocode} % The option coloremph makes |\em| and |\emph| switch the text color instead of the font shape. % \begin{macrocode} \newboolean{coloremph@TP} \DeclareOption{coloremph} {\setboolean{TPcolor}{true}\setboolean{coloremph@TP}{true}} % \end{macrocode} % The option colormath makes math formulae be color highlighted. % \begin{macrocode} \newboolean{colormath@TP} \DeclareOption{colormath} {\setboolean{TPcolor}{true}\setboolean{colormath@TP}{true}} % \end{macrocode} % The option colorhighlight makes highlighting commands use colors. % \begin{macrocode} \newboolean{colorhighlight@TP} \DeclareOption{colorhighlight} {\setboolean{TPcolor}{true}\setboolean{colorhighlight@TP}{true}} % \end{macrocode} % The option whitebackground selects standard colors for white backgrounds. % \begin{macrocode} \newboolean{whitebackground@TP} \setboolean{whitebackground@TP}{true}% This is the default. \DeclareOption{whitebackground} {\setboolean{TPcolor}{true}\setboolean{whitebackground@TP}{true}} % \end{macrocode} % The option lightbackground selects standard colors for light (but not white) backgrounds. % \begin{macrocode} \newboolean{lightbackground@TP} \DeclareOption{lightbackground} {\setboolean{TPcolor}{true}\setboolean{lightbackground@TP}{true}} % \end{macrocode} % The option blackbackground selects standard colors for black backgrounds. % \begin{macrocode} \newboolean{blackbackground@TP} \DeclareOption{blackbackground} {\setboolean{TPcolor}{true}\setboolean{blackbackground@TP}{true}} % \end{macrocode} % The option darkbackground selects standard colors for dark (but not black) backgrounds. % \begin{macrocode} \newboolean{darkbackground@TP} \DeclareOption{darkbackground} {\setboolean{TPcolor}{true}\setboolean{darkbackground@TP}{true}} % \end{macrocode} % % Load the config file with default options if file exists. % \begin{macrocode} \InputIfFileExists{tpoptions.cfg}{}{} % \end{macrocode} % % Process options. % \begin{macrocode} \ProcessOptions \ifthenelse{\boolean{display}} {\PackageInfo{texpower}{Producing display version. Dynamic features activated.}} {\PackageInfo{texpower}{Producing printout version. Dynamic features inactive.}} % \end{macrocode} % % General option-driven initialization. % % If the verbose option is set, we give a lot of context information when an error is raised. % \begin{macrocode} \ifthenelse{\boolean{verbose@TP}}{\setcounter{errorcontextlines}{10000}}{} % \end{macrocode} % % Driver-specific defaults. % % We provide a switch which (hopefully) allows to distinguish whether postscript specials (as used by PSTricks) can be % used safely or not. % \begin{macrocode} \newboolean{psspecialsallowed} \setboolean{psspecialsallowed}{true} % optimistic default % \end{macrocode} % The switch |\ifpdf| is to determine whether pdfLaTeX is being run and outputting pdf, using Heiko Oberdiek's faultproof % pdf detector: % \begin{macrocode} \@ifundefined{pdftrue}{ \IfFileExists{ifpdf.sty}{\RequirePackage{ifpdf}}{% \expandafter\newif\csname ifpdf\endcsname \ifx\pdfoutput\undefined \else \ifx\pdfoutput\relax \else \ifcase\pdfoutput \else \pdftrue \fi \fi \fi } }{% \ifpdf is defined - nothing to do } \ifpdf\setboolean{psspecialsallowed}{false}\fi % \end{macrocode} % % Class-specific defaults. % % The following switches centering of slides off for the slides document class because this would disturb dynamic % building of slides. % \begin{macrocode} \@ifclassloaded{slides}% {% \ifthenelse{\boolean{display}}% {\let\@topfil\relax}% {}% } {} % \end{macrocode} % % Some registers and macros for general use throughout texpower.sty. % \begin{macrocode} \newcounter{tmpcnta@TP} \newcounter{tmpcntb@TP} \newlength{\tempdima@TP} \newlength{\tempdimb@TP} \newbox\tempbox@TP \newboolean{carryon@TP} % \end{macrocode} % These are needed for calculating the size of the page background box. % \begin{macrocode} \newcommand{\TPpagewidth}{\strip@pt\paperwidth truept} \newcommand{\TPpageheight}{\strip@pt\paperheight truept} % \AtBeginDocument % {% % \edef\TPpagewidth{\strip@pt\paperwidth truept}% % \edef\TPpageheight{\strip@pt\paperheight truept}% % } % \end{macrocode} % \begin{macro}{\mkfactor} % |\mkfactor{}{}| is a helper command for automatically generating the fixed point numbers between 0 and 1 % which are employed by the color calculation commands. || can be anything which can stand behind * in calc % (for instance: |\value{counter}/\value{maxcounter}| or |\ratio| or whatever). || should be a valid macro name. || % is converted into a fixed-point representation which is then assigned to ||. % \begin{macrocode} \newcommand{\mkfactor}[2]% {\setlength{\tempdima@TP}{1pt*#2}\edef#1{\strip@pt\tempdima@TP}} % \end{macrocode} % \end{macro} % Make a string representation of a length expression. % \begin{macrocode} \newcommand{\mklength@TP}[2] {\setlength{\tempdima@TP}{#2}\edef#1{\the\tempdima@TP}} \newcommand{\mklength}{} \let\mklength\mklength@TP % \end{macrocode} % % \subsection{Color management, color emphasis and highlighting} % % Initialization. % % If we are to use colors, we need the color package. % \begin{macrocode} \ifthenelse{\boolean{TPcolor}}{\RequirePackage{color}}{}% % \end{macrocode} % % \subsubsection{Color management kernel} % % Only load the kernel if TeXPower's color management is active. % \begin{macrocode} \ifthenelse{\boolean{TPcolor}}{% Yes. % \end{macrocode} % We need a hook which can be defined otherwise to turn off colors. % \begin{macrocode} \let\setcolor@TP=\color% % \end{macrocode} % Overload |\definecolor| to store a `driver-independent' copy of the color definition for later use by |\colorbetween| % and relatives. % \begin{macrocode} \let\o@definecolor@TP=\definecolor% \def\definecolor#1#2#3% {% \o@definecolor@TP{#1}{#2}{#3}% \expandafter\edef\csname colordef@TP@#1\endcsname% {\csname processcolor@TP@#2\endcsname{#3}}% }% % \end{macrocode} % Repeat color.sty's standard color definitions to make the original definitions available to TeXPower. % Begin excerpt from color.sty: % \begin{macrocode} \@ifundefined{c@lor@namefile}{}{\input{\c@lor@namefile}} \ifx\color@gray\@undefined \ifx\color@rgb\@undefined \else \definecolor{black}{rgb}{0,0,0} \definecolor{white}{rgb}{1,1,1} \fi \else \definecolor{black}{gray}{0} \definecolor{white}{gray}{1} \fi \ifx\color@rgb\@undefined\else \definecolor{red}{rgb}{1,0,0} \definecolor{green}{rgb}{0,1,0} \definecolor{blue}{rgb}{0,0,1} \fi \ifx\color@cmyk\@undefined\else \definecolor{cyan}{cmyk}{1,0,0,0} \definecolor{magenta}{cmyk}{0,1,0,0} \definecolor{yellow}{cmyk}{0,0,1,0} \fi % \end{macrocode} % End excerpt from color.sty. % % \subsubsection{Commands for calculating new colors} % % \begin{macro}{\interpolate@TP} Calculates the weighted average between two fixed point values. % \begin{macrocode} \newcommand{\interpolate@TP}[3]% {% \setlength{\tempdima@TP}{1pt-#1pt}% Calculate the second factor for the weighted average. \edef\secondfactor@TP{\strip@pt\tempdima@TP}% \setlength{\tempdima@TP}{#2pt*\real{#1}+#3pt*\real{\secondfactor@TP}}% Calculate the weighted average. \ifthenelse{\lengthtest{\tempdima@TP<0pt}}% Bound the result to the interval [0,1] (just in case the first {\setlength{\tempdima@TP}{0pt}}% factor was not from [0,1]). {\ifthenelse{\lengthtest{\tempdima@TP>1pt}}{\setlength{\tempdima@TP}{1pt}}{}}% \edef\result@TP{\strip@pt\tempdima@TP}% } % \end{macrocode} % \end{macro} % \begin{macro}{\interpolate@three@TP} Interpolates a three-piece color value. % \begin{macrocode} \def\interpolate@three@TP#1,#2,#3;#4,#5,#6;#7% {% \interpolate@TP{#7}{#1}{#4}% First intermediary value. \edef\newcolordef@TP{\result@TP,}% Store first value. \interpolate@TP{#7}{#2}{#5}% Second intermediary value. \edef\newcolordef@TP{\newcolordef@TP\result@TP,}% Store second value. \interpolate@TP{#7}{#3}{#6}% Third intermediary value. \edef\newcolordef@TP{\newcolordef@TP\result@TP}% Store third value. } % \end{macrocode} % \end{macro} % \begin{macro}{\interpolate@four@TP} Interpolates a four-piece color value. % \begin{macrocode} \def\interpolate@four@TP#1,#2,#3,#4;#5,#6,#7,#8;#9% {% \interpolate@TP{#9}{#1}{#5}% First intermediary value. \edef\newcolordef@TP{\result@TP,}% Store first value. \interpolate@TP{#9}{#2}{#6}% Second intermediary value. \edef\newcolordef@TP{\newcolordef@TP\result@TP,}% Store second value. \interpolate@TP{#9}{#3}{#7}% Third intermediary value. \edef\newcolordef@TP{\newcolordef@TP\result@TP,}% Store third value. \interpolate@TP{#9}{#4}{#8}% Fourth intermediary value. \edef\newcolordef@TP{\newcolordef@TP\result@TP}% Store fourth value. } % \end{macrocode} % \end{macro} % \begin{macro}{\convert@cmykvalue@rgbvalue@TP} Converts one color value from CMYK to rgb. % \begin{macrocode} \def\convert@cmykvalue@rgbvalue@TP#1#2% {% \setlength{\tempdima@TP}{1pt-#1pt-#2pt}% \ifthenelse{\lengthtest{\tempdima@TP<0pt}}{\setlength{\tempdima@TP}{0pt}}{}% \edef\result@TP{\strip@pt\tempdima@TP}% }% % \end{macrocode} % \end{macro} % \begin{macro}{\convert@cmyk@rgb@TP} Converts CMYK color to rgb. % \begin{macrocode} \def\convert@cmyk@rgb@TP#1,#2,#3,#4;% {% \convert@cmykvalue@rgbvalue@TP{#1}{#4}% \edef\newcolordef@TP{\result@TP,}% Store first value. \convert@cmykvalue@rgbvalue@TP{#2}{#4}% \edef\newcolordef@TP{\newcolordef@TP\result@TP,}% Store second value. \convert@cmykvalue@rgbvalue@TP{#3}{#4}% \edef\newcolordef@TP{\newcolordef@TP\result@TP}% Store third value. } % \end{macrocode} % \end{macro} % \begin{macro}{\convert@RGBvalue@rgbvalue@TP} Converts one color value from RGB to rgb. % \begin{macrocode} \def\convert@RGBvalue@rgbvalue@TP#1% {% \setlength{\tempdima@TP}{#1pt/255}% \edef\result@TP{\strip@pt\tempdima@TP}% }% % \end{macrocode} % \end{macro} % \begin{macro}{\convert@RGB@rgb@TP} Converts RGB color to rgb. % \begin{macrocode} \def\convert@RGB@rgb@TP#1,#2,#3;% {% \convert@RGBvalue@rgbvalue@TP{#1}% \edef\newcolordef@TP{\result@TP,}% Store first value. \convert@RGBvalue@rgbvalue@TP{#2}% \edef\newcolordef@TP{\newcolordef@TP\result@TP,}% Store second value. \convert@RGBvalue@rgbvalue@TP{#3}% \edef\newcolordef@TP{\newcolordef@TP\result@TP}% Store third value. } % \end{macrocode} % \end{macro} % |\colorbetween[]{}{}{}| calculates a `weighted average' between % two colors. || and || are the names of the two colors. || (default: 0.5) % is a fixed-point number between 0 and 1 giving the `weight' for the interpolation between % || and ||. || is the name to be given to the resulting mixed color. If % || is 1, then || will be identical to || (up to color model conversions, % see below), if || is 0, then || will be identical to ||, if || is % 0.5, then || will be exactly in the middle between || and ||. % % |\colorbetween| supports the following color models: rgb, RGB, gray, cmyk, hsb. If both colors are % of the same model, the resulting color is also of the respective model. If || and % || are from \texttt{different} models, then || will \texttt{always} be an rgb % color. The only exception is the hsb color model: As I don't know how to convert hsb to rgb, % mixing hsb with another color model will always raise an error. % \begin{macrocode} \newcommand{\colorbetween}[4][.5]% {% \begingroup% Make the definition of \processcolor... local. \newcommand{\processcolor@TP@rgb}[3]% What if the first color is an rgb color? {% \ifx##2\processcolor@TP@rgb% Are both colors rgb colors? \interpolate@three@TP##1;##3;{#1}% Calculate interpolated values. \else \ifx##2\processcolor@TP@gray% Is the second color from the gray model? \interpolate@three@TP##1;##3,##3,##3;{#1}% Calculate interpolated values. \else \ifx##2\processcolor@TP@cmyk% Is the second color from the cmyk model? \convert@cmyk@rgb@TP##3;% Convert to rgb. \edef\newcolordef@TP{\noexpand\interpolate@three@TP##1;\newcolordef@TP;{#1}}% \newcolordef@TP \else \ifx##2\processcolor@TP@RGB% Is the second color from the RGB model? \convert@RGB@rgb@TP##3;% Convert to rgb. \edef\newcolordef@TP{\noexpand\interpolate@three@TP##1;\newcolordef@TP;{#1}}% \newcolordef@TP \else \ifx##2\processcolor@TP@hsb% Is the second color from the hsb model? \PackageError{texpower}{Don't know how to convert an hsb color!} \fi \fi \fi \fi \fi \edef\newcolordef@TP{{rgb}{\newcolordef@TP}}% Store the result }% \newcommand{\processcolor@TP@gray}[3]% What if the first color is a gray color? {% \ifx##2\processcolor@TP@gray% Are both colors gray colors? \interpolate@TP{#1}{##1}{##3}% Calculate interpolated value. \edef\newcolordef@TP{{gray}{\result@TP}}% Store the result \else \processcolor@TP@rgb{##1,##1,##1}{##2}{##3}% Otherwise, convert first color to rgb and continue. \fi }% \newcommand{\processcolor@TP@cmyk}[3]% What if the first color is a cmyk color? {% \ifx##2\processcolor@TP@cmyk% Are both colors cmyk colors? \interpolate@four@TP##1;##3;{#1}% Calculate interpolated values. \edef\newcolordef@TP{{cmyk}{\newcolordef@TP}}% Store the result \else \convert@cmyk@rgb@TP##1;% Otherwise, convert first color to rgb ... \expandafter\processcolor@TP@rgb\expandafter{\newcolordef@TP}{##2}{##3}% ... and continue. \fi }% \newcommand{\processcolor@TP@RGB}[3]% What if the first color is an RGB color? {% \convert@RGB@rgb@TP##1;% Convert to rgb ... \expandafter\processcolor@TP@rgb\expandafter{\newcolordef@TP}{##2}{##3}% ... and continue. }% \newcommand{\processcolor@TP@hsb}[3]% What if the first color is an hsb color? {% \ifx##2\processcolor@TP@hsb% Are both colors hsb colors? \interpolate@three@TP##1;##3;{#1}% Calculate interpolated values. \edef\newcolordef@TP{{hsb}{\newcolordef@TP}}% Store the result \else \PackageError{texpower}{Don't know how to convert an hsb color!} \fi }% \expandafter\let\expandafter \firstcol@TP\csname colordef@TP@#3\endcsname % Retrieve definition of color ... \expandafter\expandafter\expandafter\firstcol@TP% and apply (remember \processcolor... is part of the definition) \csname colordef@TP@#4\endcsname% to definition of color . \edef\end@TP% Define color (outside the enclosing group). {\endgroup\noexpand\definecolor{#2}\newcolordef@TP}% \end@TP }% matches \newcommand{\colorbetween} % \end{macrocode} % \begin{macro}{\complement@TP} Calculates the complement of a fixed point value. % \begin{macrocode} \newcommand{\complement@TP}[1]% {% \setlength{\tempdima@TP}{1pt-#1pt}% \edef\result@TP{\strip@pt\tempdima@TP}% } % \end{macrocode} % \end{macro} % \begin{macro}{\complement@three@TP} Complements a three-piece color value. % \begin{macrocode} \def\complement@three@TP#1,#2,#3;% {% \complement@TP{#1}% \edef\newcolordef@TP{\result@TP,}% Store first value. \complement@TP{#2}% \edef\newcolordef@TP{\newcolordef@TP\result@TP,}% Store second value. \complement@TP{#3}% \edef\newcolordef@TP{\newcolordef@TP\result@TP}% Store third value. } % \end{macrocode} % \end{macro} % \begin{macro}{\grabfourth@TP} Separates the fourth element of a four-piece color value from the rest. % \begin{macrocode} \def\grabfourth@TP#1,#2,#3,#4;% {% \def\mem@TP{#4}% Store fourth element. \def\result@TP{#1,#2,#3;}% Store first three elements. } % \end{macrocode} % \end{macro} % \begin{macro}{\complementcolor} % |\complementcolor{}{}| calculates the numerical complement of a color. || is the name of the % color to be complemented. || is the name to be given to the resulting color. % |\complementcolor| supports the following color models: rgb, RGB, gray, cmyk, hsb. % \begin{macrocode} \newcommand{\complementcolor}[2]% {% \begingroup% Make the definition of \processcolor... local. \newcommand{\processcolor@TP@rgb}[1]% What if the color is an rgb color? {% \complement@three@TP##1;% Calculate complemented values. \edef\newcolordef@TP{{rgb}{\newcolordef@TP}}% Store the result }% \newcommand{\processcolor@TP@gray}[1]% What if the color is a gray color? {% \complement@TP{##1}% Calculate complemented value. \edef\newcolordef@TP{{gray}{\result@TP}}% Store the result }% \newcommand{\processcolor@TP@cmyk}[1]% What if the color is a cmyk color? {% \grabfourth@TP##1;% Remember fourth element. \expandafter\complement@three@TP\result@TP% Calculate complemented values of first three elements. \edef\newcolordef@TP{{cmyk}{\newcolordef@TP,\mem@TP}}% Store the result, putting back the fourth element. }% \newcommand{\processcolor@TP@RGB}[1]% What if the color is an RGB color? {% \convert@RGB@rgb@TP##1;% Convert to rgb ... \expandafter\processcolor@TP@rgb\expandafter{\newcolordef@TP}% ... and continue. }% \newcommand{\processcolor@TP@hsb}[1]% What if the color is an hsb color? {% \complement@three@TP##1;% Calculate complemented values. \edef\newcolordef@TP{{hsb}{\newcolordef@TP}}% Store the result }% \csname colordef@TP@#2\endcsname% Execute definition of color (which contains \processcolor...) \edef\end@TP% Define color (outside the enclosing group). {\endgroup\noexpand\definecolor{#1}\newcolordef@TP}% \end@TP }% matches \newcommand{\complementcolor} }% matches \ifthenelse{\boolean{TPcolor}}{% Yes. {% No. Do nothing. } % \end{macrocode} % \end{macro} % % \subsection{Color name and color set management} % % \begin{macro}{\replacecolor} % |\replacecolor[]{}[]{}| will make || have the same definition as || (if || is % defined at all), where and are color names as given in the first argument of |\definecolor|. If (one % of) || and || are given, the colors will be taken from the respective color sets. % \begin{macrocode} \newcommand{\replacecolor} {% \let\replacecolor@hook@TP=\@gobble% This hook can be used for variant checking (see below). \replacecolor@TP% Pick up arguments. } \newcommand{\replacecolor@TP}[2][]% Pick up the first two arguments of \replacecolor. {% \ifthenelse{\equal{#1}{}}{\edef\tcolname@TP{#2}}{\edef\tcolname@TP{#2@#1}}% Construct `real' target color name. \@replacecolor@TP% Read second argument. }% % \end{macrocode} % \end{macro} % \begin{macrocode} \ifthenelse{\boolean{TPcolor}}% Only if TeXPower's color management is active. {% Yes. \newcommand{\undefinecolor@TP}[1]% Make a color undefined. {\expandafter\let\csname\string\color @#1\endcsname=\@undefined}% \newcommand{\ifcolorexists@TP}[3]% Conditional for testing whether a color is defined. {\@ifundefined{\string\color @#1}{#3}{#2}}% Test whether a given color is defined. \newcommand{\@replacecolor@TP}[2][]% Second part of \replacecolor. {% \ifthenelse{\equal{#1}{}}{\edef\scolname@TP{#2}}{\edef\scolname@TP{#2@#1}}% Construct `real' source color name. \ifcolorexists@TP{\scolname@TP}% Does the source color exist at all? {% Yes. \replacecolor@hook@TP{\tcolname@TP}% Execute hook. \expandafter\let\csname\string\color @\tcolname@TP\expandafter\endcsname% Make value of target color \csname\string\color @\scolname@TP\endcsname% identical with source color. \expandafter\let\csname colordef@TP@\tcolname@TP\expandafter\endcsname% Make definition of target color \csname colordef@TP@\scolname@TP\endcsname% identical with source color. }% {% No. Do nothing. }% }% % \end{macrocode} % % The set of TeXPower's `standard colors' and some commands to manipulate them. % % \begin{macro}{\colors@TP} |\colors@TP| is the list of all standard colors defined by texpower. % The list is empty initially. % \begin{macrocode} \newcommand{\colors@TP}{} % \end{macrocode} % \end{macro} % \begin{macro}{\removecolor@TP} Removes a color name from the list. % \begin{macrocode} \newcommand{\removecolor@TP}[1]% {% \def\processme@TP##1% This macro does the real work. {% \ifthenelse{\equal{#1}{##1}}% Is this the color to be removed? {% Yes. Do nothing, so it vanishes. } {% No. Re-insert. \expandafter\def\expandafter\colors@TP\expandafter{\colors@TP\processme@TP{##1}}% }% }% \expandafter\let\expandafter\colors@TP\expandafter\empty% Initialize \colors@TP. \colors@TP% Execute \processme@TP for every color on the list. } % \end{macrocode} % \end{macro} % \begin{macro}{\addTPcolor} % |\addTPcolor{}| adds the color named || to TeXPower's list of standard colors. % \begin{macrocode} \newcommand{\addTPcolor}[1]% {% \removecolor@TP{#1}% Remove this color from the list (to avoid duplicates). \expandafter\def\expandafter\colors@TP\expandafter{\colors@TP\processme@TP{#1}}% ... and insert. \register@normalvariant@TP{#1}% Register the normal variant for this color. } % \end{macrocode} % \end{macro} % \begin{macro}{\defineTPcolor} % |\defineTPcolor[]{}{}{}| acts like\\ |\definecolor{}{}{}|, but % \begin{enumerate} % \item color || is automatically added to the list of standard colors and % \item if the optional parameter is given, the color is defined in the color set || instead of % the current color set. % \end{enumerate} % \begin{macrocode} \newcommand{\defineTPcolor}[4][] {% \addTPcolor{#2}% Add color to the list. \ifthenelse{\equal{#1}{}}% Color from the current color set? {\definecolor{#2}{#3}{#4}}% Yep. Just define the color. {\definecolor{#2@#1}{#3}{#4}}% No. Add color set identifyer. } % \end{macrocode} % \end{macro} % % Some commands for manipluating whole color sets. % % \begin{macro}{\replacecolors@TP} Low level command for replacing a complete color set. % \begin{macrocode} \newcommand{\replacecolors@TP}% {% \@ifstar% The starred version will put the color set into normal variant. {\let\replacecolor@hook@TP=\register@normalvariant@TP\@replacecolors@TP} {\let\replacecolor@hook@TP=\@gobble\@replacecolors@TP}% } \newcommand{\@replacecolors@TP}[4]% This part does the real work. {% \def\processme@TP##1{\replacecolor@TP[#1]{#2##1}[#3]{#4##1}}% \colors@TP } % \end{macrocode} % \end{macro} % \begin{macro}{\usecolorset} % |\usecolorset{}| switches to color set ||. % \begin{macrocode} \newcommand{\usecolorset}[1]% {% \replacecolors@TP*{}{}{#1}{}% Replace normal variant (registering variants). \replacecolors@TP{}{d}{#1}{d}% Replace dimmed variant. \replacecolors@TP{}{e}{#1}{e}% Replace enhanced variant. \color{textcolor}% Activate textcolor. \pagecolor{pagecolor}% Activate pagecolor. }% % \end{macrocode} % \end{macro} % \begin{macro}{\dumpcolorset} % |\dumpcolorset{}| saves all standard colors from the current color set to the color set ||. % \begin{macrocode} \newcommand{\dumpcolorset}[1]% {% \nonnormalwarnings@TP{Dumping color set #1}% Output a warning for every color not in the normal variant. \replacecolors@TP{#1}{}{}{}% Dump normal variant (hopefully). \replacecolors@TP{#1}{d}{}{d}% Dump dimmed variant. \replacecolors@TP{#1}{e}{}{e}% Dump enhanced variant. }% % \end{macrocode} % \end{macro} % Commands for color variants. % \begin{macrocode} \newcommand{\registervariant@TP}[2]% Remember which variant a color is currently in. {\expandafter\def\csname cvar@#1@TP\endcsname{#2}} \newcommand{\register@normalvariant@TP}[1]% Register that a color is now in the normal variant. {\registervariant@TP{#1}{}} \newcommand{\currentvariant@TP}[1]% Return the current variant of a color. {\csname cvar@#1@TP\endcsname} \newcommand{\ifnormalvariant@TP}[3]% Conditional for checking whether a color is in the normal variant. {\ifthenelse{\equal{\currentvariant@TP{#1}}{}}{#2}{#3}} \newcommand{\nonnormalwarnings@TP}[1]% Checks the current variant for every standard color and gives a warning {% if it's not the normal one. \def\processme@TP##1% {% \ifnormalvariant@TP{##1}{} {% \PackageWarning{texpower} {#1\MessageBreak when color ##1 is in \currentvariant@TP{##1} variant}% }% }% \colors@TP } % \end{macrocode} % Default dim level for automatic color dimming. % \begin{macrocode} \newcommand{\dimlevel}{.7} % \end{macrocode} % |\dimcolor[]{}| dims the color named ||. It checks whether an explicit `dimmed' variant d % exists. If yes, || is replaced by |d|. Otherwise, the dimmed color is calculated by interpolating between % pagecolor and ||. The parameter for |\colorbetween| is given by the optional argument || (default: % |\dimlevel|). % \begin{macrocode} \newcommand{\dimcolor}[2][\dimlevel] {% \ifnormalvariant@TP{#2}% Color in the normal variant? {% Yes. \registervariant@TP{#2}{d}% Register dimmed variant. \ifcolorexists@TP{d#2}% Dedicated dimmed color found? {\replacecolor{#2}{d#2}}% Yes. use that one. {\colorbetween[#1]{#2}{pagecolor}{#2}}% No. Dim numerically using \colorbetween. }% {}% No. Do nothing. } % \end{macrocode} % |\dimcolors[]| dims all standard colors using |\dimcolor|. See the description of |\dimcolor| for details. % \begin{macrocode} \newcommand{\dimcolors}[1][\dimlevel] {% \def\processme@TP##1{\dimcolor[#1]{##1}}% \colors@TP }% % \end{macrocode} % Default enhance level for automatic color enhancing. % \begin{macrocode} \newcommand{\enhancelevel}{.5} % \end{macrocode} % |\enhancecolor[]{}| enhances the color named ||. It checks whether an explicit `enhanced' variant % |e| exists. If yes, || is replaced by |e|. Otherwise, the enhanced color is calculated by % `extrapolating' from pagecolor and ||. The parameter for |\colorbetween| is given by the optional argument % || (default: |\enhancelevel|). % \begin{macrocode} \newcommand{\enhancecolor}[2][\enhancelevel] {% \ifnormalvariant@TP{#2}% Color in the normal variant? {% \registervariant@TP{#2}{e}% Register enhanced variant. \ifcolorexists@TP{e#2}% Dedicated enhanced color found? {\replacecolor{#2}{e#2}}% Yes. use that one. {\colorbetween[-#1]{#2}{pagecolor}{#2}}% No. Enhance numerically using \colorbetween. }% {}% }% % \end{macrocode} % |\enhancecolors[]| enhances all standard colors using |\enhancecolor|. See the description of |\enhancecolor| for % details. % \begin{macrocode} \newcommand{\enhancecolors}[1][\enhancelevel] {% \def\processme@TP##1{\enhancecolor[#1]{##1}}% \colors@TP }% % \end{macrocode} % Replace all colors from the current color set by a single color. % \begin{macrocode} \newcommand{\replacecolorsbyone@TP}[2]% {% \def\processme@TP##1{\replacecolor{#1##1}{#2}}% \colors@TP } % \end{macrocode} % The color used to make things `vanish'. % \begin{macrocode} \newcommand{\vanishcolor}{pagecolor} % \end{macrocode} % |\vanishcolors| replaces all standard colors by |\vanishcolor|. % \begin{macrocode} \newcommand{\vanishcolors}[1][\vanishcolor]{\replacecolorsbyone@TP{}{#1}} % \end{macrocode} % TeXPower's predefined color sets and commands to activate them. Redefine in tpcolors.cfg as convenient. % \begin{macrocode} \input{tpcolors.cfg} % \end{macrocode} % |\whitebackground| sets the standard colors up for white background. % \begin{macrocode} \newcommand{\whitebackground}% {% \usecolorset{whitebg}% } % \end{macrocode} % When the whitebackground option (or no background option, but some other color-activating option like colormath) is % given, |\whitebackground| is executed automatically (at the end of the package to ensure that texpower.cfg was read). % \begin{macrocode} \ifthenelse{\boolean{whitebackground@TP}} {\AtEndOfPackage{\whitebackground}} {} % \end{macrocode} % |\lightbackground| sets the standard colors up for `light' background. % \begin{macrocode} \newcommand{\lightbackground}% {% \usecolorset{lightbg}% } % \end{macrocode} % When the lightbackground option is given, |\lightbackground| is executed automatically. % \begin{macrocode} \ifthenelse{\boolean{lightbackground@TP}}{\AtEndOfPackage{\lightbackground}}{} % \end{macrocode} % |\darkbackground| sets the standard colors up for `dark' background. % \begin{macrocode} \newcommand{\darkbackground}% {% \usecolorset{darkbg}% } % \end{macrocode} % Execute |\darkbackground| automatically if the darkbackground option was given. % \begin{macrocode} \ifthenelse{\boolean{darkbackground@TP}}{\AtEndOfPackage{\darkbackground}}{} % \end{macrocode} % |\blackbackground| sets the standard colors up for black background. % \begin{macrocode} \newcommand{\blackbackground}% {% \usecolorset{blackbg}% } % \end{macrocode} % Execute |\blackbackground| automatically if the blackbackground option was given. % \begin{macrocode} \ifthenelse{\boolean{blackbackground@TP}}{\AtEndOfPackage{\blackbackground}}{} % \end{macrocode} % If TeXPower's color management is active, setup LaTeX color management to use the dedicated colors. % \begin{macrocode} \ifthenelse{\boolean{TPcolor}} {% \renewcommand{\normalcolor}{\color{textcolor}}% \normalcolor should produce textcolor. \let\o@textnormal@TP=\textnormal% \textnormal should also set text color. \def\textnormal#1{\o@textnormal@TP{\normalcolor#1}} % \end{macrocode} % Make sure current color is correct for the rest of the preamble. % \begin{macrocode} \AtEndOfPackage{\color{textcolor}\let\default@color\current@color} % \end{macrocode} % The following is deferred to the beginning of the document to allow redefinitions of colors and loading of % packages. We set page and text color and make amsmath's |\text| command switch to text color. % \begin{macrocode} \AtBeginDocument% {% \pagecolor{pagecolor}\color{textcolor}% \@ifpackageloaded{amstext}% {% \let\o@text@TP=\text% \def\text#1{\o@text@TP{\normalcolor\expandafter\everymath\expandafter{\the\everymath\color{mathcolor}}#1}}% }% {}% }% } {} % \end{macrocode} % If TeXPower's color management is active, set page and text color at the beginning of the document. % \begin{macrocode} \ifthenelse{\boolean{TPcolor}}{\AtBeginDocument{\pagecolor{pagecolor}\color{textcolor}}}{} }% matches \ifthenelse{\boolean{TPcolor}}{% Yes. {% No; provide dummies. \let\setcolor@TP=\@gobble% \newcommand{\@replacecolor@TP}[2][]{}% \let\addTPcolor=\@gobble \newcommand{\defineTPcolor}[4][]{}% \let\usecolorset=\@gobble \let\dumpcolorset=\@gobble \newcommand{\dimcolor}[2][]{} \newcommand{\dimcolors}[1][]{} \newcommand{\enhancecolor}[2][]{} \newcommand{\enhancecolors}[1][]{} \newcommand{\vanishcolors}[1][]{} } % \end{macrocode} % % \subsubsection{Implementation of the coloremph option} % \begin{macrocode} \ifthenelse{\boolean{coloremph@TP}}% Should \emph use color? {% Yes; \DeclareRobustCommand{\em}% Redefine \em. {% \@nomath\em \color{emcolor}% Change color. \replacecolor{tmp@TP}{emcolor}% Exchange emcolor and altemcolor. \replacecolor{emcolor}{altemcolor}% \replacecolor{altemcolor}{tmp@TP}% }% }% {}% No; keep original definition. % \end{macrocode} % % \subsubsection{Implementation of the colormath option} % % Note that the following code is quite fragile and contains some modifications of LaTeX internals. Thus it is likely to % cause trouble, especially in conjunction with other packages modifying the LaTeX kernel. The array package is % supported, but no explicit support of other packages exists. If you experience strange and inexplicable errors while % the colormath option is active, first of all try switching it off to see whether anything changes. % The implementation of colormath is likely to change several times before the first beta release, so expect backward % incompatible changes in behaviour. % \begin{macrocode} \ifthenelse{\boolean{colormath@TP}}% Should we color math? {% Yes. \AtBeginDocument {% % \end{macrocode} % The most basic magical incantation: Color inline math using |\everymath|. Beware of side effects of this hack. % \begin{macrocode} \expandafter\everymath\expandafter{\the\everymath\color{mathcolor}}% % \end{macrocode} % Color displayed math by overloading LaTeX's own math environments. Note that this doesn't work for the TeX % notation \$\$, which is deprecated in LaTeX anyway. % Note further that for the eqnarray and eqnarray* environments, the current implementation places the color change % command \textbf{outside} the math environment (for technical reasons; maybe this can be remedied by a more sophisticated % implementation), which will almost invariably lead to unwanted extra vertical space before and after equation % arrays. Currently there is no clean remedy, apart from using amsmath's align environment. % \begin{macrocode} \let\o@dm@TP=\[% Save the original definitions of begin and end macros for \let\o@enddm@TP=\]% LaTeX's displayed math environments. \let\o@eqa@TP=\eqnarray% \let\o@endeqa@TP=\endeqnarray% \expandafter\let\expandafter\o@eqastar@TP\csname eqnarray*\endcsname% \expandafter\let\expandafter\o@endeqastar@TP\csname endeqnarray*\endcsname% \def\[{\o@dm@TP\begingroup\color{mathcolor}}% Redefine the begin and end macros for LaTeX's displayed math \def\]{\endgroup\o@enddm@TP}% environments, adding the color change commands and an extra \def\eqnarray{\begingroup\color{mathcolor}\o@eqa@TP}% level of grouping. \def\endeqnarray{\o@endeqa@TP\endgroup\@ignoretrue}% \@namedef{eqnarray*}{\begingroup\color{mathcolor}\o@eqastar@TP} \@namedef{endeqnarray*}{\o@endeqastar@TP\endgroup\@ignoretrue} \@ifpackageloaded{amsmath}% Amsmath's displayed math environments are covered by the {% \everymath hack because they are `fake' displayed equations. \@ifpackagelater{amsmath}{2000/01/15}% As amsmath 1.x redefines the equation environment to be a {% variant of gather, treating it as a displayed math \let\o@eq@TP=\equation% environment would lead to problems, so this redefinition is \let\o@endeq@TP=\endequation% made only if amsmath 1.x is not loaded. \def\equation{\o@eq@TP\begingroup\color{mathcolor}}% \def\endequation{\endgroup\everymath{}\o@endeq@TP}% }% {}% }% {% \let\o@eq@TP=\equation% \let\o@endeq@TP=\endequation% \def\equation{\o@eq@TP\begingroup\color{mathcolor}}% \def\endequation{\endgroup\everymath{}\o@endeq@TP}% }% }% matches \AtBeginDocument{ % \end{macrocode} % Sometimes, a math environment is used for something other than displaying math. The macro |\origmath| will put its % argument in math mode, but turn off coloring. If another math environemt should be nested inside the argument of % |\origmath|, it will be coloured. % \begin{macrocode} \newcommand{\origmath}[1]{{\everymath{}\ensuremath{\everymath{\color{mathcolor}}#1}}}% % \end{macrocode} % We need to redefine some LaTeX macros which internally use math mode, to make sure that not all tabulars and % parboxes are coloured. Note that this can break packages which mess with tabular themselves. % \begin{macrocode} \renewcommand*\labelitemi{\origmath{\m@th\bullet}}% \@ifpackageloaded{array}% The array package redefines \@tabular {% \def\@tabular{% \leavevmode \hbox \bgroup \everymath{}$\everymath{\color{mathcolor}}\col@sep\tabcolsep \let\d@llarbegin\begingroup % $ \let\d@llarend\endgroup \@tabarray }% \@ifpackageloaded{colortbl} {% \def\@classz{\@classx \@tempcnta \count@ \prepnext@tok \expandafter\CT@extract\the\toks\@tempcnta\columncolor!\@nil \@addtopreamble{% \setbox\z@\hbox\bgroup\bgroup \ifcase \@chnum \hskip\stretch{.5}\kern\z@ \d@llarbegin \insert@column \d@llarend\hskip\stretch{.5}\or \d@llarbegin \insert@column \d@llarend \hfill \or \hfill\kern\z@ \d@llarbegin \insert@column \d@llarend \or \@startvcenter \@startpbox{\@nextchar}\insert@column \@endpbox $\or % $ \vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or \vbox \@startpbox{\@nextchar}\insert@column \@endpbox \fi \egroup\egroup \begingroup \CT@setup \CT@column@color \CT@row@color \CT@do@color \endgroup \@tempdima\ht\z@ \advance\@tempdima\minrowclearance \vrule\@height\@tempdima\@width\z@ \unhbox\z@}% \prepnext@tok}% } {% \def\@classz{\@classx \@tempcnta \count@ \prepnext@tok \@addtopreamble{\ifcase \@chnum \hfil \d@llarbegin \insert@column \d@llarend \hfil \or \hskip1sp\d@llarbegin \insert@column \d@llarend \hfil \or \hfil\hskip1sp\d@llarbegin \insert@column \d@llarend \or \@startvcenter \@startpbox{\@nextchar}\insert@column \@endpbox $\or % $ \vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or \vbox \@startpbox{\@nextchar}\insert@column \@endpbox \fi}\prepnext@tok}% } \DeclareRobustCommand\@startvcenter{\everymath{}$\everymath{\color{mathcolor}}\vcenter}% $ \expandafter\def\expandafter\@mkpream\expandafter#\expandafter1% \expandafter{% \expandafter\let\expandafter\@startvbox\expandafter\relax \@mkpream{#1}} } {% \def\@tabular{\leavevmode \hbox \bgroup \everymath{}$\everymath{\color{mathcolor}}\let\@acol\@tabacol \let\@classz\@tabclassz \let\@classiv\@tabclassiv \let\\\@tabularcr\@tabarray% $ }% } \long\def\@iiiparbox#1#2[#3]#4#5{% \leavevmode \@pboxswfalse \setlength\@tempdima{#4}% \@begin@tempboxa\vbox{\hsize\@tempdima\@parboxrestore#5\@@par}% \ifx\@empty#2\else\ifx\relax#2\else \setlength\@tempdimb{#2}% \def\@parboxto{to\@tempdimb}% \fi\fi \if#1b\vbox \else\if #1t\vtop \else\ifmmode\vcenter \else\@pboxswtrue \everymath{}$\everymath{\color{mathcolor}}\vcenter \fi\fi\fi \@parboxto{\let\hss\vss\let\unhbox\unvbox \csname bm@#3\endcsname}% \if@pboxsw \m@th$\fi \@end@tempboxa} \let\o@textsuperscript@TP=\textsuperscript \def\textsuperscript#1{{\everymath{}\o@textsuperscript@TP{\everymath{\color{mathcolor}}#1}}}% }% matches \ifthenelse{\boolean{colormath@TP}}{% Yes. {% No; keep original definition. \let\origmath=\ensuremath% \origmath needs to have a sensible definition. } % \end{macrocode} % % New highlighting and emphasis commands. Most of them have a sensible alternative definition if the colorhighlight % option is not given. % % |\code{}| will display in a `code-like' style (for shell commands or macro names). % |\codeswitch| switches to the style used by |\code|, for use e.g. in verbatim environments. % \begin{macrocode} \ifthenelse{\boolean{colorhighlight@TP}}% Color highlighting enabled? {% Yes; code is displayed typewriter-style, bold and in a special color. \DeclareRobustCommand{\code}[1]{\textcolor{codecolor}{\textbf{\texttt{#1}}}}% \DeclareRobustCommand{\codeswitch}{\color{codecolor}\bfseries\ttfamily}% } {% No; code is displayed just in typewriter-style and bold. \DeclareRobustCommand{\code}[1]{\textbf{\texttt{#1}}}% \DeclareRobustCommand{\codeswitch}{\bfseries\ttfamily}% } % \end{macrocode} % \begin{macro}{\macroname} % |\macroname{}| acts like |\code|, but adds a backslash in front. % \begin{macrocode} \newcommand{\macroname}[1]{\code{\textbackslash#1}} % \end{macrocode} % \end{macro} % % \begin{macro}{\commandapp} % |\commandapp[]{}{}| displays a macro with an argument. || is the macro name, || is an optional % argument, is the macro argument. Note that only one pair of braces is added for ||; for several arguments, % |\}\{| needs to be used inside || to separate arguments. % \begin{macrocode} \newcommand{\commandapp}[3][]{\code{\macroname{#2}\ifthenelse{\equal{#1}{}}{}{[#1]}\{#3\}}} % \end{macrocode} % \end{macro} % % \begin{macro}{\carg} % |\carg{}| displays a `symbolic argument', i.e. || in code style enclosed in pointy braces. % \begin{macrocode} \newcommand{\carg}[1]{\code{\origmath{\left<\code{#1}\right>}}} % \end{macrocode} % \end{macro} % % \begin{macro}{\underl} % |\underl{}| emphasises || using a special color if the colorhighlight option is given and by boldfacing % otherwise. % \begin{macrocode} \ifthenelse{\boolean{colorhighlight@TP}}% Color highlighting enabled? {% Yes; \DeclareRobustCommand{\underl}{\textcolor{underlcolor}}% Use color to highlight. } {% No; \DeclareRobustCommand{\underl}{\textbf}% Use bold face. } % \end{macrocode} % \end{macro} % % \begin{macro}{\concept} % |\concept{}| emphasises || using a special color if the colorhighlight option is given and by boldfacing % otherwise. To be used for emphasizing names of (new) concepts. % \begin{macrocode} \ifthenelse{\boolean{colorhighlight@TP}}% Color highlighting enabled? {% Yes; \DeclareRobustCommand{\concept}{\textcolor{conceptcolor}}% Use color to highlight. } {% No; \DeclareRobustCommand{\concept}{\textbf}% Use bold face. } % \end{macrocode} % \end{macro} % % \begin{macro}{\inactive} % |\inactive{}| emphasises || using a special color if the colorhighlight option is given. Nothing is done if % the option is not given. To be used for `de-emphasizing' things not currently of interest. % \begin{macrocode} \ifthenelse{\boolean{colorhighlight@TP}}% Color highlighting enabled? {% Yes; \DeclareRobustCommand{\inactive}{\textcolor{inactivecolor}}% Use color to highlight. } {% No; \DeclareRobustCommand{\inactive}{\monochromeinactive}% Use monochrome default. } \providecommand{\monochromeinactive}{}% What should \inactive do if colors can't be used? We provide a hook for % user definitions. % \end{macrocode} % \end{macro} % % \begin{macro}{\present} % |\present[]{}| puts its argument into an |\fbox| with coloured background. % If || is given, it is added to the left of the box without taking any space, i.e. it will overlap text to the left % of the box. This addition is useful mainly for adding `constraints' to things presented in a description or center % environment. % \begin{macrocode} \ifthenelse{\boolean{colorhighlight@TP}}% Color highlighting enabled? {% Yes; use a colored box. \newcommand{\present}[2][]{\leavevmode\llap{\textbf{\footnotesize#1}\,}\fcolorbox{textcolor}{presentcolor}{#2}}% \newcommand{\mkpbox@TP}[1]{\fcolorbox{presentcolor}{presentcolor}{#1}}% Internal macro for use by \presentbox. } {% No; use an \fbox. \newcommand{\present}[2][]{\leavevmode\llap{\textbf{\footnotesize#1}\,}\fbox{#2}}% \newcommand{\mkpbox@TP}[1]{\fbox{#1}}% } % \end{macrocode} % \end{macro} % % \begin{environment}{presentbox} % The presentbox environment creates a coloured patch of width |\linewidth| with a minipage inside. If the % colorhighlight option is not given, an |\fbox| containing the minipage is created. % \begin{macrocode} \newsavebox{\pbox@TP}% Container for the minipage to be boxed. \newenvironment{presentbox}% {% \par\smallskip% First a small space to separate the area from preceding text. \begin{lrbox}{\pbox@TP}% Save the contents in a minipage inside \pbox@TP. \noindent \begin{minipage}{\linewidth-2\fboxsep-2\fboxrule}% Reduce the width of the minipage to leave space for the frame. \replacecolor{presentcolor}{pagecolor}% If \present is used inside the colored area... }% {% \end{minipage} \end{lrbox}% \noindent\mkpbox@TP{\usebox{\pbox@TP}}% This typesets the saved minipage inside the coloured area. \smallskip% A small space to separate the area from succeding text. \par } % \end{macrocode} % \end{environment} % % % \subsection{Structured rules, box and page backgrounds} % % \subsubsection{Structured rules} % % Some configurable defaults for rules and box backgrounds. % % Default number of stripes for gradient rules and box backgrounds. % \begin{macrocode} \newcommand{\rulestripes}{10} % \end{macrocode} % Default stripe overlap for avoiding `gaps' in color gradients. % \begin{macrocode} \newcommand{\stripeoverlap}{.15pt} % \end{macrocode} % Default gradient progression for rules and box backgrounds (single gradients or first part of double gradients). % \begin{macrocode} \newcommand{\rulefirstgradprogression}{1} % \end{macrocode} % Default gradient progression for rules and box backgrounds (second part of double gradients). % \begin{macrocode} \newcommand{\rulesecondgradprogression}{1} % \end{macrocode} % Default position of the `middle' color of a double gradient. % \begin{macrocode} \newcommand{\rulegradmidpoint}{.5} % \end{macrocode} % % The following are used internally when making color gradients. % % \begin{macrocode} \newcounter{stripe@TP} \newcounter{stripes@TP} \newcommand{\firstgradprogression@TP}{1} \newcommand{\secondgradprogression@TP}{1} \newcounter{gradprogression@TP} \newcommand{\gradmidpoint@TP}{.5} % \end{macrocode} % % Special versions of |\mkfactor| which apply gradient progressions. % \begin{macrocode} \newcommand{\mkgradfirstfactor@TP}{\mkgradfactor@TP\firstgradprogression@TP} \newcommand{\mkgradsecondfactor@TP}{\mkgradfactor@TP\secondgradprogression@TP} \newcommand{\mkgradfactor@TP}[3]% Calculate a factor modified by a `progression' parameter. {% \mkfactor{#2}{#3}% Calculate the unmodified factor. \setcounter{gradprogression@TP}{#1}% Factor definition may contain a calc-expression. \ifthenelse{\value{gradprogression@TP}=1}{}% Progression value 1 is neutral. {% \ifthenelse{\value{gradprogression@TP}<0}% `Negative' progression? {% Yes. \@tempcnta-\value{gradprogression@TP}\relax% Complement progression wrt 0. \mkfactor{#2}{1-1pt*\real{#2}}% Complement factor definition wrt 1pt. } {\@tempcnta\value{gradprogression@TP}\relax}% No; Use progression as given. \whiledo{\the\@tempcnta>1}% Calculate (factor definition)^(progression). {\advance\@tempcnta by -1\relax\mkfactor{#2}{\real{#2}*\real{#2}}}% \ifthenelse{\value{gradprogression@TP}<0}% `Negative' progression? {% Yes. \mkfactor{#2}{1-1pt*\real{#2}}% Complement result wrt 1pt. } {}% }% } % \end{macrocode} % % \begin{macro}{\vgradrule} % |\vgradrule[][]{}[]{}[]{}{}| creates a % rule-like object consisting of a vertical color gradient composed of horizontal stripes. % % The topmost stripe has color |{}|, the bottommost stripe has color |{}|. Inbetween, color changes % gradually from top to bottom. % The colors are specified exactly as for the |\color| command: if the optional argument || is given, % || contains an explicit definition of a color from model ||, otherwise || % is the name of a defined color. The same holds for || and ||. % % The arguments |[]{}{}| work exactly as for the |\rule| command. % % The optional argument ||, if given, should contain a (calc expression for a) number specifying the number of % stripes. If || is not given, the default is the content of |\rulestripes| (default 10). % % There is one more parameter which is not given as an argument. The control sequence |\rulefirstgradprogression| should % expand to an (calc expression for an) integer. This value (default 1) controls the `order' of progression from % || to ||. % The default value 1 means linear progression. 2 means quadratic progression, i.e. color values `nearer' to % are reached `later' (the square of 0.5, for instance, is 0.25, i.e. in the geometric middle point of the rule % produced, the color gradient will have traveled only to one quarter of the `distance' between || and % ||). % 3 means cubic progression and so on. 0 and -1 mean the same as 1. -2 means quadratic progression ``from bottom to % top'', i.e. color values `nearer' to || are reached `earlier', and analogously for -3, -4, ... % % If you wish to give the second optional argument but not the first, just write |\vgradrule[][]|... % % \begin{macrocode} \newcommand{\vgradrule}[1][]% Pick up first optional argument: [] {% \let\firstgradprogression@TP=\rulefirstgradprogression% Use progression parameter for rules. \ifthenelse{\equal{#1}{}}% First optional argument given? {\setcounter{stripes@TP}{\rulestripes}}% No; use default value. {\setcounter{stripes@TP}{#1}}% Yes. \vgradrule@TP% Pick up []{}. } \newcommand{\vgradrule@TP}[2][]% Pick up next pair of arguments: []{}. {% \ifthenelse{\equal{#1}{}}% given? {\replacecolor{startcolor@TP}{#2}}% No; is a color name. {\definecolor{startcolor@TP}{#1}{#2}}% Yes; {}{} is a color definition. \@vgradrule@TP% Pick up []{}. } \newcommand{\@vgradrule@TP}[2][]% Pick up next pair of arguments: []{}. {% \ifthenelse{\equal{#1}{}} {\replacecolor{endcolor@TP}{#2}} {\definecolor{endcolor@TP}{#1}{#2}}% \@@vgradrule@TP% Pick up rule arguments and proceed. } % \end{macrocode} % Helper command for making \textbf{one} stripe. Can be overladed for making histograms. % \begin{macrocode} \newcommand{\hstripe@TP}[4]% {\hbox{{\setcolor@TP{stripecolor@TP}\rule{#2}{#3}}}#4} % \end{macrocode} % Main part of |\vgradrule|. % \begin{macrocode} \newcommand{\@@vgradrule@TP}[3][0pt]% {% \ifthenelse{\value{stripes@TP}<2}% A `pathological case' which can happen in animations: If 0 or 1 stripes are % requested, a division by zero error would be produced by the gradient code. {\mbox{{\setcolor@TP{startcolor@TP}\rule[#1]{#2}{#3}}}}% In this case, just produce a colored rule. {% \raisebox{#1}% Evaluate the argument of the rule. {% \vbox% A vbox with \offinterlineskip allows to align the stripes vertically. {% \offinterlineskip \setcounter{stripe@TP}{0}% Initialize the number of the current stripe. \whiledo{\value{stripe@TP}<\value{stripes@TP}} {% \mkgradfirstfactor@TP{\tmp@TP}% Make the weight for \colorbetween, based on the number of the current stripe {\value{stripe@TP}/(\value{stripes@TP}-1)}% and the first gradient progression. \colorbetween[\tmp@TP]{stripecolor@TP}{endcolor@TP}{startcolor@TP}% Calculate stripe color. \stepcounter{stripe@TP}% \ifthenelse{\value{stripe@TP}=\value{stripes@TP}}% Last stripe? {\hstripe@TP{\tmp@TP}{#2}{(#3)/\value{stripes@TP}}{}}% Yes; make stripe w/o overlap. {% No; add a kern to make stripes overlap. \hstripe@TP{\tmp@TP}{#2}{(#3)/\value{stripes@TP}+\stripeoverlap}{\kern-\stripeoverlap}% }% }% matches \whiledo{\value{stripe@TP}<\value{stripes@TP}}{% }% matches \vbox{% }% matches \raisebox{#1}{% }% matches second argument of \ifthenelse{\value{stripes@TP}<2} }% matches \newcommand{\@@vgradrule@TP}[3][0pt]{% % \end{macrocode} % \end{macro} % % \begin{macro}{\dblvgradrule} % |\dblvgradrule[][][]|\\ % | {}[]{}[]|\\ % | {}[]{}{}| % creates a rule-like object consisting of a vertical color gradient composed of horizontal stripes. % % The behaviour is exactly like |\vgradrule|, only in addition to the defined `start' and `end' color, there is an % additional defined `middle' color. The color gradient first progresses from the start to the middle color and then % from the middle to the end color. % % |[]{}| specify the middle color exactly as described for the other colors in the description of % |\vgradrule|. % % The additional optional parameter || is a fixed-point value specifying where in the produced gradient the % middle color is placed. 0 means the middle color replaces the start color; 1 means the middle color replaces the end % color; 0.5 means the middle color is placed in the geometric middle between start and end color. If || is not % given, the default is the content of |\rulegradmidpoint| (default 0.5). % % There is another parameter not passed as an argument: while |\rulefirstgradprogression| specifies the order of % progression from first to middle color as described for |\vgradrule|, |\rulesecondgradprogression| specifies the order of % progression from middle to end color. % % If you wish to give one from the first row of optional arguments but not the other(s), any one can be replaced by |[]| % to use the default. % % \begin{macrocode} \newcommand{\dblvgradrule}[1][]% Pick up first optional argument: [] {% \let\firstgradprogression@TP=\rulefirstgradprogression% Use progression parameters for rules. \let\secondgradprogression@TP=\rulesecondgradprogression \ifthenelse{\equal{#1}{}}% First optional argument given? {\let\gradmidpoint@TP=\rulegradmidpoint}% No; use default value. {\def\gradmidpoint@TP{#1}}% Yes. \dblvgradrule@TP% Pick up second optional argument. } \newcommand{\dblvgradrule@TP}[1][]% Pick up second optional argument: [] {% \ifthenelse{\equal{#1}{}} {\setcounter{stripes@TP}{\rulestripes}} {\setcounter{stripes@TP}{#1}}% \@dblvgradrule@TP } \newcommand{\@dblvgradrule@TP}[2][]% Pick up next pair of arguments: []{}. {% \ifthenelse{\equal{#1}{}} {\replacecolor{startcolor@TP}{#2}} {\definecolor{startcolor@TP}{#1}{#2}}% \@@dblvgradrule@TP } \newcommand{\@@dblvgradrule@TP}[2][]% Pick up next pair of arguments: []{}. {% \ifthenelse{\equal{#1}{}} {\replacecolor{midcolor@TP}{#2}} {\definecolor{midcolor@TP}{#1}{#2}}% \@@@dblvgradrule@TP } \newcommand{\@@@dblvgradrule@TP}[2][]% Pick up next pair of arguments: []{}. {% \ifthenelse{\equal{#1}{}} {\replacecolor{endcolor@TP}{#2}} {\definecolor{endcolor@TP}{#1}{#2}}% \@@@@dblvgradrule@TP% Pick up rule arguments and proceed. } \newcommand{\@@@@dblvgradrule@TP}[3][0pt]% Main part of \dblvgradrule. {% \ifthenelse{\value{stripes@TP}<2}% The gradient code is not equipped for making less than 2 stripes. {\mbox{{\setcolor@TP{midcolor@TP}\rule[#1]{#2}{#3}}}}% In this case, just produce a rule colored with the middle color. {% \raisebox{#1}% Evaluate the argument of the rule. {% \vbox% A vbox with \offinterlineskip allows to align the stripes {% vertically. \offinterlineskip \setcounter{stripe@TP}{0}% Initialize the number of the current stripe. \setcounter{tmpcnta@TP}% Number of the `middle' stripe. {\value{stripes@TP}*\real{\gradmidpoint@TP}}% \whiledo{\value{stripe@TP}<\value{tmpcnta@TP}}% Produce the upper part of the gradient. {% \mkgradfirstfactor@TP{\tmp@TP}% Make the weight for \colorbetween, based on the number of the {\value{stripe@TP}/\value{tmpcnta@TP}}% current stripe and the first gradient progression. \colorbetween[\tmp@TP]{stripecolor@TP}{midcolor@TP}{startcolor@TP}% Calculate stripe color. \hstripe@TP{\tmp@TP}% Make stripe with overlap. {#2}{(#3)/\value{stripes@TP}+\stripeoverlap}{\kern-\stripeoverlap}% This is the upper part, remember? \stepcounter{stripe@TP}% }% \stepcounter{tmpcnta@TP}% \ifthenelse{\value{stripes@TP}=\value{tmpcnta@TP}}% Only one stripe left to produce? {\hstripe@TP{1}{#2}{(#3)/\value{stripes@TP}}{}}% Just produce one stripe colored with the end color. {% \whiledo{\value{stripe@TP}<\value{stripes@TP}}% Produce the lower part of the gradient. {% \mkgradsecondfactor@TP{\tmp@TP}% Make the weight for \colorbetween. {(\value{stripe@TP}-\value{tmpcnta@TP}+1)/(\value{stripes@TP}-\value{tmpcnta@TP})}% \colorbetween[\tmp@TP]{stripecolor@TP}{endcolor@TP}{midcolor@TP}% Calculate stripe color. \stepcounter{stripe@TP}% \ifthenelse{\value{stripe@TP}=\value{stripes@TP}}% Last stripe? {\hstripe@TP{\tmp@TP}{#2}{(#3)/\value{stripes@TP}}{}}% Yes; make stripe w/o overlap. {% No; add kern to make stripes overlap. \hstripe@TP{\tmp@TP}{#2}{(#3)/\value{stripes@TP}+\stripeoverlap}{\kern-\stripeoverlap}% }% }% matches \whiledo{\value{stripe@TP}<\value{stripes@TP}}% }% matches second argument of \ifthenelse{\value{stripes@TP}=\value{tmpcnta@TP}}% }% matches \vbox{% }% matches \raisebox{#1}{% }% matches second argument of \ifthenelse{\value{stripes@TP}<2}% }% matches \newcommand{\@@@@dblvgradrule@TP}[3][0pt]% % \end{macrocode} % \end{macro} % % \begin{macro}{\hgradrule} % |\hgradrule[][]{}|\\ % | []{}[]{}{}| creates a % rule-like object consisting of a horizontal color gradient composed of vertical stripes. % % Parameters are exactly as those for |\vgradrule| (replacing `top' by `left' and `bottom' by `right'). See there for % explanations. % % \begin{macrocode} \newcommand{\hgradrule}[1][]% Pick up first optional argument: []. {% \let\firstgradprogression@TP=\rulefirstgradprogression% Use progression parameter for rules. \ifthenelse{\equal{#1}{}}% First optional argument given? {\setcounter{stripes@TP}{\rulestripes}}% No; use default value. {\setcounter{stripes@TP}{#1}}% Yes. \hgradrule@TP% Pick up []{}. } \newcommand{\hgradrule@TP}[2][]% Pick up next pair of arguments: []{}. {% \ifthenelse{\equal{#1}{}} {\replacecolor{startcolor@TP}{#2}} {\definecolor{startcolor@TP}{#1}{#2}}% \@hgradrule@TP } \newcommand{\@hgradrule@TP}[2][] {% \ifthenelse{\equal{#1}{}} {\replacecolor{endcolor@TP}{#2}} {\definecolor{endcolor@TP}{#1}{#2}}% \@@hgradrule@TP% Pick up rule arguments and proceed. } \newcommand{\vstripe@TP}[4]% Helper command for making _one_ stripe. Can be overladed for making historams. {{\setcolor@TP{stripecolor@TP}\rule{#2}{#3}#4}} \newcommand{\@@hgradrule@TP}[3][0pt]% Main part of \hgradrule. {% \ifthenelse{\value{stripes@TP}<2}% A `pathological case' which can happen in animations: If 0 or 1 stripes are % requested, a division by zero error would be produced by the gradient code. {\mbox{{\setcolor@TP{startcolor@TP}\rule[#1]{#2}{#3}}}}% In this case, just produce a colored rule. {% \raisebox{#1}% Evaluate the argument of the rule. {% \setcounter{stripe@TP}{0}% Initialize the number of the current stripe. \whiledo{\value{stripe@TP}<\value{stripes@TP}} {% \mkgradfirstfactor@TP{\tmp@TP}% Make the weight for \colorbetween, based on the number of the current stripe {\value{stripe@TP}/(\value{stripes@TP}-1)}% and the first gradient progression. \colorbetween[\tmp@TP]{stripecolor@TP}{endcolor@TP}{startcolor@TP}% Calculate stripe color. \stepcounter{stripe@TP}% \ifthenelse{\value{stripe@TP}=\value{stripes@TP}}% Last stripe? {\vstripe@TP{\tmp@TP}{(#2)/\value{stripes@TP}}{#3}{}}% Yes; make stripe w/o overlap. {% No; add a kern to make stripes overlap. \vstripe@TP{\tmp@TP}{(#2)/\value{stripes@TP}+\stripeoverlap}{#3}{\kern-\stripeoverlap}% }% }% matches \whiledo{\value{stripe@TP}<\value{stripes@TP}}{% }% matches \raisebox{#1}{% }% matches second argument of \ifthenelse{\value{stripes@TP}<2}% }% matches \newcommand{\@@hgradrule@TP}[3][0pt]{% % \end{macrocode} % \end{macro} % \begin{macro}{\dblhgradrule} % |\dblhgradrule[][][]|\\ % | {}[]{}[]|\\ % | {}[]{}{}| % creates a rule-like object consisting of a horizontal color gradient composed of vertical stripes. % % Parameters are exactly as those for |\dblvgradrule| (replacing `top' by `left' and `bottom' by `right'). See there for % explanations. % % \begin{macrocode} \newcommand{\dblhgradrule}[1][]% Pick up first optional argument: []. {% \let\firstgradprogression@TP=\rulefirstgradprogression% Use progression parameters for rules. \let\secondgradprogression@TP=\rulesecondgradprogression \ifthenelse{\equal{#1}{}}{\let\gradmidpoint@TP=\rulegradmidpoint}{\def\gradmidpoint@TP{#1}}% \dblhgradrule@TP } \newcommand{\dblhgradrule@TP}[1][]% Pick up second optional argument: []. {% \ifthenelse{\equal{#1}{}}{\setcounter{stripes@TP}{\rulestripes}}{\setcounter{stripes@TP}{#1}}% \@dblhgradrule@TP } \newcommand{\@dblhgradrule@TP}[2][]% Pick up next pair of arguments: []{}. {% \ifthenelse{\equal{#1}{}}{\replacecolor{startcolor@TP}{#2}}{\definecolor{startcolor@TP}{#1}{#2}}% \@@dblhgradrule@TP } \newcommand{\@@dblhgradrule@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{midcolor@TP}{#2}}{\definecolor{midcolor@TP}{#1}{#2}}% \@@@dblhgradrule@TP } \newcommand{\@@@dblhgradrule@TP}[2][] {% \ifthenelse{\equal{#1}{}} {\replacecolor{endcolor@TP}{#2}} {\definecolor{endcolor@TP}{#1}{#2}}% \@@@@dblhgradrule@TP% Pick up rule arguments and proceed. } \newcommand{\@@@@dblhgradrule@TP}[3][0pt]% Main part of \dblhgradrule. {% \ifthenelse{\value{stripes@TP}<2}% The gradient code is not equipped for making less than 2 stripes. {\mbox{{\setcolor@TP{midcolor@TP}\rule[#1]{#2}{#3}}}}% In this case, just produce a rule colored with the middle color. {% \raisebox{#1}% Evaluate the argument of the rule. {% \setcounter{stripe@TP}{0}% Initialize the number of the current stripe. \setcounter{tmpcnta@TP}% Number of the `middle' stripe. {\value{stripes@TP}*\real{\gradmidpoint@TP}}% \whiledo{\value{stripe@TP}<\value{tmpcnta@TP}}% Produce the left part of the gradient. {% \mkgradfirstfactor@TP{\tmp@TP}% Make the weight for \colorbetween, based on the number of the {\value{stripe@TP}/\value{tmpcnta@TP}}% current stripe and the first gradient progression. \colorbetween[\tmp@TP]{stripecolor@TP}{midcolor@TP}{startcolor@TP}% Calculate stripe color. \vstripe@TP{\tmp@TP}% Make stripe with overlap. {(#2)/\value{stripes@TP}+\stripeoverlap}{#3}{\kern-\stripeoverlap}% This is the left part, remember? \stepcounter{stripe@TP}% }% \stepcounter{tmpcnta@TP}% \ifthenelse{\value{stripes@TP}=\value{tmpcnta@TP}}% Only one stripe left to produce? {\vstripe@TP{1}{(#2)/\value{stripes@TP}}{#3}{}}% Just produce one stripe colored with the end color. {% \whiledo{\value{stripe@TP}<\value{stripes@TP}}% Produce the right part of the gradient. {% \mkgradsecondfactor@TP{\tmp@TP}% Make the weight for \colorbetween. {(\value{stripe@TP}-\value{tmpcnta@TP})/(\value{stripes@TP}-\value{tmpcnta@TP}-1)}% \colorbetween[\tmp@TP]{stripecolor@TP}{endcolor@TP}{midcolor@TP}% Calculate stripe color. \stepcounter{stripe@TP}% \ifthenelse{\value{stripe@TP}=\value{stripes@TP}}% Last stripe? {\vstripe@TP{\tmp@TP}{(#2)/\value{stripes@TP}}{#3}{}}% Yes; make stripe w/o overlap. {% Add kern to make stripes overlap. \vstripe@TP{\tmp@TP}{(#2)/\value{stripes@TP}+\stripeoverlap}{#3}{\kern-\stripeoverlap}% }% }% matches \whiledo{\value{stripe@TP}<\value{stripes@TP}}{% }% matches second argument of \ifthenelse{\value{stripes@TP}=\value{tmpcnta@TP}}% }% matches \raisebox{#1}{% }% matches second argument of \ifthenelse{\value{stripes@TP}<2}% }% matches \newcommand{\@@@@dblhgradrule@TP}[3][0pt]{% % \end{macrocode} % \end{macro} % % Clipbox stuff. The first part isn't used currently. % \begin{macrocode} % PDF: % \def\clipbox{\@ifnextchar[{\clipbox@}{\clipbox@[0pt]}} % \def\clipbox@[#1]#2{% % \begingroup % \setlength{\@tempdima}{#1}% % \setbox\@tempboxa=\hbox{% % \color@begingroup % #2% % \color@endgroup % }% % \leavevmode\hbox to \wd\@tempboxa{% % \@ifundefined{dimexpr}{% % \@defbp\x{-\@tempdima}% % \@tempdimc=\dp\@tempboxa % \advance\@tempdimc by \@tempdima % \@defbp\y{-\@tempdimc}% % \@tempdimc=\wd\@tempboxa % \advance\@tempdimc by 2\@tempdima % \@defbp\w{\@tempdimc}% % \@tempdimc=\dp\@tempboxa % \advance\@tempdimc by \ht\@tempboxa % \advance\@tempdimc by 2\@tempdima % \@defbp\h{\@tempdimc}% % \pdfliteral{% % q % gsave % \x\space\y\space\w\space\h\space re % rectangle % W n% make clip-path % }% % }{% e-TeX % \pdfliteral{% % q % gsave % \@dimtobp{-\@tempdima} % x % \@dimtobp{-\dp\@tempboxa-\@tempdima} % y % \@dimtobp{\wd\@tempboxa+2\@tempdima} % width % \@dimtobp{\dp\@tempboxa+\ht\@tempboxa+2\@tempdima} % height % re % rectangle % W n% make clip-path % }% % }% % \rlap{\unhbox\@tempboxa}% % \pdfliteral{% % Q% grestore % }% % \hss % }% % \endgroup % } % \begingroup\expandafter\expandafter\expandafter\endgroup % \expandafter\ifx\csname dimexpr\endcsname\relax % \def\@defbp#1#2{% % \setlength{\@tempdimb}{#2}% % \setlength{\@tempdimb}{.99626401\@tempdimb}% % \edef#1{\strip@pt\@tempdimb}% % } % \else % \def\@dimtobp#1{% % \strip@pt\dimexpr.99626401\dimexpr#1\relax\relax % } % \fi % % PS: % \def\clipbox{\@ifnextchar[{\clipbox@}{\clipbox@[0pt]}} % \def\clipbox@[#1]#2{% % \begingroup % \setlength{\@tempdima}{#1}% % \setbox\@tempboxa=\hbox{% % \color@begingroup % #2% % \color@endgroup % }% % \leavevmode\hbox to \wd\@tempboxa{% % \@ifundefined{dimexpr}{% % \@defpt\x{-\@tempdima}% % \@tempdimc=\ht\@tempboxa % \advance\@tempdimc by \@tempdima % \@defpt\y{-\@tempdimc}% % \@tempdimc=\wd\@tempboxa % \advance\@tempdimc by 2\@tempdima % \@defpt\w{\@tempdimc}% % \@tempdimc=\dp\@tempboxa % \advance\@tempdimc by \ht\@tempboxa % \advance\@tempdimc by 2\@tempdima % \@defpt\h{\@tempdimc}% % \special{ps:% % gsave % % SDict begin % % \x\space PTtoDVIPS \y\space PTtoDVIPS rmoveto % % currentpoint % % \w\space PTtoDVIPS \h\space PTtoDVIPS rectclip % % end% % }% % }{% e-TeX % \special{ps:% % gsave % % SDict begin % % \@dimtopt{-\@tempdima} PTtoDVIPS % x % \@dimtopt{-\ht\@tempboxa-\@tempdima} PTtoDVIPS % y % rmoveto currentpoint % % \@dimtopt{\wd\@tempboxa+2\@tempdima} PTtoDVIPS % width % \@dimtopt{\dp\@tempboxa+\ht\@tempboxa+2\@tempdima} % % PTtoDVIPS % height % rectclip % % end% % }% % }% % \rlap{\unhbox\@tempboxa}% % \special{ps:grestore}% % \hss % }% % \endgroup % } % \special{!% % /PTtoDVIPS{72.27 div Resolution mul}def% % % rectclip is a level 2 feature % /rectclip where{pop}{% % /rectclip{% % newpath % % 4 2 roll moveto % % exch dup 0 rlineto % % exch 0 exch rlineto % % neg 0 rlineto % % closepath % % clip % % newpath % % }bind def% % }% % ifelse% % } % \begingroup\expandafter\expandafter\expandafter\endgroup % \expandafter\ifx\csname dimexpr\endcsname\relax % \def\@defpt#1#2{% % \setlength{\@tempdimb}{#2}% % \edef#1{\strip@pt\@tempdimb}% % } % \else % \def\@dimtopt#1{% % \strip@pt\dimexpr#1\relax % } % \fi \ifpdf \providecommand{\clipbox}[2][\z@] {% \setlength{\@tempdima}{#1}% \setbox\@tempboxa= \hbox{\kern\@tempdima\vbox{\offinterlineskip\kern\@tempdima\hbox{#2}\kern\@tempdima}\kern\@tempdima}% \pdfxform\@tempboxa \leavevmode \hbox {% \kern-\@tempdima \vbox{\offinterlineskip\kern-\@tempdima\hbox{\pdfrefxform\pdflastxform}\kern-\@tempdima}% \kern-\@tempdima }% } \else \providecommand{\clipbox}[2][\z@]{\leavevmode\hbox{#2}} \fi % \end{macrocode} % % |\dgradslope| stuff. % \begin{macrocode} \newcommand{\dgradslope}{1,1} \newcounter{dgradhslope@TP} \newcounter{dgradvslope@TP} \def\setdgradslope(#1,#2){\setcounter{dgradhslope@TP}{#1}\setcounter{dgradvslope@TP}{#2}} % \end{macrocode} % % |\dgradrule| stuff. % \begin{macrocode} \newcommand{\dgradrule}[1][] {% \ifthenelse{\equal{#1}{}}{\expandafter\setdgradslope\expandafter(\dgradslope)}{\setdgradslope(#1)}% \dgradrule@TP } \newcommand{\dgradrule@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{startcolor@TP}{#2}}{\definecolor{startcolor@TP}{#1}{#2}}% \@dgradrule@TP } \newcommand{\@dgradrule@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{endcolor@TP}{#2}}{\definecolor{endcolor@TP}{#1}{#2}}% \@@dgradrule@TP } \newcommand{\dstripewd@TP}{.7pt} \newcommand{\@@dgradrule@TP}[3][0pt] {% \raisebox{#1} {% \thicklines \setcounter{stripe@TP}{0}% \setcounter{tmpcnta@TP}{1*\ratio{#3}{\dstripewd@TP}}% \setcounter{stripes@TP}{1*\ratio{#3}{\dstripewd@TP}+1*\ratio{#2}{\dstripewd@TP}}% \@xarg\c@dgradhslope@TP\@yarg\c@dgradvslope@TP \makebox[\dstripewd@TP] {% \whiledo{\value{stripe@TP}<\value{tmpcnta@TP}} {% \mkfactor{\tmp@TP}{\value{stripe@TP}/(\value{stripes@TP}-1)}% \colorbetween[\tmp@TP]{stripecolor@TP}{endcolor@TP}{startcolor@TP}% \setlength{\@linelen}{\dstripewd@TP*\value{stripe@TP}}% \raisebox{\dstripewd@TP*(\value{tmpcnta@TP}-\value{stripe@TP})} {\makebox[0pt]{{\setcolor@TP{stripecolor@TP}\hbox to 0pt{\@sline\hss}}}}% \stepcounter{stripe@TP}% }% }% \whiledo{\value{stripe@TP}<\value{stripes@TP}} {% \mkfactor{\tmp@TP}{\value{stripe@TP}/(\value{stripes@TP}-1)}% \colorbetween[\tmp@TP]{stripecolor@TP}{endcolor@TP}{startcolor@TP}% \makebox[\dstripewd@TP]{{\setcolor@TP{stripecolor@TP}.}}% \stepcounter{stripe@TP}% }% }% }% % \end{macrocode} % % \subsubsection{Structured box backgrounds} % % \begin{macro}{\vgradbox} % |\vgradbox[][]{}[]{}{}| creates an mbox containing % ||, which has a background made up of a vertical color gradient. In fact, the background exceeds the extent of % || by the value of |\fboxsep| on every side, just like the |\colorbox| command from the color package. % % The gradient background is constructed using the |\vgradrule| command; see the description of |\vgradrule| on the way the % gradient is constructed and on the meaning of the parameters ||, ||, ||, ||, % || and the additional parameter |\rulefirstgradprogression| which has the same meaning for |\vgradbox| as for % |\vgradrule|. % % \begin{macrocode} \newcommand{\vgradbox}[1][]% Pick up first optional argument: []. {% \let\firstgradprogression@TP=\rulefirstgradprogression% Use progression parameter for rules. \ifthenelse{\equal{#1}{}}% First optional argument given? {\setcounter{stripes@TP}{\rulestripes}}% No; use default value. {\setcounter{stripes@TP}{#1}}% Yes. \vgradbox@TP% Pick up remaining optional arguments. } \newcommand{\vgradbox@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{startcolor@TP}{#2}}{\definecolor{startcolor@TP}{#1}{#2}}% \@vgradbox@TP } \newcommand{\@vgradbox@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{endcolor@TP}{#2}}{\definecolor{endcolor@TP}{#1}{#2}}% \@@gradbox@TP\@@vgradrule@TP% Make a generic background box with vertical gradient background. } \newcommand{\@@gradbox@TP}[2]% Generic background box. {% \leavevmode% Make box behave like \mbox. \setbox\tempbox@TP \hbox{\kern\fboxsep{\set@color#2}\kern\fboxsep}% An \hbox containing plus additional white space. \rlap% Underlay box background with rule command passed as #1. {% #1[-\fboxsep-\dp\tempbox@TP]% Box depth augmented by `white' space. {\wd\tempbox@TP}% Space on the sides has already been added. {\ht\tempbox@TP+\dp\tempbox@TP+2\fboxsep}}% Total height. \box\tempbox@TP% Overlay box contents. }% % \end{macrocode} % \end{macro} % % \begin{macro}{\hgradbox} % |\hgradbox[][]{}[]{}{}| acts like |\vgradbox|, but creates % the background using |\hgradrule|. See comments above. % % \begin{macrocode} \newcommand{\hgradbox}[1][] {% \let\secondgradprogression@TP=\rulesecondgradprogression \ifthenelse{\equal{#1}{}}{\setcounter{stripes@TP}{\rulestripes}}{\setcounter{stripes@TP}{#1}}% \hgradbox@TP } \newcommand{\hgradbox@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{startcolor@TP}{#2}}{\definecolor{startcolor@TP}{#1}{#2}}% \@hgradbox@TP } \newcommand{\@hgradbox@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{endcolor@TP}{#2}}{\definecolor{endcolor@TP}{#1}{#2}}% \@@gradbox@TP\@@hgradrule@TP } % \end{macrocode} % \end{macro} % % \begin{macro}{\dblvgradbox} % |\dblvgradbox[][][]|\\ % | {}[]{}[]{}{}| % acts like |\vgradbox|, but creates the background using |\dblvgradrule| (hence the additional parameters). See comments % above (and the description of |\dblvgradrule| concerning the meaning of |\dblvgradrule| parameters). % % \begin{macrocode} \newcommand{\dblvgradbox}[1][] {% \let\firstgradprogression@TP=\rulefirstgradprogression% Use progression parameters for rules. \let\secondgradprogression@TP=\rulesecondgradprogression \ifthenelse{\equal{#1}{}}{\let\gradmidpoint@TP=\rulegradmidpoint}{\def\gradmidpoint@TP{#1}}% \dblvgradbox@TP } \newcommand{\dblvgradbox@TP}[1][] {% \ifthenelse{\equal{#1}{}}{\setcounter{stripes@TP}{\rulestripes}}{\setcounter{stripes@TP}{#1}}% \@dblvgradbox@TP } \newcommand{\@dblvgradbox@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{startcolor@TP}{#2}}{\definecolor{startcolor@TP}{#1}{#2}}% \@@dblvgradbox@TP } \newcommand{\@@dblvgradbox@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{midcolor@TP}{#2}}{\definecolor{midcolor@TP}{#1}{#2}}% \@@@dblvgradbox@TP } \newcommand{\@@@dblvgradbox@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{endcolor@TP}{#2}}{\definecolor{endcolor@TP}{#1}{#2}}% \@@gradbox@TP\@@@@dblvgradrule@TP } % \end{macrocode} % \end{macro} % % \begin{macro}{\dblhgradbox} % |\dblhgradbox[][][]|\\ % | {}[]{}[]{}{}| % acts like |\dblvgradbox|, but creates the background using |\dblhgradrule|. See comments above. % % \begin{macrocode} \newcommand{\dblhgradbox}[1][] {% \let\firstgradprogression@TP=\rulefirstgradprogression \let\secondgradprogression@TP=\rulesecondgradprogression \ifthenelse{\equal{#1}{}}{\let\gradmidpoint@TP=\rulegradmidpoint}{\def\gradmidpoint@TP{#1}}% \dblhgradbox@TP } \newcommand{\dblhgradbox@TP}[1][] {% \ifthenelse{\equal{#1}{}}{\setcounter{stripes@TP}{\rulestripes}}{\setcounter{stripes@TP}{#1}}% \@dblhgradbox@TP } \newcommand{\@dblhgradbox@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{startcolor@TP}{#2}}{\definecolor{startcolor@TP}{#1}{#2}}% \@@dblhgradbox@TP } \newcommand{\@@dblhgradbox@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{midcolor@TP}{#2}}{\definecolor{midcolor@TP}{#1}{#2}}% \@@@dblhgradbox@TP } \newcommand{\@@@dblhgradbox@TP}[2][] {% \ifthenelse{\equal{#1}{}}{\replacecolor{endcolor@TP}{#2}}{\definecolor{endcolor@TP}{#1}{#2}}% \@@gradbox@TP\@@@@dblhgradrule@TP } % \end{macrocode} % \end{macro} % % \subsubsection{Structured page backgrounds} % % \begin{macro}{\backgroundstyle} % |\backgroundstyle[]{