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
|
% \iffalse meta-comment
%
% Copyright (C) 2005 by Régis Lachaume.
%
% Released in the public domain.
%
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{zigarettenschachtelhuellenzeichnung}
%<package> [2005/04/29 Zigarettenschachtelhuellenzeichnung mit LaTeX - Drawing of cigarette pack covers with LaTeX]
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{zigarettenschachtelhuellenzeichnung.dtx}
\end{document}
%</driver>
% \fi
%
%
%
% \GetFileInfo{zigarettenschachtelhuellenzeichnung.dtx}
% \CheckSum{0}
% \OnlyDescription
%
% \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 \~}
%
%
%
% \title{Zigarettenschachtelhuellenzeichnung\\Drawing of cigarette pack covers.}
%
% \author{R\'egis Lachaume\\
% Max-Planck-Institut f\"ur Radioastronomie\\
% Auf dem H\"ugel 69\\
% D-53121 Bonn\\
% \texttt{lachaume@mpifr-bonn.mpg.de}}
%
%
% \date{Printed \today}
%
% \maketitle
%
% \section{To start with}
%
% This package is meant to design cigarette pack covers that hide the
% death warnings and the advertising present on most packs. It imitates
% the original look of packs in the European Union by allowing the
% placement of fancy warnings (e.g. Caution: inflammable device).
%
% An example file example.tex is included in the distribution.
%
% The package is loaded with |\usepackage{zigarettenschachtelhuellenzeichnung}|
% between the |\documentclass{...}| and the |\begin{document}|.
%
% A cigarette pack is then obtained with
% \begin{verbatim}
% \begin{zigarettenschachtelhuelle}[<pack>]
% \frontwarning{Text of the warning on the front side}
% \fronttext{Text on the front side, above the warning frame}
% \ingredients{Text in the left side frame}
% \background{<pgfcolor>}
% \backwarning{Text of the warning on the back side}
% \backtext{Text on the back side, above the warning frame}
% \end{zigarettenschachtelhuelle}
% \end{verbatim}
%
% The default pack is |<pack>=normalpack|. It corresponds to a standard
% hard pack. It is possible to define new pack styles by specifying all
% dimensions:
%
% \begin{verbatim}
% \definepack{<packname>}{
% \width=<pack width>
% \depth=<pack depth>
% \frontheight=<cover height on the front side>
% \backheight=<cover height on the back side>
% \frontwarningheight=<height of the warning framebox on the front side>
% \backwarningheight=<height of the warning framebox on the back side>
% \ingrendientsheight=<height of the ingredients framebox>
% \framewidth=<thickness of the frame in warning boxes>
% \framesep=<distance between warning text and frame>
% \flapsize=<width of the flaps used to glue the pattern>
% \frontwarningbottommargin=
% \backwarningsidemargin=
% \ingrendientsbottommargin=
% \ingrendientssidemargin=
% \frontwarningsidemargin=
% \backwarningbottommargin=
% \sidemargin=<margin for normal text written on the pack cover>
% \verticalmargin=<top margin for normal text on the pack cover>
% }
% \end{verbatim}
%
% \section{Description of commands}
%
% TBW.
%
% \section{\LaTeX source}
%
% \begin{macrocode}
% Needed packages: calc for dimension calculus, pgf for portable graphics
% and ifthen to use latex-style booleans.
\RequirePackage{calc}
\RequirePackage{pgf}
\RequirePackage{ifthen}
% width of the pack
\newlength\width
% depth of the pack
\newlength\depth
% height of the cover on the front side of the pack
\newlength\frontheight
% height of the cover on the back side of the pack
\newlength\backheight
% flap width
\newlength\flapsize
% width of the black frame of warnings
\newlength\framewidth
% separation between warning text and the black frame
\newlength\framesep
% height, side-margin and bottom margin of the front warning frame
\newlength\frontwarningheight
\newlength\frontwarningsidemargin
\newlength\frontwarningbottommargin
% idem for the back warning frame
\newlength\backwarningheight
\newlength\backwarningsidemargin
\newlength\backwarningbottommargin
% idem for the side frame used as a ingredients listing
\newlength\ingrendientsheight
\newlength\ingrendientssidemargin
\newlength\ingrendientsbottommargin
% side-margin and top margin for displaying text or images on the cover
\newlength\sidemargin
\newlength\verticalmargin
% define a packstyle \definepack{packname}{\width=... \depth=...}
% can be used later with \begin{zigarettenschachtelhuelle}[packname]
\def\@listofpacks{}
\newcommand\definepack[2]{
\ifthenelse{\equal{\@listofpacks}{}}{\def\@comma{}}{\def{\@comma{,}}}
\edef\@listofpacks{\@listofpacks\@comma#1}%
\expandafter\def\csname #1\endcsname{#2}%
}
% the default pack style is normalpack (20 hard pack)
\definepack{normalpack}{
\newcommand\warningfont{\sffamily\bfseries}
\renewcommand\textfont{\sffamily}
\ingrendientssidemargin=2mm
\ingrendientsbottommargin=5mm
\ingrendientsheight=22mm
\frontwarningbottommargin=1mm
\frontwarningsidemargin=1mm
\backwarningheight=38mm
\backwarningsidemargin=1mm
\backwarningbottommargin=1mm
\depth=24mm
\width=56mm
\frontheight=62mm
\backheight=76mm
\flapsize=10mm
\framewidth=3mm
\framesep=2.5mm
\sidemargin=3mm
\frontwarningheight=28mm
\verticalmargin=3mm
}
% pack cover is created by an environment
% \begin{zigarettenschachtelhuelle}[packstyle]
% <some dimension and/or font settings>
% <setting of warning messages>
% \end{zigarettenschachtelhuelle}
\newenvironment{zigarettenschachtelhuelle}[1][normalpack]{%
% \frontwarning[fontsize]{text}: set the front warning (and its font size)
\newcommand\frontwarning[2][20pt]{%
\setlength\@frontwarningfs{##1}
\setlength\@frontwarningls{1.14\@frontwarningfs}
\def\@frontwarningtext{##2}%
}\frontwarning{}%
% \fronttext[fontsize]{text}: set the front text (and its font size)
\newcommand\fronttext[2][10pt]{%
\setlength\@fronttextfs{##1}
\setlength\@fronttextls{1.14\@fronttextfs}
\def\@fronttext{##2}%
}\fronttext{}%
% \backwarning[fontsize]{text}: set the back warning (and its font size)
\newcommand\backwarning[2][15pt]{%
\setlength{\@backwarningfs}{##1}
\setlength\@backwarningls{1.14\@backwarningfs}
\def\@backwarningtext{##2}%
}\backwarning{}%
% \backtext[fontsize]{text}: set the back text (and its font size)
\newcommand\backtext[2][10pt]{%
\setlength\@backtextfs{##1}
\setlength\@backtextls{1.14\@backtextfs}
\def\@backtext{##2}%
}\backtext{}%
% \ingredients[fontsize]{text}: set the ingredient list (and its font size)
\newcommand\ingredients[2][5pt]{%
\setlength{\@ingrendientsfs}{##1}
\setlength\@ingrendientsls{1.14\@ingrendientsfs}
\def\@ingredientstext{##2}%
}\ingredients{}%
% \background{pgfcolor}: set the background color
\newcommand\background[1]{\def\@background{##1}}\background{white}%
% look for the pack style in the list of defined ones and
% set the corresponding dimensions
\setboolean{@validpack}{false}
\@for\@packstyle:=\@listofpacks\do{%
\typeout{\@packstyle - #1}
\ifthenelse{\equal{#1}{\@packstyle}}{%
\typeout{ -> OK!}
\csname\@packstyle\endcsname
\setboolean{@validpack}{true}
}{}%
}
\ifthenelse{\boolean{@validpack}}{}{%
\@latexerr{Not a valid pack type: #1}%
}
}{%
% coordinates of template vertices. (see template below)
% N________N
% /| |\
% / | | \
% P________O/r | | \L__
% | | i | | l | f\K
% | back | g | front | e | l |
% | | h | | f | a |
% | | t | | t | p J
% A--------B---C--------H---I--/
% | bottom |
% D--------G
% | flap |
% \E------F/
\parindent=0pt
\setlength\@xA{0cm}\setlength\@yA{0cm}
\setlength\@xB{\width}\setlength\@yB{0cm}
\setlength\@xC{\width+\depth}\setlength\@yC{0cm}
\setlength\@xD{\width+\depth}\setlength\@yD{-\depth}
\setlength\@xE{\width+\depth+0.5\flapsize}\setlength\@yE{-\depth-\flapsize}
\setlength\@xF{2\width+\depth-0.5\flapsize}\setlength\@yF{-\depth-\flapsize}
\setlength\@xG{2\width+\depth}\setlength\@yG{-\depth}
\setlength\@xH{2\width+\depth}\setlength\@yH{0cm}
\setlength\@xI{2\width+2\depth}\setlength\@yI{0cm}
\setlength\@xJ{2\width+2\depth+\flapsize}\setlength\@yJ{0.5\flapsize}
\setlength\@xK{2\width+2\depth+\flapsize}\setlength\@yK{\backheight-0.5\flapsize}
\setlength\@xL{2\width+2\depth}\setlength\@yL{\backheight}
\setlength\@xM{2\width+\depth}\setlength\@yM{\frontheight}
\setlength\@xN{\width+\depth}\setlength\@yN{\frontheight}
\setlength\@xO{\width}\setlength\@yO{\backheight}
\setlength\@xP{0cm}\setlength\@yP{\backheight}
% drawing
\begin{pgfpicture}{0cm}{\@yE}{\@xK}{\@yO}
% draw template outline
\begin{pgfscope}
\color{\@background}
\pgfmoveto{\pgfpoint\@xA\@yA}\pgflineto{\pgfpoint\@xB\@yB}
\pgflineto{\pgfpoint\@xD\@yC}\pgflineto{\pgfpoint\@xD\@yD}
\pgflineto{\pgfpoint\@xE\@yE}\pgflineto{\pgfpoint\@xF\@yF}
\pgflineto{\pgfpoint\@xG\@yG}\pgflineto{\pgfpoint\@xH\@yH}
\pgflineto{\pgfpoint\@xI\@yI}\pgflineto{\pgfpoint\@xJ\@yJ}
\pgflineto{\pgfpoint\@xK\@yK}\pgflineto{\pgfpoint\@xL\@yL}
\pgflineto{\pgfpoint\@xM\@yM}\pgflineto{\pgfpoint\@xN\@yN}
\pgflineto{\pgfpoint\@xO\@yO}\pgflineto{\pgfpoint\@xP\@yP}
\pgffillstroke
\end{pgfscope}
% draw folding lines
\color{black}
\pgfline{\pgfpoint\@xB\@yB}{\pgfpoint\@xO\@yO}
\pgfline{\pgfpoint\@xC\@yC}{\pgfpoint\@xN\@yN}
\pgfline{\pgfpoint\@xH\@yH}{\pgfpoint\@xM\@yM}
\pgfline{\pgfpoint\@xI\@yI}{\pgfpoint\@xL\@yL}
\pgfline{\pgfpoint\@xC\@yC}{\pgfpoint\@xH\@yH}
\pgfline{\pgfpoint\@xD\@yD}{\pgfpoint\@xG\@yG}
% position warning frames
\begin{pgfscope}
\fontsize{\@frontwarningfs}{\@frontwarningls}
\@smashbox\@xC\@yC\frontwarningsidemargin\frontwarningbottommargin\width\frontwarningheight\@frontwarningtext
\fontsize{\@ingrendientsfs}{\@ingrendientsls}
\@smashbox\@xB\@yB\ingrendientssidemargin\ingrendientsbottommargin\depth\ingrendientsheight\@ingredientstext
\fontsize{\@backwarningfs}{\@backwarningls}
\@smashbox\@xA\@yA\backwarningsidemargin\backwarningbottommargin\width\backwarningheight\@backwarningtext
\end{pgfscope}
% position additional text
\fontsize{\@fronttextfs}{\@fronttextls}
\@smashtext\@xN\@yN\sidemargin\verticalmargin\width\@fronttext
\fontsize{\@backtextfs}{\@backtextls}
\@smashtext\@xP\@yP\sidemargin\verticalmargin\width\@backtext
\end{pgfpicture}
}
% internal use
\newlength\@tmplen
\newlength\@fronttextls
\newlength\@backtextls
\newlength\@fronttextfs
\newlength\@backtextfs
\newlength\@frontwarningfs
\newlength\@backwarningfs
\newlength\@ingrendientsfs
\newlength\@frontwarningls
\newlength\@backwarningls
\newlength\@ingrendientsls
\newlength\@xA\newlength\@yA
\newlength\@xB\newlength\@yB
\newlength\@xC\newlength\@yC
\newlength\@xD\newlength\@yD
\newlength\@xE\newlength\@yE
\newlength\@xF\newlength\@yF
\newlength\@xG\newlength\@yG
\newlength\@xH\newlength\@yH
\newlength\@xI\newlength\@yI
\newlength\@xJ\newlength\@yJ
\newlength\@xK\newlength\@yK
\newlength\@xL\newlength\@yL
\newlength\@xM\newlength\@yM
\newlength\@xN\newlength\@yN
\newlength\@xO\newlength\@yO
\newlength\@xP\newlength\@yP
\newlength\@xbl\newlength\@ybl
\newlength\@xtl\newlength\@ytl
\newlength\@xwd\newlength\@yht
\newlength\@wd\newlength\@ht
% smash a text around top-left corner (#1, #2) with margin (#3, #4)
% and dimensions #5x#6. Text is #7
\def\@smashtext#1#2#3#4#5#6{
\@tmplen=#3
\setlength\@xbl{#1+#3}\setlength\@ybl{#2-#4}
\setlength\@xwd{#5-2\@tmplen}
\pgfputat{\pgfpoint{\@xbl}{\@ybl}}{%
\pgfbox[top,left]{\parbox[t]{\@xwd}{\vglue 0pt\textfont #6}}%
}%
}
% smash a frame box around bottom-left corner (#1,#2) with offset (#3,#4)
% and width #5. The text is #6.
\def\@smashbox#1#2#3#4#5#6#7{%
% black frame
\color{black}
\@tmplen=#3
\setlength\@xbl{#1+#3}\setlength\@ybl{#2+#4}
\setlength\@xwd{#5-2\@tmplen}\setlength\@yht{#6}
\pgfrect[fill]{\pgfpoint\@xbl\@ybl}{\pgfpoint\@xwd\@yht}
% white bg in frame
\color{white}
\setlength\@xbl{\@xbl+\framewidth}\setlength\@ybl{\@ybl+\framewidth}%
\setlength\@xwd{\@xwd-2\framewidth}\setlength\@yht{\@yht-2\framewidth}%
\pgfrect[fill]{\pgfpoint\@xbl\@ybl}{\pgfpoint\@xwd\@yht}%
% text
\color{black}
\setlength\@xbl{\@xbl+\framesep}\setlength\@ybl{\@ybl+\framesep}%
\setlength\@xwd{\@xwd-2\framesep}%
\pgfputat{\pgfpoint{\@xbl}{\@ybl}}{%
\pgfbox[left,bottom]{\parbox[b]{\@xwd}{\centering\warningfont #7\vglue 0pt}}%
}%
}
%
\newboolean{@validpack}
% \end{macrocode}
%
%\Finale
\endinput
|