summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/wallpaper/wallpaper.sty
blob: c0b79c586b7e52c3cb6ee145a5d3bd4cca501eff (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
%% 
%% This is file `wallpaper.sty' v 1.00
%%
%% Author Michael H.F. Wilkinson 
%%   December 22, 2004
%% 
%% Create background, either centered or tiled   
%% relies heavily on eso-pic.sty, corrects for changes in \hoffset 
%% by classes such as sciposter.cls
%% Problems, bugs and comments to 
%%        michael@cs.rug.nl

\ProvidesPackage{wallpaper}[2004/12/22, v1.00 easy wallpaper formatting (MHFW)]
\NeedsTeXFormat{LaTeX2e}[1995/06/01]

\RequirePackage{ifthen}
\RequirePackage{calc}
\RequirePackage{eso-pic}
\RequirePackage{graphicx}

\newlength{\wpXoffset}
\setlength{\wpXoffset}{-\hoffset}
\newlength{\wpYoffset}
\setlength{\wpYoffset}{0pt}
\newlength{\tileXoffset}
\newlength{\tileYoffset}
\newlength{\tilewidth}
\newlength{\tileheight}
\newlength{\tileX}
\newlength{\tileY}

\newcommand{\CenterWallPaper}[2]{%
\AddToShipoutPicture{\put(\LenToUnit{\wpXoffset},\LenToUnit{\wpYoffset}){%
     \parbox[b][\paperheight]{\paperwidth}{%       
       \vfill
       \centering
       \includegraphics[width=#1\paperwidth,height=#1\paperheight,%
                        keepaspectratio]{#2}%
       \vfill
     }}}
}  

\newcommand{\ThisCenterWallPaper}[2]{%
\AddToShipoutPicture*{\put(\LenToUnit{\wpXoffset},\LenToUnit{\wpYoffset}){%
     \parbox[b][\paperheight]{\paperwidth}{%       
       \vfill
       \centering
       \includegraphics[width=#1\paperwidth,height=#1\paperheight,%
                        keepaspectratio]{#2}%
       \vfill
     }}}
}  



\newcommand{\TileSquareWallPaper}[2]{%
\AddToShipoutPicture{%
  \begingroup
    \setlength{\tileYoffset}{\wpYoffset}
    \setlength{\tilewidth}{\paperwidth/#1}%
    \setlength{\tileheight}{\tilewidth}%
    \setlength{\tileY}{0pt}%
    \whiledo{\lengthtest{\tileY < \paperheight}}{% 
      \setlength{\tileX}{0pt}%
      \setlength{\tileXoffset}{\wpXoffset}%
      \whiledo{\lengthtest{\tileX < \paperwidth}}{% 
        \put(\LenToUnit{\tileXoffset},\LenToUnit{\tileYoffset}){%
          \includegraphics[height=\tileheight,width=\tilewidth]{#2}}%
        \addtolength{\tileX}{\tilewidth}
        \addtolength{\tileXoffset}{\tilewidth}
      }%
      \addtolength{\tileY}{\tileheight}
      \addtolength{\tileYoffset}{\tileheight}
    }%
  \endgroup  
}%
}

\newcommand{\ThisTileSquareWallPaper}[2]{%
\AddToShipoutPicture*{%
  \begingroup
    \setlength{\tileYoffset}{\wpYoffset}
    \setlength{\tilewidth}{\paperwidth/#1}%
    \setlength{\tileheight}{\tilewidth}%
    \setlength{\tileY}{0pt}%
    \whiledo{\lengthtest{\tileY < \paperheight}}{% 
      \setlength{\tileX}{0pt}%
      \setlength{\tileXoffset}{\wpXoffset}%
      \whiledo{\lengthtest{\tileX < \paperwidth}}{% 
        \put(\LenToUnit{\tileXoffset},\LenToUnit{\tileYoffset}){%
          \includegraphics[height=\tileheight,width=\tilewidth]{#2}}%
        \addtolength{\tileX}{\tilewidth}
        \addtolength{\tileXoffset}{\tilewidth}
      }%
      \addtolength{\tileY}{\tileheight}
      \addtolength{\tileYoffset}{\tileheight}
    }%
  \endgroup  
}%
}


\newcommand{\TileWallPaper}[3]{%
\AddToShipoutPicture{%
  \begingroup
    \setlength{\tileYoffset}{\wpYoffset}
    \setlength{\tilewidth}{#1}%
    \setlength{\tileheight}{#2}%
    \setlength{\tileY}{0pt}%
    \whiledo{\lengthtest{\tileY < \paperheight}}{% 
      \setlength{\tileX}{0pt}%
      \setlength{\tileXoffset}{\wpXoffset}%
      \whiledo{\lengthtest{\tileX < \paperwidth}}{% 
        \put(\LenToUnit{\tileXoffset},\LenToUnit{\tileYoffset}){%
          \includegraphics[height=\tileheight,width=\tilewidth]{#3}}%
        \addtolength{\tileX}{\tilewidth}
        \addtolength{\tileXoffset}{\tilewidth}
      }%
      \addtolength{\tileY}{\tileheight}
      \addtolength{\tileYoffset}{\tileheight}
    }%
  \endgroup  
}%
}

\newcommand{\ThisTileWallPaper}[3]{%
\AddToShipoutPicture*{%
  \begingroup
    \setlength{\tileYoffset}{\wpYoffset}
    \setlength{\tilewidth}{#1}%
    \setlength{\tileheight}{#2}%
    \setlength{\tileY}{0pt}%
    \whiledo{\lengthtest{\tileY < \paperheight}}{% 
      \setlength{\tileX}{0pt}%
      \setlength{\tileXoffset}{\wpXoffset}%
      \whiledo{\lengthtest{\tileX < \paperwidth}}{% 
        \put(\LenToUnit{\tileXoffset},\LenToUnit{\tileYoffset}){%
          \includegraphics[height=\tileheight,width=\tilewidth]{#3}}%
        \addtolength{\tileX}{\tilewidth}
        \addtolength{\tileXoffset}{\tilewidth}
      }%
      \addtolength{\tileY}{\tileheight}
      \addtolength{\tileYoffset}{\tileheight}
    }%
  \endgroup  
}%
}

\newcommand{\ClearWallPaper}{\ClearShipoutPicture}