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
|
%%
%%
%% This is file `ticket.sty',
%%
%% File: ticket.sty Copyright (c) 1999,2000,2005 Thomas Emmel
%% <thomas@family-emmel.de>
%%
%%
% This package may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% 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.2 or later is part of all distributions of LaTeX
% version 1999/12/01 or later.
%
% This package consists of the file ticket.sty
%%
% HISTORY:
%
% v0.1a-0.1d non-official implementations
%
% v0.2 fixing some minor bugs and add examples
%
% v0.3a checking for an old calc-package
% v0.3b use internal values if tdf-file is not specified
% v0.3c \ticketreset added.
% v0.3d added option emptycrossmark as provided by
% Rafal Bielski <rafal dot bielski at dhl dot com>
% Similar option was provided by
% Ivan Lloro Boada <antispam at wanadoo dot es>
%
% v0.4a added the flashcard-style invented by
% Santiago Mejia <san_tico at yahoo dot com>
% v0.4b added 'rowmode' introduced by Wulf Coulmann
% <wulf at coulmann dot de>
%
% Many thanks for all contributions
%
%
\def\fileversion{v0.4b}
\def\filedate{2010/11/30}
\ProvidesPackage{ticket}[\filedate\space\fileversion]
\typeout{Package: `ticket' \fileversion\space <\filedate> (Thomas Emmel)}
\newif\if@crossmark \@crossmarkfalse
\newif\if@circlemark \@circlemarkfalse
\newif\if@emptycrossmark \@emptycrossmarkfalse
\newif\if@cutmark \@cutmarkfalse
\newif\if@boxed \@boxedfalse
\newif\if@extern \@externfalse
\newif\if@backside \@backsidefalse
\newif\if@rowmode \@rowmodefalse
\DeclareOption{boxed}{\@boxedtrue}
\DeclareOption{crossmark}{\@crossmarktrue}
\DeclareOption{circlemark}{\@circlemarktrue}
\DeclareOption{emptycrossmark}{\@emptycrossmarktrue}
\DeclareOption{cutmark}{\@cutmarktrue}
\DeclareOption{rowmode}{\@rowmodetrue}
\DeclareOption*{\edef\ticketToUse{\CurrentOption.tdf}\@externtrue}%
\ProcessOptions
%
\RequirePackage{ifthen}
\RequirePackage{calc}
% older calc packages have a small bug
\@ifpackagelater{calc}{1998/07/06}%
{% Yes. OK!
}
{% No.
\PackageWarning{ticket}
{Package calc too old (older than v4.1b).}%
}%
\pagestyle{empty}
% standard definitions
\topmargin=0pt
\headheight=0pt
\headsep=0pt
\oddsidemargin=0pt
\evensidemargin=0pt
\footskip=0pt
\voffset=0pt
\hoffset=0pt
\unitlength=1mm
%
\newcounter{ticket@x}
\newcounter{ticket@y}
\setcounter{ticket@x}{1}
\setcounter{ticket@y}{1}
\newcounter{ticket@num@X}% Number of tickets in horizontal direction
\newcounter{ticket@num@Y}% Number of tickets in vertical direction
\setcounter{ticket@num@X}{2}% default value
\setcounter{ticket@num@Y}{3}% default value
\def\ticketNumbers#1#2{\setcounter{ticket@num@X}{#1}%
\setcounter{ticket@num@Y}{#2}}
%
\newdimen\ticketWidth% width of a ticket
\newdimen\ticketHeight% height of a ticket
\newdimen\ticket@dis@X% horizontal space between tickets
\newdimen\ticket@dis@Y% vertical space between tickets
\ticket@dis@X=0mm% default value
\ticket@dis@Y=0mm% default value
\def\ticketSize#1#2{\gdef\ticket@size@X{#1}\ticketWidth=#1\unitlength%
\gdef\ticket@size@Y{#2}\ticketHeight=#2\unitlength}
\def\ticketDistance#1#2{\ticket@dis@X=#1\unitlength%
\ticket@dis@Y=#2\unitlength}
%% now load ticket definitions from file
\if@extern
\InputIfFileExists{\ticketToUse}
{\typeout{load \ticketToUse}}
{\errmessage{\ticketToUse\space not found! Please use another file}}
\else
\unitlength=1mm
\hoffset=0mm
\voffset=0mm
\ticketNumbers{2}{2}
\ticketSize{50}{20}
\ticketDistance{5}{10}
\fi
%% temporary length
\newdimen\ticket@shift@x
\newdimen\ticket@shift@y
\newdimen\back@shift
\setlength{\back@shift}{(\ticketWidth+\ticket@dis@X)*(\theticket@num@X-1)}%
%% a restart
\def\ticketreset{%
\setcounter{ticket@x}{1}\setcounter{ticket@y}{1}%
\if@backside%
\setlength{\ticket@shift@y}{0pt}%
\setlength{\ticket@shift@x}{\back@shift}%
\else%
\setlength{\ticket@shift@y}{0pt}%
\setlength{\ticket@shift@x}{0pt}%
\fi}
%% backsides should be handled different for flashcards
\def\backside{%
\@backsidetrue%
\ticketreset%
\clearpage}%
% the heart: a "counter"
\newcommand{\ticket@counter}{%
\if@rowmode%
\ifthenelse{\value{ticket@x}<\value{ticket@num@X}}%
{\stepcounter{ticket@x}\\[-\baselineskip]}%
% otherwise:
{\setcounter{ticket@x}{1}%
\ifthenelse{\value{ticket@y}<\value{ticket@num@Y}}%
{\stepcounter{ticket@y}\\[-\baselineskip]}%
% otherwise:
{\setcounter{ticket@y}{1}\setcounter{ticket@x}{1}\newpage}}%
\setlength{\ticket@shift@y}{(\ticketHeight+\ticket@dis@Y)*(\theticket@y-1)}%
\if@backside%
\setlength{\ticket@shift@x}{\back@shift-(\ticketWidth+\ticket@dis@X)*(\theticket@x-1)}%
\else%
\setlength{\ticket@shift@x}{(\ticketWidth+\ticket@dis@X)*(\theticket@x-1)}%
\fi%
\else%
\ifthenelse{\value{ticket@y}<\value{ticket@num@Y}}%
{\stepcounter{ticket@y}\\[-\baselineskip]}%
% otherwise:
{\setcounter{ticket@y}{1}%
\ifthenelse{\value{ticket@x}<\value{ticket@num@X}}%
{\stepcounter{ticket@x}\\[-\baselineskip]}%
% otherwise:
{\setcounter{ticket@x}{1}\setcounter{ticket@y}{1}\newpage}}%
\setlength{\ticket@shift@y}{(\ticketHeight+\ticket@dis@Y)*(\theticket@y-1)}%
\if@backside%
\setlength{\ticket@shift@x}{\back@shift-(\ticketWidth+\ticket@dis@X)*(\theticket@x-1)}%
\else%
\setlength{\ticket@shift@x}{(\ticketWidth+\ticket@dis@X)*(\theticket@x-1)}%
\fi%
\fi}%
% default content...
% users should renew this command
\newcommand{\ticketdefault}{%
%
\put( 5, 5){Ticket....}%
}%
% the main command: \ticket
% users should define a command like \myticket to get more than one parameter
\newcommand{\ticket}[1]{%
% position global
\noindent%
\raisebox{-\ticket@shift@y}[0mm][0mm]{%
\raisebox{-\ticketHeight}[0mm][0mm]{%
\hspace*{\ticket@shift@x}%
%
% open a picture of zero size and place some crosses
\begin{picture}(0,0)%
\if@crossmark%
\put(0,0){\ticket@cross}%
\put(0,\ticket@size@Y){\ticket@cross}%
\put(\ticket@size@X,0){\ticket@cross}%
\put(\ticket@size@X,\ticket@size@Y){\ticket@cross}%
\fi%
\if@circlemark%
\put(0,0){\circle{1}}%
\put(0,\ticket@size@Y){\circle{1}}%
\put(\ticket@size@X,0){\circle{1}}%
\put(\ticket@size@X,\ticket@size@Y){\circle{1}}%
\fi%
\if@boxed%
\put(0,0){\line(1,0){\ticket@size@X}}%
\put(0,0){\line(0,1){\ticket@size@Y}}%
\put(\ticket@size@X,\ticket@size@Y){\line(-1,0){\ticket@size@X}}%
\put(\ticket@size@X,\ticket@size@Y){\line(0,-1){\ticket@size@Y}}%
\fi%
\if@emptycrossmark%
\put(0,0){\begin{picture}(0,0)%
\put(-1,0){\line(-1,0){1}}%
\put(0,-1){\line(0,-1){1}}\end{picture}}%
\put(0,\ticket@size@Y){\begin{picture}(0,0)%
\put(-1,0){\line(-1,0){1}}%
\put(0,1){\line(0,1){1}}\end{picture}}%
\put(\ticket@size@X,0){\begin{picture}(0,0)%
\put(1,0){\line(1,0){1}}%
\put(0,-1){\line(0,-1){1}}\end{picture}}%
\put(\ticket@size@X,\ticket@size@Y){\begin{picture}(0,0)%
\put(1,0){\line(1,0){1}}%
\put(0,1){\line(0,1){1}}\end{picture}}%
\fi%
\if@cutmark%
\ifthenelse{\value{ticket@x}=1}%
{\put(-1,0){\line(-1,0){1}}\put(-1,\ticket@size@Y){\line(-1,0){1}}}{}%
\ifthenelse{\value{ticket@y}=1}%
{\put(0,\ticket@size@Y){\begin{picture}(0,0)%
\put(0,1){\line(0,1){1}}\end{picture}}%
\put(\ticket@size@X,\ticket@size@Y){\begin{picture}(0,0)%
\put(0,1){\line(0,1){1}}\end{picture}}}{}%
\ifthenelse{\value{ticket@x}=\value{ticket@num@X}}%
{\put(\ticket@size@X,0){\begin{picture}(0,0)%
\put(1,0){\line(1,0){1}}\end{picture}}%
\put(\ticket@size@X,\ticket@size@Y){\begin{picture}(0,0)%
\put(1,0){\line(1,0){1}}\end{picture}}}{}%
\ifthenelse{\value{ticket@y}=\value{ticket@num@Y}}%
{\put(0,-1){\line(0,-1){1}}\put(\ticket@size@X,-1){\line(0,-1){1}}}{}%
\fi%
% put the default content into the ticket
\ticketdefault%
% put the variable content into the ticket
#1%
\end{picture}}}\ticket@counter}%
%
\def\ticket@cross{%
\begin{picture}(0,0)%
\put(-1,0){\line(1,0){2}}\put(0,-1){\line(0,1){2}}%
\end{picture}}%
%
\endinput
|