summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/background/background.sty
blob: 314c090a90a62c75b9cc9098011852168f0f4500 (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
%%
%% This is file `background.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% background.dtx  (with options: `package')
%% 
%% Copyright (C) 2009 Gonzalo Medina (gmedinaar@unal.edu.co)
%% 
%% --------------------------------------------------------------------------
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainer of this work is Gonzalo Medina.
%% 
%% This work consists of the files background.ins, background.dtx,
%% and the derived files background.sty and background.pdf.
%% 
 % \end{center}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{background}[2009/11/07 v1.0 bg material]

\RequirePackage{everypage}
\RequirePackage{tikz}
\RequirePackage{afterpage}

\newif\ifbg@some
  \bg@somefalse

\def\bg@contents{Draft}
\def\bg@color{red!45}
\def\bg@angle{60}
\def\bg@opacity{.5}
\def\bg@scale{15}
\def\bg@position{current page.center}
\def\bg@anchor{}
\def\bg@hshift{0}
\def\bg@vshift{0}

\DeclareOption{all}{\bg@somefalse}
\DeclareOption{some}{\bg@sometrue}
\DeclareOption{center}{%
  \def\bg@position{current page.center}%
  \def\bg@anchor{}%
  \def\bg@angle{60}}
\DeclareOption{bottom}{%
  \def\bg@position{current page.south}%
  \def\bg@anchor{above}%
  \def\bg@angle{0}%
  \def\bg@scale{8}}
\DeclareOption{top}{%
  \def\bg@position{current page.north}%
  \def\bg@anchor{below}%
  \def\bg@angle{0}%
  \def\bg@scale{8}}

\ExecuteOptions{all,center}
\ProcessOptions

\newcommand*\SetBgContents[1]{%
  \def\bg@contents{#1}}
\newcommand*\SetBgColor[1]{%
  \def\bg@color{#1}}
\newcommand*\SetBgAngle[1]{%
  \def\bg@angle{#1}}
\newcommand*\SetBgOpacity[1]{%
  \def\bg@opacity{#1}}
\newcommand*\SetBgScale[1]{%
  \def\bg@scale{#1}}
\newcommand*\SetBgPosition[1]{%
  \def\bg@position{#1}}
\newcommand*\SetBgAnchor[1]{%
  \def\bg@anchor{#1}}
\newcommand*\SetBgHshift[1]{%
  \def\bg@hshift{#1}}
\newcommand*\SetBgVshift[1]{%
  \def\bg@vshift{#1}}

\newcommand\bg@material{%
  \begin{tikzpicture}[remember picture,overlay]
  \node [rotate=\bg@angle,scale=\bg@scale,opacity=\bg@opacity,%
    xshift=\bg@hshift,yshift=\bg@vshift,color=\bg@color]
    at (\bg@position) [\bg@anchor]  {\bg@contents};
  \end{tikzpicture}}%
\newcommand\BgThispage{\AddThispageHook{\bg@material}}

\newcommand\NoBgThispage{%
  \let\oldbg@material\bg@material\renewcommand\bg@material{}%
  \afterpage{\AddEverypageHook{\oldbg@material}}}

\ifbg@some
  \AddThispageHook{}
\else
  \AddEverypageHook{\bg@material}
\fi
\endinput
%%
%% End of file `background.sty'.