2 %% This is file `background.sty',
3 %% generated with the docstrip utility.
5 %% The original source files were:
7 %% background.dtx (with options: `package')
9 %% Copyright (C) 2009, 2012, 2014 Gonzalo Medina (gmedinaar@unal.edu.co)
11 %% --------------------------------------------------------------------------
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.
21 %% This work has the LPPL maintenance status "maintained".
23 %% The Current Maintainer of this work is Gonzalo Medina.
25 %% This work consists of the files background.ins, background.dtx,
26 %% and the derived files background.sty and background.pdf.
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}}
68 \define@choicekey+[BG]{background}{pages}[\val\nr]{all,some}{%
75 \PackageWarning{background}{erroneous input ignored}%
78 \define@choicekey+[BG]{background}{placement}[\val\nr]{center,bottom,top}{%
80 \renewcommand\Background@Position{current page.center}%
81 \renewcommand\Background@Anchor{}%
82 \renewcommand\Background@Angle{60}
84 \renewcommand\Background@Position{current page.south}%
85 \renewcommand\Background@Anchor{above}%
86 \renewcommand\Background@Angle{0}%
88 \renewcommand\Background@Position{current page.north}%
89 \renewcommand\Background@Anchor{below}%
90 \renewcommand\Background@Angle{0}%
93 \PackageWarning{background}{erroneous input ignored}%
95 \define@boolkey+[BG]{background}{firstpage}{%
96 \ifBG@background@firstpage
98 \AtBeginDocument{\BgThispage}%
103 \PackageWarning{background}{erroneous input ignored}%
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}}
124 \ExecuteOptions{all,center}
127 \DeclareOptionX*{\PackageWarningNoLine{background}{Option '\CurrentOption' ignored}}
129 \ExecuteOptionsX[BG]<background>{%
136 position=current page.center,%
138 nodeanchor={center},%
143 \ProcessOptionsX[BG]<background>
144 \DeclareRobustCommand*\backgroundsetup[1]{%
145 \setkeys[BG]{background}{#1}
148 \newcommand\bg@material{%
149 \begin{tikzpicture}[remember picture,overlay,scale=\Background@Scale]
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,
160 at (\Background@Position) [\Background@Anchor]
161 {\Background@Contents};
163 \newcommand\BgThispage{\AddThispageHook{\bg@material}}
165 \newcommand\NoBgThispage{%
166 \let\oldbg@material\bg@material\renewcommand\bg@material{}%
167 \afterpage{\AddEverypageHook{\oldbg@material}}}
172 \AddEverypageHook{\bg@material}
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}}
194 \let\BgMaterial\bg@material
196 \AtEndDocument{\clearpage}
199 %% End of file `background.sty'.