| 1 |
%% $Id: zwpagelayout.tex 214 2008-06-26 23:08:07Z zw $ |
| 2 |
\input utf8-t1 % encTeX required |
| 3 |
\documentclass[11pt]{article} |
| 4 |
\usepackage{zwgetfdate} |
| 5 |
\usepackage[footskip=30pt,topmargin=2cm,leftmargin=2cm,rightmargin=4cm,botmargin]{zwpagelayout} |
| 6 |
\usepackage[T1]{fontenc} |
| 7 |
\usepackage{lmodern,array,dcolumn,rotating} |
| 8 |
\usepackage[help,H=3mm,S.6]{makebarcode} |
| 9 |
\usepackage[protrusion=false,expansion=true,stretch=8,shrink=24,step=4]{microtype} |
| 10 |
\makeatletter |
| 11 |
\renewcommand*\l@section{\@dottedtocline{1}{\z@}{1.5em}} |
| 12 |
\makeatother |
| 13 |
\extrarowheight 2pt |
| 14 |
\mubytein 0 % important due to bug in url.sty |
| 15 |
\usepackage[pdftitle=Bar\ Codes, pdfauthor=Zdenek\ Wagner, |
| 16 |
pdfkeywords={bar code, 2/5, Code39, ITF-6, ITF-14, ITF-16}, |
| 17 |
bookmarks,bookmarksopen,bookmarksopenlevel=2]{hyperref} |
| 18 |
\mubytein 1 \mubyteout 1 \mubytelog 1 |
| 19 |
|
| 20 |
\marginparwidth\UserRightMargin |
| 21 |
\advance\marginparwidth -1cm |
| 22 |
\advance\marginparwidth-\marginparsep |
| 23 |
|
| 24 |
\def\mg#1{\ifvmode\leavevmode\fi\marginpar{\texttt{#1}}\ignorespaces} |
| 25 |
\def\cmg#1{\mg{\char`\\#1}} |
| 26 |
\def\omg#1{\ifvmode\leavevmode\fi\marginpar{\raggedright\hspace{0pt}\opt{#1}}\ignorespaces} |
| 27 |
\def\opt#1{\texorpdfstring{\textmd{\textsc{#1}}}{#1}} |
| 28 |
\let\pkg\textsc |
| 29 |
\DeclareRobustCommand\cmd[1]{\texttt{\char`\\#1}} |
| 30 |
\def\ie.{i.\,e.\@} |
| 31 |
\def\eg.{e.\,g.\@} |
| 32 |
\def\true{\bool{true}} |
| 33 |
\def\false{\bool{false}} |
| 34 |
\def\bool#1{\texorpdfstring{\textit{#1}}{#1}} |
| 35 |
\def\is{\unskip\nobreak\space =\penalty200 \space\ignorespaces} |
| 36 |
|
| 37 |
\def\bcd#{\barcode[code=Code39,X=.5mm,ratio=2.25,H=1cm]} |
| 38 |
|
| 39 |
\let\zwcomma\, |
| 40 |
\def\,{\texorpdfstring{\zwcomma}{}} |
| 41 |
|
| 42 |
\begin{document} |
| 43 |
|
| 44 |
\clubpenalty 10000 |
| 45 |
\widowpenalty 10000 |
| 46 |
\raggedbottom |
| 47 |
|
| 48 |
\title{Bar Codes} |
| 49 |
\author{Zdeněk Wagner\\\url{http://icebearsoft.euweb.cz}} |
| 50 |
\date{Package date: \DateOfPackage{makebarcode}} |
| 51 |
\maketitle |
| 52 |
|
| 53 |
\begin{abstract}\noindent |
| 54 |
The package contains macros for printing various 2/5 bar codes and Code 39 |
| 55 |
bar codes. The macros do not use fonts but create the bar codes directly |
| 56 |
by vrules. It is therefore possible to vary width to height ratio, ration |
| 57 |
of thin and thick bars. The package is therefore convenient for printing |
| 58 |
ITF bar codes as well as bar codes for identification labels for HP |
| 59 |
storage media. |
| 60 |
\end{abstract} |
| 61 |
|
| 62 |
\tableofcontents |
| 63 |
|
| 64 |
\section{Introduction} |
| 65 |
The development of the package started due to practical need. Bar code labels for HP storage media |
| 66 |
are quite expensive. However, the bar codes may easily be produced by \TeX. The documentation |
| 67 |
clearly specifies that the bar code is of the Code39 type~[\ref{hpstorage}, \ref{hplabel}]. |
| 68 |
It may seem that the task is easy. |
| 69 |
|
| 70 |
The common denominator of the 2/5 codes and Code39 is that they are formed of thin and thick bars. |
| 71 |
The ratio of thin and thick bars may vary as well as the width-to-height ratio. It may therefore be |
| 72 |
impossible to use bar code fonts for a particular application. On the other hand a bar code may |
| 73 |
simply be created by rules. This approach was inspired by the \texttt{ean13.tex} file developed by |
| 74 |
Petr Olšák~[\ref{olsak}]. |
| 75 |
|
| 76 |
Since the HP documentation does not specify dimensions, it was clear that some experimentation will |
| 77 |
be necessary. The macro should thus be general with dimensions controlled by parameters. It is not |
| 78 |
much work to make the macro really general with bar codes defined in tables. The same macro can |
| 79 |
thus produce several types of barcodes. Moreover, the 2/5 bar codes are simpler and serve therefore |
| 80 |
better to debugging and testing the macro during development. |
| 81 |
|
| 82 |
The structure of the package allows for implementation of other types of the bar codes. Some of |
| 83 |
them will be implemented in the next version. |
| 84 |
|
| 85 |
The bar codes may contain a checksum digit. The macro in this package is able neither to generate |
| 86 |
them nor to check them. It is up to the user to specify the full code. |
| 87 |
|
| 88 |
\section{Usage}\label{usage} |
| 89 |
The package is loaded simply by: |
| 90 |
|
| 91 |
\vb |
| 92 |
\verb;\usepackage[;$\langle$options$\rangle$\verb;]{makebarcode}; |
| 93 |
|
| 94 |
\vb\noindent |
| 95 |
The bar code may then be printed by command |
| 96 |
|
| 97 |
\vb |
| 98 |
\verb;\barcode[;$\langle$options$\rangle$\verb;]{;$\langle$code$\rangle$\verb;}; |
| 99 |
|
| 100 |
\vb |
| 101 |
Options that ar not given in the \cmd{barcode} command are taken form those specified for the whole |
| 102 |
package or the default values are used. Typically you will specify the most frequently options in |
| 103 |
the \cmd{usepackage} command. Notice that the options in the square brackets of both commands are |
| 104 |
optional. In the extreme case you may wish to print the bar codes of type Code39, module width |
| 105 |
0.5\,mm, ratio of thin and thick bars 2.25 and height 1\,cm. You therefore load the package using |
| 106 |
|
| 107 |
\vb |
| 108 |
\verb;\usepackage[code=Code39,X=.5mm,ratio=2.25,H=1cm]{makebarcode}; |
| 109 |
|
| 110 |
\vb\noindent |
| 111 |
and produce the bar codes simply by |
| 112 |
|
| 113 |
\vb |
| 114 |
\verb;\barcode{MAKEBARCODE.STY};\par |
| 115 |
\verb;\barcode{ZDENEK WAGNER}; |
| 116 |
|
| 117 |
\vb\noindent |
| 118 |
These commands will produce the following bar codes: |
| 119 |
|
| 120 |
\vb |
| 121 |
\begin{center} |
| 122 |
\bcd{MAKEBARCODE.STY} |
| 123 |
|
| 124 |
\bcd{ZDENEK WAGNER} |
| 125 |
\end{center} |
| 126 |
|
| 127 |
\section{General Options} |
| 128 |
The general options are available both for the \cmd{usepackage} command and for the \cmd{barcode} |
| 129 |
macro. They cannot be used with high-level macros \cmd{ITFbarcode} and \cmd{HPlabel}. |
| 130 |
|
| 131 |
Almost all options have default values and may also be used without specification of a value. This will |
| 132 |
reset the option to the default value. It may be useful if you wish to reset the default in the |
| 133 |
\cmd{barcode} macro. |
| 134 |
|
| 135 |
\omg{help} |
| 136 |
The \opt{help} option can only be used with the \cmd{usepackage} command. It prints the list of the |
| 137 |
supported bar codes to the log file. |
| 138 |
|
| 139 |
\omg{bcorr} |
| 140 |
Some applications require correction of the bar and blank width. The \opt{bcorr} option defines |
| 141 |
dimension that is subtracted from each bar and added to each blank. The default value is 0\,mm. |
| 142 |
|
| 143 |
\section{Low-Level Options}\label{low} |
| 144 |
\omg{code} |
| 145 |
The \opt{code} option select the type of the bar code. The list of valid values will be given |
| 146 |
in later sections. This is the only option that has no default value. |
| 147 |
|
| 148 |
\omg{X} |
| 149 |
Option \opt{X} specifies the module width, \ie. the width of a thin line. Its default value is the |
| 150 |
smallest allowed width 0.19\,mm. |
| 151 |
|
| 152 |
\omg{H} |
| 153 |
The \opt{H} option is the width of the bar code. The default value is calculated dynamically as |
| 154 |
40~times the module width. |
| 155 |
|
| 156 |
\omg{ratio} |
| 157 |
The \opt{ratio} option defines the ratio of thin and thick bars. The default value is~3. Remember |
| 158 |
that some applications require a particular value. |
| 159 |
|
| 160 |
\omg{K} |
| 161 |
The \opt{K} option specifies the width of a bar used in the start/stop characters of the 2/5 Matrix |
| 162 |
bar code as a multiple of the width of the thick bar. It must hold $1.5 \leq \mathrm{K} \leq 4$. The |
| 163 |
default value is~2. |
| 164 |
|
| 165 |
\omg{MtoXratio} |
| 166 |
The characters in most bar codes start and end with a bar so that they must be separated with w |
| 167 |
blank space. The width of the space must be wide at least as the module width but may be larger. |
| 168 |
The width of such a space is defined as a ration to the module width by the \opt{MtoXratio} option. |
| 169 |
Its default value is~1. It will rarely be changed. |
| 170 |
|
| 171 |
\section{Family of 2/5 Bar Codes} |
| 172 |
The package implements the whole family of 2/5 bar codes. Their list is given in table~\ref{25}. |
| 173 |
Remember that the 2/5 Interleaved bar code requires even number of digits. If odd number of digits |
| 174 |
is given, zero is prepended. |
| 175 |
|
| 176 |
\begin{table}[hbt] |
| 177 |
\caption{Samples of 2/5 barcodes, encoded sequence is 0123456789, module width 0,19\,mm, ratio~3, |
| 178 |
height~3\,mm}\label{25} |
| 179 |
\medskip |
| 180 |
\begin{center} |
| 181 |
\begin{tabular}{|r|l|}\hline |
| 182 |
\bfseries Code name & \bfseries Bar code\\\hline |
| 183 |
2/5-Industrial & \barcode[code=2/5-Industrial]{0123456789} \\ |
| 184 |
2/5-Inverted& \barcode[code=2/5-Inverted]{0123456789}\\ |
| 185 |
2/5-IATA& \barcode[code=2/5-IATA]{0123456789}\\ |
| 186 |
2/5-Matrix& \barcode[code=2/5-Matrix]{0123456789}\\ |
| 187 |
2/5-Datalogic& \barcode[code=2/5-Datalogic]{0123456789}\\ |
| 188 |
2/5-Interleaved& \barcode[code=2/5-Interleaved]{0123456789}\\ |
| 189 |
\hline |
| 190 |
\end{tabular} |
| 191 |
\end{center} |
| 192 |
\end{table} |
| 193 |
|
| 194 |
\section{Code39} |
| 195 |
The package currently supports only the basic version of the Code39 bar code. The sample is given in |
| 196 |
section~\ref{usage}. The full ASCII bar code will be implemented in a later version of the package. |
| 197 |
|
| 198 |
\section{Labels for HP Storage Media} |
| 199 |
\cmg{HPlabel} |
| 200 |
The labels for HP storage media are produced by the \cmd{HPlabel} command. Its parametr is the |
| 201 |
requested code. The code must contain exactly 8~characters. The syntax is fixed but not verified by |
| 202 |
the macro. It is only checked whether the number of charactes is correct. It is required that the |
| 203 |
\pkg{rotating} package is loaded manually. Options described in section~\ref{low} cannot be used as |
| 204 |
an optional argument and are ignored if given in the \cmd{usepackage} command because all |
| 205 |
dimensions are fixed. |
| 206 |
|
| 207 |
The author of the package gives no warranty that the code produced by this macro will be usable. HP |
| 208 |
requires high printing quality saying that laser printers are not good enough for such purpose. |
| 209 |
However, bars on the labels bought from HP were grey, not black. As already written the dimensions |
| 210 |
are not given in the documentation. The dimensions used here were determined by careful measuring a |
| 211 |
bought label. A label printed on an HP laser printer with resolution 600\,dpi was tested on a real |
| 212 |
hardware and it worked. |
| 213 |
|
| 214 |
An example of such a bar code is given in figure~\ref{hp}. The frame |
| 215 |
is not a part of the \cmd{HPlabel} macro output but is displayed here in order to show the real |
| 216 |
size of the label. |
| 217 |
|
| 218 |
\begin{figure}[hbt] |
| 219 |
\begin{center} |
| 220 |
\fboxsep 0mm |
| 221 |
\fbox{\HPlabel{CLNU01L1}} |
| 222 |
\end{center} |
| 223 |
\caption{Example of a label for an HP cleaning casette, code CLNU01L1}\label{hp} |
| 224 |
\end{figure} |
| 225 |
|
| 226 |
\section{ITF-6, ITF-14, And ITF-16 Bar Codes}\label{itf} |
| 227 |
\cmg{ITFbarcode} |
| 228 |
The ITF bar codes are basically 2/5 Interleaved codes with 6, 14 or 16 digits. The last digit is a |
| 229 |
checksum calculated by the same algorithm as for EAN13 bar codes. The macro verifies the number of |
| 230 |
digits supplied, not the checksum. The bar code must be printed in a |
| 231 |
frame. Sometimes only horizontal lines are sufficient. Human readable information is printed below |
| 232 |
the bar code. The author has seen several types of formatting the human readable information on real bar |
| 233 |
codes. The one that seemed most reasonable was therefore chosen. |
| 234 |
|
| 235 |
The bar code is always composed in a \cmd{vbox}. It might be necessary to use \cmd{leavevmode} in |
| 236 |
front of the \cmd{ITFbarcode} macro. |
| 237 |
|
| 238 |
Dimensions of the ITF bar codes are fixed. Options defines in section~\ref{low} are thus ignored, |
| 239 |
only the \opt{bcorr} option is allowed. Properties of the ITF bar codes are selected by a special |
| 240 |
set of options that can be given either as an optional argument to the \cmd{ITFbarcode} macro or in |
| 241 |
the \cmd{usepackage} command. |
| 242 |
|
| 243 |
\omg{frame} |
| 244 |
The \opt{frame} option is boolean, \ie. allowed values are \true\ and \false. The default value is |
| 245 |
\true. It requires prining the bar code inside a frame. An example is shown in |
| 246 |
figure~\ref{itf.frame}. |
| 247 |
|
| 248 |
\begin{figure}[hbt] |
| 249 |
\begin{center} |
| 250 |
\leavevmode\ITFbarcode{15412345678908} |
| 251 |
\end{center} |
| 252 |
\caption{ITF-14 bar code with a frame}\label{itf.frame} |
| 253 |
\end{figure} |
| 254 |
|
| 255 |
\omg{lines} |
| 256 |
The \opt{lines} option is complementary to the \opt{frame} options. Its default value is therefore |
| 257 |
\false. It requires printing the bar code within lines as shown in figure~\ref{itf.lines}. |
| 258 |
|
| 259 |
\begin{figure}[hbt] |
| 260 |
\begin{center} |
| 261 |
\leavevmode\ITFbarcode[lines]{15412345678908} |
| 262 |
\end{center} |
| 263 |
\caption{ITF-14 bar code with lines}\label{itf.lines} |
| 264 |
\end{figure} |
| 265 |
|
| 266 |
\omg{S.6}\omg{S.7}\omg{S.8}\omg{S.9}\omg{S1}\omg{S1.1}\omg{S1.2} |
| 267 |
Size of the ITF bar code can be selected from the list of predefined options. The names of these |
| 268 |
options are derived from the values of the scaling factors. By choosing the size options the |
| 269 |
low-level options \opt{X} and \opt{H} are set to proper values. Option \opt{ratio} is always~2.5 |
| 270 |
and \opt{MtoXratio} is~1. Option \opt{code} is \texttt{2/5-Interleaved}. The framed form requires a |
| 271 |
blank area in front of and after the bar code (inside the frame). All dimensions are given in |
| 272 |
table~\ref{itfdim}. If no size option is given, \opt{S1} is the default. Human readable information |
| 273 |
is always typeset with the OCR-B font at 12\,pt. |
| 274 |
|
| 275 |
\begin{table}[hbt] |
| 276 |
\caption{Dimensions of the ITF bar codes (in milimeters)}\label{itfdim} |
| 277 |
\medskip |
| 278 |
\begin{center} |
| 279 |
\newcolumntype{N}{D{.}{.}{3}} |
| 280 |
\newcolumntype{M}{D{.}{.}{1}} |
| 281 |
\newcommand*\R[1]{\multicolumn{1}{r}{\bfseries #1}} |
| 282 |
\newcommand*\RR[1]{\multicolumn{1}{r|}{\bfseries #1}} |
| 283 |
\begin{tabular}{|lNNMM|}\hline |
| 284 |
\bfseries Option & \R{Scale} & \R{Module} & \R{Blank area} & \RR{Height}\\ \hline |
| 285 |
S1.2& 1.2 & 1.219 & 13.1 & 38.2 \\ |
| 286 |
S1.1& 1.1 & 1.118 & 12.0 & 35.0 \\ |
| 287 |
S1 & 1.0 & 1.016 & 10.9 & 31.8 \\ |
| 288 |
S.9 & 0.9 & 0.914 & 9.8 & 28.7 \\ |
| 289 |
S.8 & 0.8 & 0.813 & 8.7 & 25.4 \\ |
| 290 |
S.7 & 0.7 & 0.711 & 7.1 & 22.3 \\ |
| 291 |
S.6 & 0.625& 0.635 & 6.4 & 19.8 \\ |
| 292 |
\hline |
| 293 |
\end{tabular} |
| 294 |
\end{center} |
| 295 |
\end{table} |
| 296 |
|
| 297 |
|
| 298 |
\section{License} |
| 299 |
The package can be used and distributed according to the LaTeX Project Public License version~1.3 |
| 300 |
or later the |
| 301 |
text of which can be found at the \texttt{License.txt} file in the \texttt{doc} directory or at |
| 302 |
\url{http://www.latex-project.org/lppl.txt} |
| 303 |
|
| 304 |
\section{References} |
| 305 |
\begin{enumerate}\itemsep 0mm \parsep 0mm |
| 306 |
\item Storage Media from HP. \url{http://www.hp.com/go/storagemedia}\label{hpstorage} |
| 307 |
\item HP Bar Code Label Packs. |
| 308 |
\url{http://h18006.www1.hp.com/storage/tapestorage/storagemedia/bar\_code\_label.html}\label{hplabel} |
| 309 |
\item Petr Olšák: The EAN barcodes by \TeX. TUGboat 15 (December 1994), No. 4, pp.~459--464. |
| 310 |
\url{http://www.tug.org/TUGboat/Articles/tb15-4/tb45olsa.pdf}\label{olsak} |
| 311 |
|
| 312 |
\item Adriana Benadiková, Stefan Mada and Stanislav |
| 313 |
Weinlich: \textit{Čárové kódy, automatická iden\-ti\-fi\-kace (Barcodes, the Automatic |
| 314 |
Identification)}. |
| 315 |
Grada 1994, 272 pp., ISBN \hbox{80-85623-66-8}. |
| 316 |
\end{enumerate} |
| 317 |
|
| 318 |
\end{document} |