summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/makebarcode/makebarcode.tex
blob: 98a0faf12ae2ab077e8471cd5802c3ca76e23642 (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
%% $Id: zwpagelayout.tex 214 2008-06-26 23:08:07Z zw $
\input utf8-t1 % encTeX required
\documentclass[11pt]{article}
\usepackage{zwgetfdate}
\usepackage[footskip=30pt,topmargin=2cm,leftmargin=2cm,rightmargin=4cm,botmargin]{zwpagelayout}
\usepackage[T1]{fontenc}
\usepackage{lmodern,array,dcolumn,rotating}
\usepackage[help,H=3mm,S.6]{makebarcode}
\usepackage[protrusion=false,expansion=true,stretch=8,shrink=24,step=4]{microtype}
\makeatletter
\renewcommand*\l@section{\@dottedtocline{1}{\z@}{1.5em}}
\makeatother
\extrarowheight 2pt
\mubytein 0 % important due to bug in url.sty
\usepackage[pdftitle=Bar\ Codes, pdfauthor=Zdenek\ Wagner,
            pdfkeywords={bar code, 2/5, Code39, ITF-6, ITF-14, ITF-16},
            bookmarks,bookmarksopen,bookmarksopenlevel=2]{hyperref}
\mubytein 1 \mubyteout 1 \mubytelog 1

\marginparwidth\UserRightMargin
\advance\marginparwidth -1cm
\advance\marginparwidth-\marginparsep

\def\mg#1{\ifvmode\leavevmode\fi\marginpar{\texttt{#1}}\ignorespaces}
\def\cmg#1{\mg{\char`\\#1}}
\def\omg#1{\ifvmode\leavevmode\fi\marginpar{\raggedright\hspace{0pt}\opt{#1}}\ignorespaces}
\def\opt#1{\texorpdfstring{\textmd{\textsc{#1}}}{#1}}
\let\pkg\textsc
\DeclareRobustCommand\cmd[1]{\texttt{\char`\\#1}}
\def\ie.{i.\,e.\@}
\def\eg.{e.\,g.\@}
\def\true{\bool{true}}
\def\false{\bool{false}}
\def\bool#1{\texorpdfstring{\textit{#1}}{#1}}
\def\is{\unskip\nobreak\space =\penalty200 \space\ignorespaces}

\def\bcd#{\barcode[code=Code39,X=.5mm,ratio=2.25,H=1cm]}

\let\zwcomma\,
\def\,{\texorpdfstring{\zwcomma}{}}

\begin{document}

\clubpenalty 10000
\widowpenalty 10000
\raggedbottom

\title{Bar Codes}
\author{Zdeněk Wagner\\\url{http://icebearsoft.euweb.cz}}
\date{Package date: \DateOfPackage{makebarcode}}
\maketitle

\begin{abstract}\noindent
The package contains macros for printing various 2/5 bar codes and Code 39
bar codes. The macros do not use fonts but create the bar codes directly
by vrules. It is therefore possible to vary width to height ratio, ration
of thin and thick bars. The package is therefore convenient for printing
ITF bar codes as well as bar codes for identification labels for HP
storage media.
\end{abstract}

\tableofcontents

\section{Introduction}
The development of the package started due to practical need. Bar code labels for HP storage media
are quite expensive. However, the bar codes may easily be produced by \TeX. The documentation
clearly specifies that the bar code is of the Code39 type~[\ref{hpstorage}, \ref{hplabel}]. 
It may seem that the task is easy.

The common denominator of the 2/5 codes and Code39 is that they are formed of thin and thick bars.
The ratio of thin and thick bars may vary as well as the width-to-height ratio. It may therefore be
impossible to use bar code fonts for a particular application. On the other hand a bar code may
simply be created by rules. This approach was inspired by the \texttt{ean13.tex} file developed by
Petr Olšák~[\ref{olsak}].

Since the HP documentation does not specify dimensions, it was clear that some experimentation will
be necessary. The macro should thus be general with dimensions controlled by parameters. It is not
much work to make the macro really general with bar codes defined in tables. The same macro can
thus produce several types of barcodes. Moreover, the 2/5 bar codes are simpler and serve therefore
better to debugging and testing the macro during development.

The structure of the package allows for implementation of other types of the bar codes. Some of
them will be implemented in the next version.

The bar codes may contain a checksum digit. The macro in this package is able neither to generate
them nor to check them. It is up to the user to specify the full code.

\section{Usage}\label{usage}
The package is loaded simply by:

\vb
\verb;\usepackage[;$\langle$options$\rangle$\verb;]{makebarcode};

\vb\noindent
The bar code may then be printed by command

\vb
\verb;\barcode[;$\langle$options$\rangle$\verb;]{;$\langle$code$\rangle$\verb;};

\vb
Options that ar not given in the \cmd{barcode} command are taken form those specified for the whole
package or the default values are used. Typically you will specify the most frequently options in
the \cmd{usepackage} command. Notice that the options in the square brackets of both commands are
optional. In the extreme case you may wish to print the bar codes of type Code39, module width
0.5\,mm, ratio of thin and thick bars 2.25 and height 1\,cm. You therefore load the package using

\vb
\verb;\usepackage[code=Code39,X=.5mm,ratio=2.25,H=1cm]{makebarcode};

\vb\noindent
and produce the bar codes simply by

\vb
\verb;\barcode{MAKEBARCODE.STY};\par
\verb;\barcode{ZDENEK WAGNER};

\vb\noindent
These commands will produce the following bar codes:

\vb
\begin{center}
\bcd{MAKEBARCODE.STY}

\bcd{ZDENEK WAGNER}
\end{center}

\section{General Options}
The general options are available both for the \cmd{usepackage} command and for the \cmd{barcode}
macro. They cannot be used with high-level macros \cmd{ITFbarcode} and \cmd{HPlabel}.

Almost all options have default values and may also be used without specification of a value. This will
reset the option to the default value. It may be useful if you wish to reset the default in the
\cmd{barcode} macro.

\omg{help}
The \opt{help} option can only be used with the \cmd{usepackage} command. It prints the list of the
supported bar codes to the log file.

\omg{bcorr}
Some applications require correction of the bar and blank width. The \opt{bcorr} option defines
dimension that is subtracted from each bar and added to each blank. The default value is 0\,mm.

\section{Low-Level Options}\label{low}
\omg{code}
The \opt{code} option select the type of the bar code. The list of valid values will be given
in later sections. This is the only option that has no default value.

\omg{X}
Option \opt{X} specifies the module width, \ie. the width of a thin line. Its default value is the
smallest allowed width 0.19\,mm.

\omg{H}
The \opt{H} option is the width of the bar code. The default value is calculated dynamically as
40~times the module width.

\omg{ratio}
The \opt{ratio} option defines the ratio of thin and thick bars. The default value is~3. Remember
that some applications require a particular value.

\omg{K}
The \opt{K} option specifies the width of a bar used in the start/stop characters of the 2/5 Matrix
bar code as a multiple of the width of the thick bar. It must hold $1.5 \leq \mathrm{K} \leq 4$. The
default value is~2.

\omg{MtoXratio}
The characters in most bar codes start and end with a bar so that they must be separated with w
blank space. The width of the space must be wide at least as the module width but may be larger.
The width of such a space is defined as a ration to the module width by the \opt{MtoXratio} option.
Its default value is~1. It will rarely be changed.

\section{Family of 2/5 Bar Codes}
The package implements the whole family of 2/5 bar codes. Their list is given in table~\ref{25}.
Remember that the 2/5 Interleaved bar code requires even number of digits. If odd number of digits
is given, zero is prepended.

\begin{table}[hbt]
\caption{Samples of 2/5 barcodes, encoded sequence is 0123456789, module width 0,19\,mm, ratio~3,
height~3\,mm}\label{25}
\medskip
\begin{center}
\begin{tabular}{|r|l|}\hline
\bfseries Code name & \bfseries Bar code\\\hline
2/5-Industrial & \barcode[code=2/5-Industrial]{0123456789} \\
2/5-Inverted& \barcode[code=2/5-Inverted]{0123456789}\\                                                            
2/5-IATA& \barcode[code=2/5-IATA]{0123456789}\\
2/5-Matrix& \barcode[code=2/5-Matrix]{0123456789}\\
2/5-Datalogic& \barcode[code=2/5-Datalogic]{0123456789}\\
2/5-Interleaved& \barcode[code=2/5-Interleaved]{0123456789}\\
\hline
\end{tabular}
\end{center}
\end{table}

\section{Code39}
The package currently supports only the basic version of the Code39 bar code. The sample is given in
section~\ref{usage}. The full ASCII bar code will be implemented in a later version of the package.

\section{Labels for HP Storage Media}
\cmg{HPlabel}
The labels for HP storage media are produced by the \cmd{HPlabel} command. Its parametr is the
requested code. The code must contain exactly 8~characters. The syntax is fixed but not verified by
the macro. It is only checked whether the number of charactes is correct. It is required that the
\pkg{rotating} package is loaded manually. Options described in section~\ref{low} cannot be used as
an optional argument and are ignored if given in the \cmd{usepackage} command because all
dimensions are fixed.

The author of the package gives no warranty that the code produced by this macro will be usable. HP
requires high printing quality saying that laser printers are not good enough for such purpose.
However, bars on the labels bought from HP were grey, not black. As already written the dimensions
are not given in the documentation. The dimensions used here were determined by careful measuring a
bought label. A label printed on an HP laser printer with resolution 600\,dpi was tested on a real
hardware and it worked.

An example of such a bar code is given in figure~\ref{hp}. The frame
is not a part of the \cmd{HPlabel} macro output but is displayed here in order to show the real
size of the label.

\begin{figure}[hbt]
\begin{center}
\fboxsep 0mm
\fbox{\HPlabel{CLNU01L1}}
\end{center}
\caption{Example of a label for an HP cleaning casette, code CLNU01L1}\label{hp}
\end{figure}

\section{ITF-6, ITF-14, And ITF-16 Bar Codes}\label{itf}
\cmg{ITFbarcode}
The ITF bar codes are basically 2/5 Interleaved codes with 6, 14 or 16 digits. The last digit is a
checksum calculated by the same algorithm as for EAN13 bar codes. The macro verifies the number of
digits supplied, not the checksum. The bar code must be printed in a
frame. Sometimes only horizontal lines are sufficient. Human readable information is printed below
the bar code. The author has seen several types of formatting the human readable information on real bar
codes. The one that seemed most reasonable was therefore chosen.

The bar code is always composed in a \cmd{vbox}. It might be necessary to use \cmd{leavevmode} in
front of the \cmd{ITFbarcode} macro.

Dimensions of the ITF bar codes are fixed. Options defines in section~\ref{low} are thus ignored,
only the \opt{bcorr} option is allowed. Properties of the ITF bar codes are selected by a special
set of options that can be given either as an optional argument to the \cmd{ITFbarcode} macro or in
the \cmd{usepackage} command.

\omg{frame}
The \opt{frame} option is boolean, \ie. allowed values are \true\ and \false. The default value is
\true. It requires prining the bar code inside a frame. An example is shown in
figure~\ref{itf.frame}.

\begin{figure}[hbt]
\begin{center}
\leavevmode\ITFbarcode{15412345678908}
\end{center}
\caption{ITF-14 bar code with a frame}\label{itf.frame}
\end{figure}

\omg{lines}
The \opt{lines} option is complementary to the \opt{frame} options. Its default value is therefore
\false. It requires printing the bar code within lines as shown in figure~\ref{itf.lines}.

\begin{figure}[hbt]
\begin{center}
\leavevmode\ITFbarcode[lines]{15412345678908}
\end{center}
\caption{ITF-14 bar code with lines}\label{itf.lines}
\end{figure}

\omg{S.6}\omg{S.7}\omg{S.8}\omg{S.9}\omg{S1}\omg{S1.1}\omg{S1.2}
Size of the ITF bar code can be selected from the list of predefined options. The names of these
options are derived from the values of the scaling factors. By choosing the size options the
low-level options \opt{X} and \opt{H} are set to proper values. Option \opt{ratio} is always~2.5
and \opt{MtoXratio} is~1. Option \opt{code} is \texttt{2/5-Interleaved}. The framed form requires a
blank area in front of and after the bar code (inside the frame). All dimensions are given in
table~\ref{itfdim}. If no size option is given, \opt{S1} is the default. Human readable information
is always typeset with the OCR-B font at 12\,pt.

\begin{table}[hbt]
\caption{Dimensions of the ITF bar codes (in milimeters)}\label{itfdim}
\medskip
\begin{center}
\newcolumntype{N}{D{.}{.}{3}}
\newcolumntype{M}{D{.}{.}{1}}
\newcommand*\R[1]{\multicolumn{1}{r}{\bfseries #1}}
\newcommand*\RR[1]{\multicolumn{1}{r|}{\bfseries #1}}
\begin{tabular}{|lNNMM|}\hline
\bfseries Option & \R{Scale} & \R{Module} & \R{Blank area} & \RR{Height}\\ \hline
S1.2& 1.2 &  1.219 & 13.1 & 38.2 \\
S1.1& 1.1 &  1.118 & 12.0 & 35.0 \\
S1  & 1.0 &  1.016 & 10.9 & 31.8 \\
S.9 & 0.9 &  0.914 &  9.8 & 28.7 \\
S.8 & 0.8 &  0.813 &  8.7 & 25.4 \\
S.7 & 0.7 &  0.711 &  7.1 & 22.3 \\
S.6 & 0.625& 0.635 &  6.4 & 19.8 \\
\hline
\end{tabular}
\end{center}
\end{table}

                                                                                                                   
\section{License}
The package can be used and distributed according to the LaTeX Project Public License version~1.3
or later the
text of which can be found at the \texttt{License.txt} file in the \texttt{doc} directory or at
\url{http://www.latex-project.org/lppl.txt}
                                                                                                                   
\section{References}
\begin{enumerate}\itemsep 0mm \parsep 0mm
\item Storage Media from HP. \url{http://www.hp.com/go/storagemedia}\label{hpstorage}
\item HP Bar Code Label Packs.
\url{http://h18006.www1.hp.com/storage/tapestorage/storagemedia/bar\_code\_label.html}\label{hplabel}
\item Petr Olšák: The EAN barcodes by \TeX. TUGboat 15 (December 1994), No. 4, pp.~459--464.
\url{http://www.tug.org/TUGboat/Articles/tb15-4/tb45olsa.pdf}\label{olsak}
 
\item Adriana Benadiková, Stefan Mada and Stanislav
Weinlich: \textit{Čárové kódy, automatická iden\-ti\-fi\-kace (Barcodes, the Automatic
Identification)}.
Grada 1994, 272 pp., ISBN \hbox{80-85623-66-8}.
\end{enumerate}

\end{document}