Reverted menu-left-example.png back to original and cleaned up menu-top-example to...
[freeside.git] / etc / background.sty
1 %%
2 %% This is file `background.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% background.dtx  (with options: `package')
8 %% 
9 %% Copyright (C) 2009, 2012, 2014 Gonzalo Medina (gmedinaar@unal.edu.co)
10 %% 
11 %% --------------------------------------------------------------------------
12 %% 
13 %% This work may be distributed and/or modified under the
14 %% conditions of the LaTeX Project Public License, either version 1.3
15 %% of this license or (at your option) any later version.
16 %% The latest version of this license is in
17 %%   http://www.latex-project.org/lppl.txt
18 %% and version 1.3 or later is part of all distributions of LaTeX
19 %% version 2003/12/01 or later.
20 %% 
21 %% This work has the LPPL maintenance status "maintained".
22 %% 
23 %% The Current Maintainer of this work is Gonzalo Medina.
24 %% 
25 %% This work consists of the files background.ins, background.dtx,
26 %% and the derived files background.sty and background.pdf.
27 %% 
28
29
30
31
32
33
34
35
36
37
38 \NeedsTeXFormat{LaTeX2e}
39 \ProvidesPackage{background}[2014/03/04 v2.1 background material]
40 \@ifpackageloaded{xkeyval}{}{\RequirePackage{xkeyval}}
41 \@ifpackageloaded{tikz}{}{\RequirePackage{tikz}}
42 \@ifpackageloaded{everypage}{}{\RequirePackage{everypage}}
43 \@ifpackageloaded{afterpage}{}{\RequirePackage{afterpage}}
44 \DeclareOptionX[BG]<background>{contents}{%
45   \def\Background@Contents{#1}}
46 \DeclareOptionX[BG]<background>{color}{%
47   \def\Background@Color{#1}}
48 \DeclareOptionX[BG]<background>{angle}{%
49   \def\Background@Angle{#1}}
50 \DeclareOptionX[BG]<background>{opacity}{%
51   \def\Background@Opacity{#1}}
52 \DeclareOptionX[BG]<background>{scale}{%
53   \def\Background@Scale{#1}}
54 \DeclareOptionX[BG]<background>{position}{%
55   \def\Background@Position{#1}}
56 \DeclareOptionX[BG]<background>{anchor}{%
57   \def\Background@Anchor{#1}}
58 \DeclareOptionX[BG]<background>{nodeanchor}{%
59   \def\Background@NodeAnchor{#1}}
60 \DeclareOptionX[BG]<background>{hshift}{%
61   \def\Background@HShift{#1}}
62 \DeclareOptionX[BG]<background>{vshift}{%
63   \def\Background@VShift{#1}}
64
65 \newif\ifbg@some
66   \bg@somefalse
67
68 \define@choicekey+[BG]{background}{pages}[\val\nr]{all,some}{%
69   \ifcase\nr\relax
70     \bg@somefalse
71   \or
72     \bg@sometrue
73   \fi
74 }{%
75   \PackageWarning{background}{erroneous input ignored}%
76 }
77
78 \define@choicekey+[BG]{background}{placement}[\val\nr]{center,bottom,top}{%
79   \ifcase\nr\relax
80     \renewcommand\Background@Position{current page.center}%
81     \renewcommand\Background@Anchor{}%
82     \renewcommand\Background@Angle{60}
83   \or
84     \renewcommand\Background@Position{current page.south}%
85     \renewcommand\Background@Anchor{above}%
86     \renewcommand\Background@Angle{0}%
87   \or
88     \renewcommand\Background@Position{current page.north}%
89     \renewcommand\Background@Anchor{below}%
90     \renewcommand\Background@Angle{0}%
91   \fi
92 }{%
93   \PackageWarning{background}{erroneous input ignored}%
94 }
95 \define@boolkey+[BG]{background}{firstpage}{%
96   \ifBG@background@firstpage
97     \bg@sometrue%
98     \AtBeginDocument{\BgThispage}%
99   \else
100     \bg@somefalse%
101   \fi
102 }{%
103   \PackageWarning{background}{erroneous input ignored}%
104 }
105
106 \DeclareOptionX[BG]<background>{all}{\bg@somefalse}
107 \DeclareOptionX[BG]<background>{some}{\bg@sometrue}
108 \DeclareOptionX[BG]<background>{center}{%
109   \renewcommand\Background@Position{current page.center}%
110   \renewcommand\Background@Anchor{}%
111   \renewcommand\Background@Angle{60}}
112 \DeclareOptionX[BG]<background>{bottom}{%
113   \renewcommand\Background@Position{current page.south}%
114   \renewcommand\Background@Anchor{above}%
115   \renewcommand\Background@Angle{0}%
116   \renewcommand\Background@Scale{8}}
117 \DeclareOptionX[BG]<background>{top}{%
118   \renewcommand\Background@Position{current page.north}%
119   \renewcommand\Background@Anchor{below}%
120   \renewcommand\Background@Angle{0}%
121   \renewcommand\Background@Scale{8}}
122
123
124 \ExecuteOptions{all,center}
125
126
127 \DeclareOptionX*{\PackageWarningNoLine{background}{Option '\CurrentOption' ignored}}
128
129 \ExecuteOptionsX[BG]<background>{%
130   firstpage=false,
131   contents=Draft,%
132   color=red!45,%
133   angle=60,%
134   opacity=0.5,%
135   scale=10,%
136   position=current page.center,%
137   anchor={},%
138   nodeanchor={center},%
139   hshift=0pt,%
140   vshift=0pt%
141 }
142
143 \ProcessOptionsX[BG]<background>
144 \DeclareRobustCommand*\backgroundsetup[1]{%
145   \setkeys[BG]{background}{#1}
146 }
147
148 \newcommand\bg@material{%
149   \begin{tikzpicture}[remember picture,overlay,scale=\Background@Scale]
150   \node[
151     rotate=\Background@Angle,
152     scale=\Background@Scale,
153     opacity=\Background@Opacity,
154     anchor=\Background@NodeAnchor,
155     xshift=\Background@HShift,
156     yshift=\Background@VShift,
157     color=\Background@Color,
158     inner sep=0pt
159     ]
160     at (\Background@Position) [\Background@Anchor]
161       {\Background@Contents};
162   \end{tikzpicture}}%
163 \newcommand\BgThispage{\AddThispageHook{\bg@material}}
164
165 \newcommand\NoBgThispage{%
166   \let\oldbg@material\bg@material\renewcommand\bg@material{}%
167   \afterpage{\AddEverypageHook{\oldbg@material}}}
168
169 \ifbg@some
170   \AddThispageHook{}
171 \else
172   \AddEverypageHook{\bg@material}
173 \fi
174
175 \newcommand\SetBgContents[1]{%
176   \def\Background@Contents{#1}}
177 \newcommand\SetBgAngle[1]{%
178   \def\Background@Angle{#1}}
179 \newcommand\SetBgColor[1]{%
180   \def\Background@Color{#1}}
181 \newcommand\SetBgScale[1]{%
182   \def\Background@Scale{#1}}
183 \newcommand\SetBgVshift[1]{%
184   \def\Background@VShift{#1}}
185 \newcommand\SetBgHshift[1]{%
186   \def\Background@HShift{#1}}
187 \newcommand\SetBgPosition[1]{%
188   \def\Background@Position{#1}}
189 \newcommand\SetBgAnchor[1]{%
190   \def\Background@Anchor{#1}}
191 \newcommand\SetBgOpacity[1]{%
192   \def\Background@Opacity{#1}}
193
194 \let\BgMaterial\bg@material
195
196 \AtEndDocument{\clearpage}
197 \endinput
198 %%
199 %% End of file `background.sty'.