From 35f8085a57171a8fc9bd16a32df711bc517358d3 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 13 Aug 2012 22:36:56 +0000 Subject: background (13aug12) git-svn-id: svn://tug.org/texlive/trunk@27390 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/background/background.sty | 194 +++++++++++++++------ 1 file changed, 137 insertions(+), 57 deletions(-) (limited to 'Master/texmf-dist/tex/latex') diff --git a/Master/texmf-dist/tex/latex/background/background.sty b/Master/texmf-dist/tex/latex/background/background.sty index 314c090a90a..e746a4e3311 100644 --- a/Master/texmf-dist/tex/latex/background/background.sty +++ b/Master/texmf-dist/tex/latex/background/background.sty @@ -6,7 +6,7 @@ %% %% background.dtx (with options: `package') %% -%% Copyright (C) 2009 Gonzalo Medina (gmedinaar@unal.edu.co) +%% Copyright (C) 2009-2012 Gonzalo Medina (gmedinaar@unal.edu.co) %% %% -------------------------------------------------------------------------- %% @@ -25,71 +25,128 @@ %% 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} + + + + + + + + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{background}[2012/08/06 v2.0 background material] +\@ifpackageloaded{xkeyval}{}{\RequirePackage{xkeyval}} +\@ifpackageloaded{tikz}{}{\RequirePackage{tikz}} +\@ifpackageloaded{everypar}{}{\RequirePackage{everypage}} +\@ifpackageloaded{afterpage}{}{\RequirePackage{afterpage}} +\DeclareOptionX[BG]{contents}{% + \def\Background@Contents{#1}} +\DeclareOptionX[BG]{color}{% + \def\Background@Color{#1}} +\DeclareOptionX[BG]{angle}{% + \def\Background@Angle{#1}} +\DeclareOptionX[BG]{opacity}{% + \def\Background@Opacity{#1}} +\DeclareOptionX[BG]{scale}{% + \def\Background@Scale{#1}} +\DeclareOptionX[BG]{position}{% + \def\Background@Position{#1}} +\DeclareOptionX[BG]{anchor}{% + \def\Background@Anchor{#1}} +\DeclareOptionX[BG]{hshift}{% + \def\Background@HShift{#1}} +\DeclareOptionX[BG]{vshift}{% + \def\Background@VShift{#1}} \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}} +\define@choicekey+[BG]{background}{pages}[\val\nr]{all,some}{% + \ifcase\nr\relax + \bg@somefalse + \or + \bg@sometrue + \fi +}{% + \PackageWarning{background}{erroneous input ignored}% +} + +\define@choicekey+[BG]{background}{placement}[\val\nr]{center,bottom,top}{% + \ifcase\nr\relax + \renewcommand\Background@Position{current page.center}% + \renewcommand\Background@Anchor{}% + \renewcommand\Background@Angle{60} + \or + \renewcommand\Background@Position{current page.south}% + \renewcommand\Background@Anchor{above}% + \renewcommand\Background@Angle{0}% + \or + \renewcommand\Background@Position{current page.north}% + \renewcommand\Background@Anchor{below}% + \renewcommand\Background@Angle{0}% + \fi +}{% + \PackageWarning{background}{erroneous input ignored}% +} +\define@boolkey+[BG]{background}{firstpage}{% + \ifBG@background@firstpage + \bg@sometrue% + \AtBeginDocument{\BgThispage}% + \else + \bg@somefalse% + \fi +}{% + \PackageWarning{background}{erroneous input ignored}% +} + +\DeclareOptionX[BG]{all}{\bg@somefalse} +\DeclareOptionX[BG]{some}{\bg@sometrue} +\DeclareOptionX[BG]{center}{% + \renewcommand\Background@Position{current page.center}% + \renewcommand\Background@Anchor{}% + \renewcommand\Background@Angle{60}} +\DeclareOptionX[BG]{bottom}{% + \renewcommand\Background@Position{current page.south}% + \renewcommand\Background@Anchor{above}% + \renewcommand\Background@Angle{0}% + \renewcommand\Background@Scale{8}} +\DeclareOptionX[BG]{top}{% + \renewcommand\Background@Position{current page.north}% + \renewcommand\Background@Anchor{below}% + \renewcommand\Background@Angle{0}% + \renewcommand\Background@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}} + + +\DeclareOptionX*{\PackageWarning{background}{‘ \CurrentOption’ ignored}} + +\ExecuteOptionsX[BG]{% + firstpage=false, + contents=Draft,% + color=red!45,% + angle=60,% + opacity=0.5,% + scale=10,% + position=current page.center,% + anchor={},% + hshift=0,% + vshift=0% +} + +\ProcessOptionsX[BG] +\DeclareRobustCommand*\backgroundsetup[1]{% + \setkeys[BG]{background}{#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}; + \begin{tikzpicture}[remember picture,overlay,scale=\Background@Scale] + \node [rotate=\Background@Angle,scale=\Background@Scale, + opacity=\Background@Opacity,% + xshift=\Background@HShift,yshift=\Background@VShift,color=\Background@Color] + at (\Background@Position) [\Background@Anchor] {\Background@Contents}; \end{tikzpicture}}% \newcommand\BgThispage{\AddThispageHook{\bg@material}} @@ -102,6 +159,29 @@ \else \AddEverypageHook{\bg@material} \fi + +\newcommand\SetBgContents[1]{% + \def\Background@Contents{#1}} +\newcommand\SetBgAngle[1]{% + \def\Background@Angle{#1}} +\newcommand\SetBgColor[1]{% + \def\Background@Color{#1}} +\newcommand\SetBgScale[1]{% + \def\Background@Scale{#1}} +\newcommand\SetBgVshift[1]{% + \def\Background@VShift{#1}} +\newcommand\SetBgHshift[1]{% + \def\Background@HShift{#1}} +\newcommand\SetBgPosition[1]{% + \def\Background@Position{#1}} +\newcommand\SetBgAnchor[1]{% + \def\Background@Anchor{#1}} +\newcommand\SetBgOpacity[1]{% + \def\Background@Opacity{#1}} + +\let\BgMaterial\bg@material + +\AtEndDocument{\clearpage} \endinput %% %% End of file `background.sty'. -- cgit v1.2.3