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
|
%%
%%
%% This is file `ticket.sty',
%%
%% File: ticket.sty Copyright (c) 1999,2000, Thomas Emmel
%% <emmel@mechanik.tu-darmstadt.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.
\def\fileversion{v0.3c}
\def\filedate{2000/10/10}
\ProvidesPackage{ticket}[\filedate\space\fileversion]
\typeout{Package: `ticket' \fileversion\space <\filedate> (Thomas Emmel)}
\newif\if@crossmark \@crossmarkfalse
\newif\if@circlemark \@circlemarkfalse
\newif\if@boxed \@boxedfalse
\newif\if@extern \@externfalse
\DeclareOption{boxed}{\@boxedtrue}
\DeclareOption{crossmark}{\@crossmarktrue}
\DeclareOption{circlemark}{\@circlemarktrue}
\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
\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
\def\ticketreset{\setcounter{ticket@x}{1}\setcounter{ticket@y}{1}%
\setlength{\ticket@shift@y}{0pt}%
\setlength{\ticket@shift@x}{0pt}}
% the heart: a "counter"
\newcommand{\ticket@counter}{%
\ifthenelse{\value{ticket@y}<\value{ticket@num@Y}}%
{\stepcounter{ticket@y}\\[-\baselineskip]}%
{\setcounter{ticket@y}{1}%
\ifthenelse{\value{ticket@x}<\value{ticket@num@X}}%
{\stepcounter{ticket@x}\\[-\baselineskip]}%
{\setcounter{ticket@x}{1}\setcounter{ticket@y}{1}\newpage}}%
\setlength{\ticket@shift@y}{(\ticketHeight+\ticket@dis@Y)*(\theticket@y-1)}%
\setlength{\ticket@shift@x}{(\ticketWidth+\ticket@dis@X)*(\theticket@x-1)}%
}%
% 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
\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
% 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
|