summaryrefslogtreecommitdiff
path: root/support/ppower4/background.sty
blob: a83880837e737475936748f01129fb0a1ac96711 (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
%% background.sty                                   26 Apr 2002
%%-------------------------------------------------------------
%% History:
%% added options ignore and dvipdfm
%% runs with vlatex and dvipdfm                     10 Nov 2001
%% added some macros for including things into      26 Apr 2002
%% the background:
%%   \bgadd{...}         add something to the top left corner
%%   \bgaddcenter{...}   add something to the center
%%   \bgclear            clear all added elements
%% examples:
%%   \bgadd{\vspace{1cm}\hspace{2cm}\includegraphics[width=3cm]{pic.png}}
%%   \bgcenter{Centered Text}
%%
%%
%% Take care: because we have to insert a pdf comment starting with
%% the letter '%' the catcode of '%' will be changed temporarily.



%% Options
\newif\ifbackground@ignore    \background@ignorefalse
\newif\ifbackground@dvipdfm   \background@dvipdfmfalse
\newif\ifbackground@bgadd     \background@bgaddfalse

\DeclareOption{ignore}{\background@ignoretrue}
\DeclareOption{dvipdfm}{\background@dvipdfmtrue}
\DeclareOption{bgadd}{\background@bgaddtrue}

\ProcessOptions


%% requires package pause.sty
\ifbackground@dvipdfm
  \RequirePackage[dvipdfm]{pause}
\else
  \RequirePackage{pause}
\fi


%%
%% background picture macros, based on a macro by
%% Rolf Niepraschk (niepraschk@ptb.de)
%%

\ifbackground@bgadd
  \RequirePackage{eso-pic}

  \ifbackground@ignore
     \def\bgadd#1{}
     \def\bgaddcenter#1{}
     \def\bgclear{}
  \else
     \def\bgadd#1{%
        \AddToShipoutPicture{
          \setlength{\unitlength}{1pt}% default
           \put(0,\strip@pt\paperheight){%
              \parbox[t][\paperheight]{\paperwidth}{\vspace{0pt}#1}
           }
        }
     }

     \def\bgaddcenter#1{%
         \bgadd{%
           \vfill
           \centering#1
           \vfill
         }
     }

     \def\bgclear{\ClearShipoutPicture}
  \fi
\fi



\def\hpagecolor{\@ifnextchar [{\bg@hpagecolorTwo}{\bg@hpagecolor}}%
\def\vpagecolor{\@ifnextchar [{\bg@vpagecolorTwo}{\bg@vpagecolor}}%


\ifbackground@ignore
   \ifx\pagecolor\undefined
     % a dummy definition
     \newcommand\pagecolor[1]{}%
     \message{Warning, pagecolor definitions ignored for non pdf processing}%
   \fi
   \def\bg@hpagecolorTwo[#1]#2{}%
   \def\bg@vpagecolorTwo[#1]#2{}%
   \def\bg@hpagecolor#1{}%
   \def\bg@vpagecolor#1{}%
\else
{\catcode`\%=11\catcode`\!=14 !make '!' the comment character for now
\gdef\pagecolor#1{\@ifundefined{\string\color @#1}!
  {\message{pagecolor: color #1 is undefined}}!
  { \pdfliteral{%mbackground \pppp@colortostring{#1}}}!
      }!
\gdef\bg@vpagecolorTwo[#1]#2{\@ifundefined{\string\color @#1}!
  {\message{vpagestripes: color #1 is undefined}}!
  {\@ifundefined{\string\color @#2}!
  {\message{vpagestripes: color #2 is undefined}}!
  {\pdfliteral{%gradbackground vt \pppp@colortostring{#1}/\pppp@colortostring{#2}}}}!
      }!
\gdef\bg@hpagecolorTwo[#1]#2{\@ifundefined{\string\color @#1}!
  {\message{pagestripes: color #1 is undefined}}!
  {\@ifundefined{\string\color @#2}!
  {\message{pagestripes: color #2 is undefined}}!
  {\pdfliteral{%gradbackground ht \pppp@colortostring{#1}/\pppp@colortostring{#2}}}}!
      }!
\gdef\bg@hpagecolor#1{\@ifundefined{\string\color @#1}!
  {\message{hpagecolor: color #1 is undefined}}!
  {\pdfliteral{%gradbackground ho \pppp@colortostring{#1}}}}!
\gdef\bg@vpagecolor#1{\@ifundefined{\string\color @#1}!
  {\message{vpagecolor: color #1 is undefined}}!
  {\pdfliteral{%gradbackground vo \pppp@colortostring{#1}}}}!
}%
\fi