summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pagecolor/pagecolor.sty
blob: 81b5fe7ee6ba6a48d893cc38d47f00b048690364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
%%
%% This is file `pagecolor.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pagecolor.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Project: pagecolor
%% Version: 2012/02/23 v1.0e
%% 
%% Copyright (C) 2011 - 2012 by
%%     H.-Martin M"unch <Martin dot Muench at Uni-Bonn dot de>
%% 
%% The usual disclaimer applies:
%% If it doesn't work right that's your problem.
%% (Nevertheless, send an e-mail to the maintainer
%%  when you find an error in this package.)
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainer of this work is H.-Martin Muench.
%% 
%% This work consists of the main source file pagecolor.dtx,
%% the README, and the derived files
%%    pagecolor.sty, pagecolor.pdf,
%%    pagecolor.ins, pagecolor.drv,
%%    pagecolor-example.tex, pagecolor-example.pdf.
%% 
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\ProvidesPackage{pagecolor}[2012/02/23 v1.0e
            Provides thepagecolor (HMM)]
%% Provides the \thepagecolor, \thepagecolornone, \newpagecolor{...},
%% and \restorepagecolor commands.
\RequirePackage{kvoptions}[2010/12/23]% v3.10
%% \RequirePackage{ either color or xcolor }:
\@ifpackageloaded{xcolor}{% xcolor loaded
   \@ifpackagelater{xcolor}{2007/01/21}{%
      % 2007/01/21, v2.11, or even more recent: OK
    }{% else: older package version
      \PackageWarning{pagecolor}{%
        It is requested version `2007/01/21' of package\MessageBreak%
        xcolor, but only an older version is available.\MessageBreak%
       }%
     }%
 }{% xcolor not loaded
   \@ifpackageloaded{color}{%
      \RequirePackage{color}[2005/11/14]% v1.0j
    }{% \else
      \PackageWarning{pagecolor}{%
        The pagecolor package must be loaded after either\MessageBreak%
        package color or after package xcolor (at your\MessageBreak%
        option). Neither package was loaded before package\MessageBreak%
        pagecolor. Loading of package xcolor will now be\MessageBreak%
        tried automatically.\MessageBreak%
        When the pagecolor package is used with option\MessageBreak%
        pagecolor using a colour requiring e. g. x11names\MessageBreak%
        option for xcolor package, this will not work!\MessageBreak%
       }
     }% \fi
   \RequirePackage{xcolor}[2007/01/21]% v2.11
  }% \fi
%% pagecolor may work with earlier versions of LaTeX and the
%% packages, but this was not tested. Please consider updating
%% your LaTeX and packages to the most recent version
%% (if they are not already the most recent version).

\SetupKeyvalOptions{family=pagecolor,prefix=pagecolor@}
\DeclareStringOption[none]{pagecolor}% \pagecolor@pagecolor
\ProcessKeyvalOptions*

\let\origpagecolour\pagecolor

\renewcommand{\pagecolor}[1]{\@bsphack%
  \edef\pagecolourtmpa{#1}%
  \def\pagecolourtmpb{none}%
  \ifx\pagecolourtmpa\pagecolourtmpb
    \@ifundefined{nopagecolor}{%
      \PackageError{pagecolor}{%
        pagecolor=none requested but \string\nopagecolor\space unknown%
       }{%
        \string\pagecolor{none} was used, but the command %
        \string\nopagecolor\space is undefined.\MessageBreak%
        Please use another colour. pagecolor=white will be used now.%
        \MessageBreak%
        }%
      \gdef\thepagecolor{white}%
      \gdef\thepagecolornone{white}% although it should be "none"
      \origpagecolour{white}%
     }{%
      \nopagecolor%
     }%
  \else%
    \xdef\thepagecolor{#1}%
    \xdef\thepagecolornone{#1}%
    \origpagecolour{\thepagecolornone}%
  \fi%
  \@esphack%
}

\@ifundefined{nopagecolor}{%
  \PackageWarning{pagecolor}{%
    \string\nopagecolor\space is undefined.\MessageBreak%
    (As long as it is neither used anywhere\MessageBreak%
    \space nor defined later, that will be no problem.)\MessageBreak%
   }
  \AtEndDocument{%
  \@ifundefined{nopagecolor}{% no problem
    }{%
    \PackageError{pagecolor}{%
      \string\nopagecolor\space defined after loading package%
      \MessageBreak%
      pagecolor%
      }{\string\nopagecolor\space was defined after loading the %
       pagecolor package.\MessageBreak%
       Either define \string\nopagecolor\space earlier or load the %
       pagecolor package later.\MessageBreak%
      }
    }%
  }%
  }{% \else
    \let\orignopagecolour\nopagecolor
    \renewcommand{\nopagecolor}{%
      \xdef\thepagecolor{white}
      \xdef\thepagecolornone{none}
      \orignopagecolour
      }
  }

\def\pagecolourtmpb{none}
\ifx\pagecolor@pagecolor\pagecolourtmpb
  \@ifundefined{nopagecolor}{%
    \PackageWarning{pagecolor}{%
      Option pagecolor=none (maybe by default) used,\MessageBreak%
      but \string\nopagecolor\space is unknown. Please use another%
      \MessageBreak%
      option value; white will be used now.\MessageBreak%
     }
    \setkeys{pagecolor}{pagecolor=white}%
  }{% ok
  }%
\fi

\pagecolor{\pagecolor@pagecolor}

\newcommand{\newpagecolor}[1]{%
\xdef\pagecolourtmpc{\thepagecolornone}%
\pagecolor{#1}%
}

\newcommand{\restorepagecolor}{\pagecolor{\pagecolourtmpc}}

\gdef\pagecolourtmpc{\thepagecolor}

\endinput
%%
%% End of file `pagecolor.sty'.