summaryrefslogtreecommitdiff
path: root/macros/generic/poster/poster.tex
blob: 0265818b9c03b59416bffbbf14411bf0ccd886bb (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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
%% BEGIN poster.tex/poster.sty
%%
%%
%% COPYRIGHT 1993, by Timothy Van Zandt, tvz@Princeton.EDU
%%
%% DESCRIPTION:
%%   poster.tex/poster.sty contains a macro for making posters and banners
%%   with TeX. It is compatible with most TeX macro packages, including Plain
%%   TeX, LaTeX, AmSTeX, and Ams-LaTeX. The only special requirement is that
%%   your printer not be bothered by text that lies off the page. This is
%%   true of most printers, including laser printers and PostScript printers.
%%
%% COPYING:
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% CODE:
% These macros use TeX primitives, plus the Plain TeX commands:
%   \dimen@, \dimen@i, \count@, \newcount, \newtoks,
%
% Check if file is loaded, announce file on terminal, and take care of @:
%
\def\fileversion{1.1}
\def\filedate{10/05/15}
\csname PosterLoaded\endcsname
\let\PosterLoaded\endinput

\message{\space\space v\fileversion\space\space\filedate\space\space <tvz>}

\edef\TheAtCode{\the\catcode`\@}
\catcode`\@=11

\newbox\@posterbox
\newbox\poster@savedbox
\newbox\poster@cropbox

\def\POSTERpaperheight{11in}
\def\POSTERpaperwidth{8.5in}
\def\POSTERimageheight{10in}
\def\POSTERimagewidth{7.5in}
\def\POSTERlandscape{false}
\def\POSTERclip{none}
\def\POSTERcrop{corners}
\def\POSTERvcenter{false}
\def\POSTERhcenter{false}

\def\poster@set#1[#2]{%
  \poster@@set#2,=\@nil,%
  #1}
\def\poster@@set#1=#2,{%
  \ifx\@nil#2\else
    \expandafter\ifx\csname POSTER#1\endcsname\relax
      \errmessage{Poster parameter `#1' not defined}%
    \else
      \expandafter\edef\csname POSTER#1\endcsname{#2}%
    \fi
    \expandafter\poster@@set
  \fi}

\def\poster@true{true}

\def\poster{%
  \begingroup
    \futurelet\next\poster@i}
\def\poster@i{%
  \ifx\next[%
    \expandafter\poster@set
  \fi
  \poster@ii}
\def\poster@ii{%
  \afterassignment\poster@iii
  \setbox\@posterbox=\hbox}
\def\poster@iii{\aftergroup\poster@iv}
\def\poster@iv{%
    \setbox\@posterbox=\hbox{\raise\dp\@posterbox\box\@posterbox}%
    \poster@savepage
    \poster@magtonum
    \ifx\POSTERlandscape\poster@true \poster@landscape \fi
    \poster@hoffsets
    \poster@voffsets
    \ifx\POSTERvcenter\poster@true \poster@vcenter \fi
    \ifx\POSTERhcenter\poster@true \poster@hcenter \fi
    \poster@makecropbox
    \count\z@=\z@
    \poster@vloop
  \endgroup}

\def\Poster{%
  \begingroup
    \futurelet\next\Poster@i}
\def\Poster@i{%
  \ifx\next[%
    \expandafter\poster@set
  \fi
  \Poster@ii}
\def\Poster@ii{%
  \setbox\@posterbox=\hbox\bgroup\ignorespaces}
\def\endPoster{\egroup\poster@iv}

\def\PosterPage{\futurelet\next\PosterPage@i}
\def\PosterPage@i{%
  \ifx\next[%
    \expandafter\poster@set
  \fi
  \PosterPage@ii}
\def\PosterPage@ii{%
  \count2=\z@
  \let\poster@trueshipout\shipout
  \let\shipout\poster@pageshipout}
\def\poster@pageshipout{%
  \begingroup
    \global\advance\count2\@ne
    \def\poster@swapcounters{%
      \count@=\count2
      \count2=\count1
      \count1=\count\z@
      \count\z@=\count@}%
    \let\poster@savepage\relax
    \let\shipout\poster@trueshipout
    \setbox\@posterbox\box\voidb@x
    \afterassignment\poster@@pageshipout
    \setbox\@posterbox}
\def\poster@@pageshipout{%
  \ifvoid\@posterbox\aftergroup\poster@iv\else\poster@iv\fi}
\let\poster@swapcounters\relax

% Save current contents of page in case it contains \special's:
\def\poster@savepage{%
    \begingroup
      \global\setbox\poster@savedbox\box\voidb@x
      \output{\global\setbox\poster@savedbox\box\@cclv}%
      \par\hbox{}\penalty-10000
    \endgroup
    \ifvoid\poster@savedbox\else
      \dp\poster@savedbox\z@
      \ht\poster@savedbox\z@
      \wd\poster@savedbox\z@
    \fi}

% \poster@mag set to decimal value of \mag.
\def\poster@magtonum{%
  \ifnum\mag=1000
    \def\poster@mag{}%
  \else
    \count@=10000000
    \divide\count@\mag
    \advance\count@ by 200000000
    \expandafter\poster@@magtonum\the\count@
  \fi
  \dimen@=2000pt
  \divide\dimen@\mag
  \edef\poster@cropwidth{\number\dimen@ sp }}

\def\poster@@magtonum#1#2#3#4#5#6#7#8#9{%
  \count@ #2#3#4#5\relax
  \edef\poster@mag{\the\count@.#6#7#8#9}}

\def\poster@landscape{%
  \let\next\POSTERpaperheight
  \let\POSTERpaperheight\POSTERpaperwidth
  \let\POSTERpaperwidth\next
  \let\next\POSTERimageheight
  \let\POSTERimageheight\POSTERimagewidth
  \let\POSTERimagewidth\next}

% \dimen@ii set to imageheight
\def\poster@voffsets{%
  \dimen@\POSTERimageheight\relax
  \dimen@ii=\poster@mag\dimen@
  \voffset=\POSTERpaperheight\relax
  \advance\voffset-\dimen@
  \divide\voffset 2
  \ifdim\voffset<\z@
    \voffset\z@
  \fi
  \dimen@=\poster@mag\voffset
  \edef\poster@vmargin{\number\dimen@ sp }%
  \advance\voffset-1in
  \voffset=\poster@mag\voffset}

% \dimen@i set to imagewidth
\def\poster@hoffsets{%
  \dimen@\POSTERimagewidth\relax
  \dimen@i=\poster@mag\dimen@
  \hoffset=\POSTERpaperwidth\relax
  \advance\hoffset-\dimen@
  \divide\hoffset 2
  \ifdim\hoffset<\z@
    \hoffset=\z@
  \fi
  \dimen@=\poster@mag\hoffset
  \edef\poster@hmargin{\number\dimen@ sp }%
  \advance\hoffset-1in
  \hoffset=\poster@mag\hoffset}

% Center vertically
\def\poster@vcenter{%
  \count@=\ht\@posterbox
  \divide\count@\dimen@ii
  \dimen@=\the\count@\dimen@ii
  \advance\dimen@-\ht\@posterbox
  \ifdim\dimen@<-.1pt
    \advance\count@ 1
  \fi
  \setbox\@posterbox=\hbox{\vbox to \the\count@\dimen@ii{%
    \vss\box\@posterbox\vss}}}

% Center horizontally
\def\poster@hcenter{%
  \count@=\wd\@posterbox
  \divide\count@\dimen@i
  \dimen@=\the\count@\dimen@i
  \advance\dimen@-\wd\@posterbox
  \ifdim\dimen@<-.1pt
    \advance\count@ 1
  \fi
  \setbox\@posterbox=\hbox to \the\count@\dimen@i{%
    \hss\box\@posterbox\hss}}

% Print rows:
\def\poster@vloop{%
  \ifdim\ht\@posterbox>.1pt
    \ifdim\ht\@posterbox<\dimen@ii
      \dimen@ii=\ht\@posterbox
      \poster@makecropbox
    \fi
    \advance\count\z@ 1
    \count1=\z@
    \dimen@=\wd\@posterbox
    \poster@hloop
    \dimen@=\ht\@posterbox
    \advance\dimen@-\dimen@ii
    \ht\@posterbox\dimen@
    \expandafter\poster@vloop
  \fi}

% Print columns.
% \dimen@ is used as scratch to keep track of remaining width.
\def\poster@hloop{%
  \ifdim\dimen@>.1pt
    \advance\count1 by 1
    \begingroup
      \ifdim\dimen@<\dimen@i
        \dimen@i=\dimen@
        \poster@makecropbox
      \fi
      \poster@swapcounters
      \poster@shipout
    \endgroup
    \advance\dimen@-\dimen@i
    \expandafter\poster@hloop
  \fi}

% Shipout, aligning everything at the top-left corner:
\def\poster@shipout{%
  \shipout\hbox{%
    \ifvoid\poster@savedbox\else\box\poster@savedbox\fi
    \csname beginposterclip@\POSTERclip\endcsname
    \lower\ht\@posterbox\hbox to\z@{%
      \advance\dimen@-\wd\@posterbox
      \kern\dimen@
      \copy\@posterbox
      \hss}%
    \csname endposterclip@\POSTERclip\endcsname
    \copy\poster@cropbox}}%

% clip=pstricks
\def\beginposterclip@pstricks{%
  \expandafter\ifx\csname @pstrickserr\endcsname\relax
    \errmessage{%
      You must load PSTricks to use poster.tex's clip=pstricks option!}%
      \global\let\beginposterclip@pstricks\relax
  \else
    \gdef\beginposterclip@pstricks{\beginposterclip@@pstricks}%
    \gdef\endposterclip@pstricks{\pstVerb{currentpoint initclip moveto}}%
    \beginposterclip@@pstricks
  \fi}

\let\endposterclip@pstricks\relax

\def\beginposterclip@@pstricks{%
  \pst@Verb{%
    /mtrxc CM def
    \tx@STV
    CP translate
    newpath
    0 0 moveto
    \pst@number\dimen@i 0 rlineto
    0 \pst@number\dimen@ii neg rlineto
    \pst@number\dimen@i neg 0 rlineto
    closepath
    clip
    newpath
    0 0 moveto
    mtrxc setmatrix}}

\def\poster@makecropbox{%
  \setbox\poster@cropbox=\hbox{\csname postercrop@\POSTERcrop\endcsname}%
  \ht\poster@cropbox=\z@
  \dp\poster@cropbox=\z@
  \wd\poster@cropbox=\z@}

\def\postercrop@corners{%
  \vtop{%
    \hbox{%
      \kern -\poster@hmargin
      \vrule height \poster@cropwidth width \poster@hmargin
      \kern -\poster@cropwidth
      \vrule height \poster@vmargin width \poster@cropwidth
      \kern \dimen@i
      \vrule height \poster@vmargin width \poster@cropwidth
      \kern -\poster@cropwidth
      \vrule height \poster@cropwidth width \poster@hmargin}%
    \nointerlineskip
    \vskip\dimen@ii
    \hbox{%
      \kern -\poster@hmargin
      \vrule height \z@ depth \poster@cropwidth width \poster@hmargin
      \kern -\poster@cropwidth
      \vrule height \z@ depth \poster@vmargin width \poster@cropwidth
      \kern \dimen@i
      \vrule height \z@ depth \poster@vmargin width \poster@cropwidth
      \kern -\poster@cropwidth
      \vrule height \z@ depth \poster@cropwidth width \poster@hmargin}}}%

\def\postercrop@full{%
  \begingroup
    \hbox to\z@{%
      \advance\dimen@ii\poster@vmargin
      \kern -\poster@cropwidth
      \vrule height \poster@vmargin depth \dimen@ii width \poster@cropwidth
      \kern \dimen@i
      \vrule height \poster@vmargin depth \dimen@ii width \poster@cropwidth
      \hss}%
    \kern -\poster@hmargin
    \vtop{%
      \advance\dimen@i \poster@hmargin
      \advance\dimen@i \poster@hmargin
      \kern-\poster@cropwidth
      \hrule height \poster@cropwidth width \dimen@i
      \kern\dimen@ii
      \hrule height \z@ depth \poster@cropwidth width \dimen@i}%
  \endgroup}

\catcode`\@=\TheAtCode\relax
\endinput
%%
%% END poster.tex