5

I want to print "stickers" with on it : * a barcode * a validity date * maybe some others informations.

I have A4 papers of stickers : 65 stickers : 38mm x 21mm ; 5 columns, 13 rows. Stickers I am using There is no space between rows ; between the 5 columns, there are 2mm space (4 x 2mm space between columns).

The barcode/validity date (...) will be created probably as an .eps , this will be made from an outside script, which will populate the model_stickers.tex using the last cell_number in comment to choose which cells will be populated for this particular print.

I thought the "model_stickers.tex" could be a written like this, but I can't find a way to really create the document as I would like.

\documentclass[english,10pt,a4paper]{article}
% The a4 page to print as a 4mm margin on right and left
% and a 10mm margin on top and bottom
% which leaves a 202mm x 276mm working area
\usepackage[a4paper, textheight=276mm, textwidth=202mm]{geometry}
\pagestyle{empty}
\renewcommand{\arraystretch}{5}
\begin{document}
%\begin{tabu}{|p{38mm}|p{2mm}|p{38mm}|p{2mm}|p{38mm}|p{2mm}|p{38mm}|p{2mm}|p{38mm}|}
\begin{tabu} to \textwidth{|p{38mm-2\tabcolsep}|p{38mm-2\tabcolsep}|p{38mm-2\tabcolsep}|p{38mm-2\tabcolsep}|p{38mm-1\tabcolsep}|}
\centering 1st cell &&       % cell_1
\centering 2nd cell &&       % cell_2
\centering 3rd cell &&       % cell_3
\centering 4th cell &&       % cell_4
\centering 5th cell \\       % cell_5
\hline
%(...)
\centering 61th cell &&      % cell_61
\centering 62th cell &&      % cell_62
\centering 63th cell &&      % cell_63
\centering 64th cell &&      % cell_64
\centering 65th cell \\      % cell_65
\end{tabu}

Of course, in production, i won't put "\hline" and vline {|p|p|p|}... But I can't figure out how to get so one "model_stickers.{ps,dvi,pdf}" with the table as i wish. Even if I use "p{40mm-2\tabcolsep}", or trying to use {easytable} ... Always there is something that block me. Someone could put me on the way of which "documentclass", which "tabular/tabularx/tabu/easytable"... and which options would be the best to achieve what I'm trying to do ?

example of barcode image with expiration date

1 Answer 1

4

The letteracdp document class (of which I am the author, actually :-) is meant for writing letters, but has an environment for producing address labels that might come in handy in your situation:

\documentclass[a4paper]{letteracdp}
\usepackage[T1]{fontenc}
\usepackage[ascii]{inputenc}

\setcounter{addrlabelcolumns}{5}
\setcounter{addrlabelrows}   {13}
\setlength{\addrlabelwidth} {38mm}
\setlength{\addrlabelheight}{21mm}
\setlength{\addrlabelshsep}  {2mm} % horizontal separation between labels
\setlength{\addrlabelsvsep}  {0mm} %   vertical separation between labels
\setlength{\addrlabelstopmargin} {1cm} % top margin above labels
\setlength{\addrlabelsleftmargin}{6mm} % left margin

% The following draws a thin border around the labels:
\renewenvironment*{labels}{%
    \begin{baselabels}%
        \setlength{\fboxrule}{.2pt}% adjust according to your needs
        \addtolength{\fboxsep}{-2\fboxrule}%
}{%
    \end{baselabels}%
}

\newcommand*{\sticker}[1]{\basemlabel{}{\centering #1}}



\begin{document}

\begin{labels}
    \begin{labelgroup}
        % You could also use a loop, here:
        % row #1
        \sticker{First\\sticker}
        \sticker{Second\\sticker}
        \sticker{Third\\sticker}
        \sticker{Fourth\\sticker}
        \sticker{Fifth\\sticker}
        % row #2
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        % row #3
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        % ... and so on
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
    \end{labelgroup}
\end{labels}

\end{document}

The above code produces only the first four rows, but the principle is clear! Here’s the output it produces:

Sample page

Addition

The letteracdp class has an added bonus that is quite useful for automatic inclusion of graphics files named myImage1.<ext>, myImage2.<ext>, myImage3.<ext>, … myImage10.<ext>, and so on: it steps a (LaTeX) counter named label each time it prints a label; moreover, this counter is reset to zero at the beginning of each labelgroup environment (actually, this environment exists solely for this purpose).

For example, the following code includes a second labelgroup environment, in which we generate stickers containing the three sample images named image-a, image-b, and image-c (they are provided by the mwe package):

\documentclass[a4paper]{letteracdp}
\usepackage[T1]{fontenc}
\usepackage[ascii]{inputenc}
\usepackage{mwe}

\setcounter{addrlabelcolumns}{5}
\setcounter{addrlabelrows}   {13}
\setlength{\addrlabelwidth} {38mm}
\setlength{\addrlabelheight}{21mm}
\setlength{\addrlabelshsep}  {2mm} % horizontal separation between labels
\setlength{\addrlabelsvsep}  {0mm} %   vertical separation between labels
\setlength{\addrlabelborder} {2mm} % clearance around label contents 
\setlength{\addrlabelstopmargin} {1cm} % top margin above labels
\setlength{\addrlabelsleftmargin}{6mm} % left margin

% The following draws a thin border around the labels:
\renewenvironment*{labels}{%
    \begin{baselabels}%
        \setlength{\fboxrule}{.2pt}% adjust according to your needs
        \addtolength{\fboxsep}{-2\fboxrule}%
}{%
    \end{baselabels}%
}

\newcommand*{\sticker}[1]{\basemlabel{}{\centering #1}}



\begin{document}

\begin{labels}
    \begin{labelgroup}
        % You could also use a loop, here:
        % row #1
        \sticker{First\\sticker}
        \sticker{Second\\sticker}
        \sticker{Third\\sticker}
        \sticker{Fourth\\sticker}
        \sticker{Fifth\\sticker}
        % row #2
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        % row #3
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        % ... and so on
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
        \sticker{And so on\\sticker}
    \end{labelgroup}

    \begin{labelgroup}
        % You can also use the "label" counter, which is stepped each time
        % a label is printed, to select which graphics file to load.
        % This counter is reset to zero at the beginning of each "labelgroup"
        % environment (this is, actually, the only purpose of this environment).
        % For example, to load files "image-a", "image-b", and "image-c":
        \sticker{
            \includegraphics[
                    width  = \addrlabeltrimwidth,
                    height = \addrlabeltrimheight
                ]{image-\alph{label}}
        }
        \sticker{
            \includegraphics[
                    width  = \addrlabeltrimwidth,
                    height = \addrlabeltrimheight
                ]{image-\alph{label}}
        }
        \sticker{
            \includegraphics[
                    width  = \addrlabeltrimwidth,
                    height = \addrlabeltrimheight
                ]{image-\alph{label}}
        }
        \sticker{There is no\\\texttt{image-\alph{label}} file}
        \sticker{Neither\\\texttt{image-\alph{label}}}
    \end{labelgroup}
\end{labels}

\end{document}

This is the corresponding output:

Output of the second code sample

You can adjust the border around the image by setting the \addrlabelborder length. Here I have used a value of 2mm.

2
  • Your template create the page i'm looking for, thanks a lot. But strangely, the sticker i put in it ends up in the right of the cell, not right in the cell: \sticker{\includegraphics{barcode.png}} is that the way I should do ?
    – franck
    Mar 28, 2016 at 0:59
  • 1
    @franck: Please see edit.
    – GuM
    Mar 28, 2016 at 1:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .