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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
% \iffalse meta-comment
%
% Copyright (C) 2007, 2018-
% Rolf Niepraschk, Rolf.Niepraschk@gmx.de
%
% 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 "author-maintained".
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{blowup.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{blowup}[2018/01/02 1.0 Document Scaling (RN)]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{array,longtable}
\IfFileExists{ragged2e.sty}{%
\usepackage{ragged2e}}{\let\RaggedRight=\raggedright}
\newcommand{\m}[1]{\mbox{$\langle$\it #1\/$\rangle$}}
\renewcommand{\arg}[1]{{\ttfamily\string{}\m{#1}{\ttfamily\string}}}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{blowup.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{504}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
%
% \changes{v0.1a}{2007/08/14}{Initial version. (RN)}
%
% \GetFileInfo{blowup.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
% \newcommand\afterheading{\par\nobreak\@afterheading}
% \newcolumntype{P}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}
%
%
% \title{The \textsf{blowup} package\thanks{This document
% corresponds to \textsf{blowup}~\fileversion, dated \filedate.}}
% \author{Rolf Niepraschk \\ \texttt{Rolf.Niepraschk@gmx.de}}
%
% \maketitle
%
% \begin{abstract}
% \noindent
% This package only defines the user-level macro \cmd{\blowUp},
% which can be used to upscale or downscale all pages
% of a document. It is
% similar to the \TeX\ primitive \cmd{\magnification} but more
% accurate and in a user-friendly manner. \cmd{\blowUp}
% may be useful for the creation of posters from a normal-sized
% document and for many kinds of fine adjustments of a ready
% typesetted document (e.\,g., minor changes of scaling and
% position of the pages).
% \end{abstract}
%
% \tableofcontents
%
% \section{Usage}
% Load the package after other packages that affect the paper size
% (e.\,g., \textsf{geometry} and \textsf{hyperref}).
% Then call the macro \cmd{\blowUp} before |\begin{document}| to scale
% the document. \par \medskip \noindent
% |\usepackage{blowup}| \par \noindent
% \cmd{\blowUp}\arg{key=value} \par \noindent
% \vspace{-\baselineskip}
% \setlength\extrarowheight{.2ex}
% \begin{longtable}{@{}lP{.75\linewidth}@{}}
% \multicolumn{1}{@{}l}{\textbf{key}} &
% \multicolumn{1}{l@{}}{\textbf{value}} \tabularnewline \hline
% target & The final paper size: \tabularnewline
% & |letter|, |legal|, |executive| or a paper size from the
% ISO/DIN paper series A, B, C, D
% (e.\,g., |a8|, |c7|,..., |b1|, |a0|) or a pair of dimensions
% in curly brackets (e.\,g., |paper={925mm,1225mm}|) or the
% letter `x' followed by a scaling factor
% (e.\,g., |paper=x1.414213|). \tabularnewline[.4\baselineskip]
% origin & The paper size of the source document; no scaling to the target
% size. \tabularnewline
% & |letter|, |legal|, |executive| or a paper size from the
% ISO/DIN paper series A, B, C, D
% (e.\,g., |a8|, |c7|,..., |b1|, |a0|) or a pair of dimensions
% in curly brackets (e.\,g., |paper={925mm,1225mm}|) or the
% letter `x' followed by a scaling factor
% (e.\,g., |paper=x1.414213|). \tabularnewline[.4\baselineskip]
% landscape & Exchanges paperwidth and paperheight: \tabularnewline
% & |true| (the same as no value) or |false|. \tabularnewline[.4\baselineskip]
% noscale & No scaling of the original paper size: \tabularnewline
% & |true| (the same as no value) or |false|. \tabularnewline[.4\baselineskip]
% pos & Position of the page on the paper: \tabularnewline
% & |left| or |right|, |inside| or |outside|, |top| or |bottom|
% (only the first letter is significant; default is
% centering), or
% a pair of dimensions in curly brackets which means the offset
% from the lower left or lower outside corner of the final paper.
% Only meaningful for |noscale=true| and up-scaled paper
% size. \tabularnewline[.4\baselineskip]
% onepage & Suppresses the second page and all following pages: \tabularnewline
% & |true| (the same as no value) or |false|. \tabularnewline
% & Useful for creating a one-side paper like a poster.
% \end{longtable}
% \vspace{0\baselineskip}
% See also the example documents |blowup-ex?.tex|.
%
% \section{Required Packages}
%
% The \textsf{blowup} package requires the following packages:
% \textsf{atbegshi}, \textsf{graphics}, \textsf{keyval}, and
% \textsf{typearea}.
%
% \StopEventually{\PrintChanges\PrintIndex}
%
% \section{Implementation}
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
% Load some packages for utility macros.
% \begin{macrocode}
\RequirePackage{atbegshi,keyval,graphics}
\@ifpackageloaded{typearea}{}{%
\newcommand*\BL@save@dimen[1]{%
\@ifundefined{BL@#1}{%
\expandafter\newlength\csname BL@#1\endcsname}{}%
\csname BL@#1\endcsname\csname #1\endcsname
\g@addto@macro\BL@restore@dimens{%
\csname #1\endcsname\csname BL@#1\endcsname}%
}%
\newcommand*\BL@restore@dimens{}%
% \end{macrocode}
% Some dimensions changed by \textsf{typearea} must be saved and restored.
% \begin{macrocode}
\BL@save@dimen{textwidth}%
\BL@save@dimen{textheight}%
\BL@save@dimen{evensidemargin}%
\BL@save@dimen{oddsidemargin}%
\BL@save@dimen{topmargin}%
\BL@save@dimen{headheight}%
\BL@save@dimen{headsep}%
\BL@save@dimen{topskip}%
\BL@save@dimen{footskip}%
\BL@save@dimen{baselineskip}%
% \end{macrocode}
% \changes{v0.1j}{2008/11/14}{Undefine \cmd{\l@addto@macro}. (RN)}
% Prevent an error if \cmd{\l@addto@macro} is already defined.
% \begin{macrocode}
\let\l@addto@macro=\relax
\RequirePackage{typearea}%
\BL@restore@dimens
\let\BL@save@dimen=\relax
\let\BL@restore@dimens=\relax
}
\providecommand*\vb@xt@{\vbox to}
% \end{macrocode}
% \begin{macro}{\tPaperWidth}
% \begin{macro}{\tPaperHeight}
% The size of the scaled pages.
% \begin{macrocode}
\newlength\tPaperWidth \tPaperWidth=\paperwidth
\newlength\tPaperHeight \tPaperHeight=\paperheight
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\oPaperWidth}
% \begin{macro}{\oPaperHeight}
% The size of the original pages.
% \begin{macrocode}
\newlength\oPaperWidth \oPaperWidth=\z@
\newlength\oPaperHeight \oPaperHeight=\z@
% \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macrocode}
\newcommand*\BL@resize[1]{#1}
% \end{macrocode}
% \begin{macro}{\BL@scalePage}
% Scales the output box to the dimension of the new paper size.
% \begin{macrocode}
\newcommand*\BL@scalePage{%
\setbox\AtBeginShipoutBox=\vbox{%
\vskip1in\moveright1in\box\AtBeginShipoutBox}%
\setbox\AtBeginShipoutBox=\hb@xt@\paperwidth{%
\box\AtBeginShipoutBox\hss}%
\setbox\AtBeginShipoutBox=\vb@xt@\paperheight{%
\box\AtBeginShipoutBox\vss}%
\ifBL@noscale\else
\ifdim\oPaperWidth>\z@
\setbox\AtBeginShipoutBox=\hbox{\resizebox{\oPaperWidth}{\oPaperHeight}%
{\box\AtBeginShipoutBox}}%
\else
\def\BL@resize##1{\resizebox{\tPaperWidth}{!}{##1}}%
\setbox\@tempboxa=\hbox{\BL@resize{\copy\AtBeginShipoutBox}}%
\ifdim\ht\@tempboxa>\tPaperHeight
\def\BL@resize##1{\resizebox{!}{\tPaperHeight}{##1}}%
\fi
\fi
\fi
\setbox\@tempboxa=\vb@xt@\tPaperHeight{%
\kern\z@\BL@t
\hb@xt@\tPaperWidth{\BL@l\BL@resize{\box\AtBeginShipoutBox}\BL@r}%
\BL@b\kern\z@
}%
\setbox\AtBeginShipoutBox=\vbox{%
\vskip-1in\moveright-1in\box\@tempboxa}%
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\newcommand\BL@tempa{}
\newcommand\BL@tempb{}
\newcommand*\BL@strip@comma{}
\def\BL@strip@comma#1,{#1}
% \end{macrocode}
% \begin{macro}{\BL@is@dimen@pair}
% The parameter two will be executed if the first parameter is
% a comma-separated pair of two dimensions. If not the parameter three
% will be executed.
% \begin{macrocode}
\newcommand*\BL@is@dimen@pair[1]{%
\expandafter\BL@@is@dimen@pair#1,\@nil
}
\newcommand*\BL@@is@dimen@pair{}
\def\BL@@is@dimen@pair#1,#2\@nil{%
\edef\BL@tempa{#1}\edef\BL@tempb{#2}%
\@tempswafalse
\ifx\BL@tempb\@empty\else
\edef\BL@tempb{\expandafter\BL@strip@comma\BL@tempb}%
\ifdimen{\BL@tempa}{%
\ifdimen{\BL@tempb}{\@tempswatrue}{}%
}{}%
\fi
\if@tempswa
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\newcommand*\BL@strip@x{}
\def\BL@strip@x#1x{#1}
% \end{macrocode}
% \begin{macro}{\BL@is@factor}
% The parameter two will be executed if the first parameter is the
% small letter x (`times') immediately followed by a number. If not
% the parameter three will be executed.
% \begin{macrocode}
\newcommand*\BL@is@factor[1]{%
\expandafter\BL@@is@factor#1x\@nil
}
\newcommand*\BL@@is@factor{}
\def\BL@@is@factor#1x#2\@nil{%
\edef\BL@tempa{#2}%
\@tempswafalse
\ifx\BL@tempa\@empty\else
\edef\BL@tempa{\expandafter\BL@strip@x\BL@tempa}%
\ifdimen{\BL@tempa pt}{\@tempswatrue}{}%
\fi
\if@tempswa
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\BL@getDimens}
% Sets the two dimen registers (|#2| and |#3|) according to parameter |#1|.
% \begin{macrocode}
\newcommand*\BL@getDimens[3]{%
\BL@is@dimen@pair{#1}{%
\global#2=\BL@tempa\relax
\global#3=\BL@tempb\relax
}{%
\BL@is@factor{#1}{%
\global#2=\BL@tempa\paperwidth
\global#3=\BL@tempa\paperheight
}{%
\begingroup
\KOMAoptions{paper=portrait,paper=#1}%
\global#2=\paperwidth
\global#3=\paperheight
\endgroup
}%
}%
}
% \end{macrocode}
% \end{macro}
% The key-value definitions for \cmd{\blowUp}.
% \begin{macrocode}
\define@key{BL@}{origin}{%
\BL@getDimens{#1}{\oPaperWidth}{\oPaperHeight}%
}
\define@key{BL@}{target}{%
\BL@getDimens{#1}{\tPaperWidth}{\tPaperHeight}%
}
\newif\ifBL@noscale \BL@noscalefalse
\define@key{BL@}{noscale}[true]{%
\csname BL@noscale#1\endcsname
}
\newcommand*\BL@l{}
\newcommand*\BL@r{}
\newcommand*\BL@i{}
\newcommand*\BL@o{}
\newcommand*\BL@t{}
\newcommand*\BL@b{}
% \end{macrocode}
% \begin{macro}{\BL@setPos}
% Modify the macros \cmd{\BL@l}, \cmd{\BL@r} (\cmd{\BL@i}, \cmd{\BL@o}),
% \cmd{\BL@t}, and \cmd{\BL@b} for positioning the page on the paper.
% \begin{macrocode}
\newcommand\BL@setPos[1]{%
\def\BL@l{\hss}\def\BL@r{\hss}%
\def\BL@o{\hss}\def\BL@i{\hss}%
\def\BL@t{\vss}\def\BL@b{\vss}%
\BL@is@dimen@pair{#1}{%
\edef\BL@b{\vskip\BL@tempb}%
\if@twoside
\edef\BL@l{\noexpand\ifodd\value{page}%
\hskip\BL@tempa\noexpand\else\hss\noexpand\fi}%
\edef\BL@r{\noexpand\ifodd\value{page}%
\hss\noexpand\else\hskip\BL@tempa\noexpand\fi}%
\else
\edef\BL@l{\hskip\BL@tempa}%
\if
}{%
\@for\BL@tempa:=#1\do{%
% \end{macrocode}
% Extract the first letter.
% \begin{macrocode}
\edef\BL@tempb{\expandafter\@car\BL@tempa\@nil}%
\expandafter\let\csname BL@\BL@tempb \endcsname\relax
}%
\if@twoside
\ifx\BL@i\relax
\def\BL@r{\ifodd\value{page}\hss\else\relax\fi}%
\def\BL@l{\ifodd\value{page}\relax\else\hss\fi}%
\fi
\ifx\BL@o\relax
\def\BL@l{\ifodd\value{page}\hss\else\relax\fi}%
\def\BL@r{\ifodd\value{page}\relax\else\hss\fi}%
\fi
\else
\let\BL@l=\BL@o
\let\BL@r=\BL@i
\fi
}%
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\define@key{BL@}{pos}{%
\BL@setPos{#1}%
}
\newif\ifBL@landscape \BL@landscapefalse
\define@key{BL@}{landscape}[true]{%
\csname BL@landscape#1\endcsname
}
\newcommand*\BL@pageInit{}
\define@key{BL@}{onepage}[true]{%
\csname if#1\endcsname
\def\BL@pageInit{\gdef\shipout{\setbox\@tempboxa=}}%
\fi
}
% \end{macrocode}
% \begin{macro}{\blowUp}
% The only user-level macro.
% \begin{macrocode}
\newcommand*\blowUp[1]{%
\setkeys{BL@}{#1}%
\ifBL@landscape
\@tempdima=\tPaperWidth
\global\tPaperWidth=\tPaperHeight
\global\tPaperHeight=\@tempdima
\fi
\AtBeginShipout{\BL@scalePage}%
\gdef\blowUp##1{%
\PackageWarning{blowup}{Only the first call of `\string\blowUp'
\MessageBreak is effective}}%
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\AtBeginShipout{\BL@pageInit}
\@onlypreamble\blowUp
\AtBeginDocument{%
\BL@pagesize@specials{\tPaperWidth}{\tPaperHeight}%
}
% \end{macrocode}
% \begin{macro}{\BL@pagesize@specials}
% Write pagesize informations to the output file. Depends on \TeX\
% compiler or driver.
% \begin{macrocode}
\RequirePackage{ifxetex,ifluatex,ifpdf,ifvtex}
\newcommand*\BL@pagesize@specials[2]{}
\ifluatex
\PackageInfo{blowup}{Generating code for LuaTeX}%
\@ifundefined{pagewidth}{%
\def\BL@pagesize@specials#1#2{\pdfpagewidth=#1 \pdfpageheight=#2}%
}{%
\def\BL@pagesize@specials#1#2{\pagewidth=#1 \pageheight=#2}%
}
\else
\ifxetex
\PackageInfo{blowup}{Generating code for XeTeX}%
\def\BL@pagesize@specials#1#2{\@tempdima=#1 \@tempdimb=#2 %
\AtBeginDvi{\special{papersize=\the\@tempdima,\the\@tempdimb}}%
\pdfpagewidth=#1 \pdfpageheight=#2}%
\else
\ifvtex
\PackageInfo{blowup}{Generating code for VTeX}%
\def\BL@pagesize@specials#1#2{\mediawidth=#1 \mediaheight=#2}%
\else
\ifpdf
\PackageInfo{blowup}{Generating code for pdfTeX}%
\def\BL@pagesize@specials#1#2{\pdfpagewidth=#1 \pdfpageheight=#2}%
\else
\PackageInfo{blowup}{Generating code for dvips}%
\def\BL@pagesize@specials#1#2{\@tempdima=#1 \@tempdimb=#2 %
\AtBeginDvi{\special{papersize=\the\@tempdima,\the\@tempdimb}}}%
\fi
\fi
\fi
\fi
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \Finale
%\endinput
|