GeneralNumbered tickets for stacked printing

LaTeX specific issues not fitting into one of the other forums of this category.
ddenton
Posts: 34
Joined: Tue Mar 20, 2007 6:08 pm

Numbered tickets for stacked printing

Post by ddenton »

I am trying to print numbered tickets in Latex. I think I might be able to use a package like Labels to get the size right, let's say 10 on a page, to number them sequentially and to put a graphic on each. Let's say that I want to create 200 tickets (20 pages of output). My problem is how to set it up for "stacked" printing, so, that the tickets in the upper left position would be numbered 1 on page 1, 2 on page 2, etc. up to 20. Then, those in the upper right position would be numbered 21 on page 1, 22 on page 2, 23 on page 3, etc. etc..

Is there any Latex package that could help with this kind of printing problem? I had thought that pdfpages could be of use, but I don't think so.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Numbered tickets for stacked printing

Post by Juanjo »

Please, try the following code:

Code: Select all

\documentclass[a4paper]{article}

\makeatletter
\let\WhileNum\@whilenum
\makeatother

\newcounter{numpage}
\newcounter{numticket}

\begin{document}

\newcommand{\ticket}[1]{\fbox{\parbox[c][0.15\textheight][c]{0.45\textwidth}%
   {\centering Ticket no. #1}}}

\setcounter{numpage}{1}
\WhileNum{\value{numpage}<21}\do{%
  \setcounter{numticket}{\value{numpage}}
  \noindent
  \WhileNum{\value{numticket}<201}\do{%
     \ticket{\thenumticket}\bigskip\hfill%
     \addtocounter{numticket}{20}}%
  \newpage\stepcounter{numpage}}

\end{document}
Is that what are you searching for?

See, for example, page 19 of the resulting document.
Tickets.pdf
(11.62 KiB) Downloaded 394 times
ddenton
Posts: 34
Joined: Tue Mar 20, 2007 6:08 pm

Re: Numbered tickets for stacked printing

Post by ddenton »

Thank you Juanjo, this is brilliant.

I hate to push this, but what if one was to put a logo in each on of the ticket boxes? I tried this and found no way to keep the images in the fboxes, and it threw everything off. Any suggestions?
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Numbered tickets for stacked printing

Post by Juanjo »

Replace the preceding definition of \ticket by the following one:

Code: Select all

\newcommand{\ticket}[1]{\fbox{\parbox[c][0.15\textheight][c]{0.45\textwidth}%
   {\centering \includegraphics[width=0.25\textwidth,%
     height=0.1\textheight,keepaspectratio]{ctanlion.jpg} \\ Ticket no. #1}}}
I attach the image I use to test the code and, again, page 19 of the resulting document.
Of course, add \usepackage{graphicx} to the preamble.

Good luck.
Attachments
Tickets.pdf
(49.8 KiB) Downloaded 371 times
Test image
Test image
ctanlion.jpg (37.3 KiB) Viewed 8206 times
ddenton
Posts: 34
Joined: Tue Mar 20, 2007 6:08 pm

Numbered tickets for stacked printing

Post by ddenton »

Thanks again. Your code works beautifully.

It is very close, but now I am falling down because I do not know how to control fboxes and parboxes, especially where images are concerned. What I am trying to do as to reproduce something that looks like the pdf file attached here. There are a few text areas: one with the ticket number which is rotated 90 deg., one with a title centred on the left half and some other text centred below it, and the last one on the right half, rotated 90 deg. and in a box.

Also, I am wondering if there is any way that the latex counter can fill with zeros (1 = 0001).

Any further help you can provide would be greatly appreciated. Sorry to be so picky, but I feel like it is close, but still beyond my reach with my limited knowledge of Latex.
pass_latin.pdf
(26.29 KiB) Downloaded 267 times
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Numbered tickets for stacked printing

Post by Juanjo »

Here you have a code to get tickets quite similar to that you are trying to reproduce. Once more, I attach page 19.

Code: Select all

\documentclass[a4paper]{article}
\usepackage{graphicx}
\usepackage{color}
\usepackage[cm]{fullpage}

% Color for the tickets
\definecolor{ticket}{cmyk}{0,0.42,1,0}

% Command for loops
\makeatletter
\let\WhileNum\@whilenum
\makeatother

% Command for adding zeros on the left of a number
\newcommand{\zeropadding}[1]{%
  \ifnum#1<10 000#1\else \ifnum#1<100 00#1\else \ifnum#1<1000 0#1\fi\fi\fi}

% Counters
% numpage = number of pages with tickets
% numticket = number of tickets per page
\newcounter{numpage}
\newcounter{numticket}
\renewcommand{\thenumticket}{\zeropadding{\arabic{numticket}}}

% Ticket dimensions
\newlength{\ticketheight}
\newlength{\ticketwidth}
\setlength{\ticketheight}{0.16\textheight}
\setlength{\ticketwidth}{0.47\textwidth}

% Box on the left of the ticket: text and graphics
\newsavebox{\leftbox}
\sbox{\leftbox}%
  {\parbox[c][\ticketheight][c]{0.45\ticketwidth}%
    {\centering {\sffamily\bfseries\large NAM LIGULA} \\[2pt]
     \footnotesize Nam ligula justo, iaculis ut, sagittis vitae, 
      molestie et, urna. Nullam quis risus. Phasellus lacinia turpis
      quis justo. Nulla ultrices \\[2pt]
      \includegraphics[width=0.4\ticketwidth,%
        height=0.4\ticketheight,keepaspectratio]{ctanlion.jpg}}}

% Boxed box on the right of the ticket
\newbox{\rightbox}
\sbox{\rightbox}{\setlength{\fboxrule}{3pt}%
  \framebox[\ticketheight]{\parbox{0.45\ticketwidth}{\footnotesize 
     Nam ligula justo, iaculis ut, sagittis vitae, molestie et, urna.
     Nullam quis risus. Phasellus lacinia turpis quis justo. Nulla
     ultrices auctor risus. Mauris leo. Quisque et est at dolor aliquet
     sagittis. Nulla ultrices auctor risus. Mauris leo.
     Quisque et est at dolor aliquet sagittis.}}}

% Command for printing each ticket
\newcommand{\ticket}[1]{\colorbox{ticket}%
  {\parbox[c][\ticketheight][c]{\ticketwidth}%
     {\enskip\rotatebox[origin=cc]{90}{\bfseries No. #1}\quad%
      \usebox{\leftbox}\hfill%
       \rotatebox[origin=cc]{90}{\usebox{\rightbox}}}}}

% Body of the document. Let's start printing 
% 200 tickets = 20 pages x 10 tickets/page.

\begin{document}

\setcounter{numpage}{1}
\WhileNum{\value{numpage}<21}\do{%
  \setcounter{numticket}{\value{numpage}}
  \noindent
  \WhileNum{\value{numticket}<201}\do{%
     \ticket{\thenumticket}\bigskip\hfill%
     \addtocounter{numticket}{20}}%
  \newpage\stepcounter{numpage}}

\end{document}
It has been a quite challenging question. Now it is your turn. Try to understand and improve the code. Replace the latin text by the correct one, format it as you like, and adapt dimensions of boxes, lengths and spaces.

Good luck.
Attachments
Tickets.pdf
(74.04 KiB) Downloaded 315 times
ddenton
Posts: 34
Joined: Tue Mar 20, 2007 6:08 pm

Re: Numbered tickets for stacked printing

Post by ddenton »

Hello Juanjo,

Many thanks for this, a bit of tweaking and it has worked out perfectly. I believe that your code (now beautifully commented) could help quite a few other people. I was unable to find anything on the web that would allow me to do this except high end (and extremely expensive) ticket printing programs, or very expensive publishing packages. Or, a printer tells me I could have fiddled with Word mailmerge linked to an Excel file with the numbers, but using Latex is much more fun!

So thanks again.
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Re: Numbered tickets for stacked printing

Post by Juanjo »

Please, could you post the code and graphic file for the final real ticket you get? I'm a bit curious about that.

It has been nice to help you.
ddenton
Posts: 34
Joined: Tue Mar 20, 2007 6:08 pm

Numbered tickets for stacked printing

Post by ddenton »

I did a little hacking (with apologies) to make it work for me: used geometry rather than fullpage, made the ticket sizes absolute. This was necessary to get the correct spacing between the two rows. And a few other spacing adjustments. The tickets are for a volunteer-run cross-county ski club. They will be printed on mactac.

Code: Select all

\documentclass[letter]{article}
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage[english]{babel}
\usepackage[letterpaper, left=.25in, right=.2in, top=.27in, bottom=.1in]{geometry}
\usepackage{graphicx}
\usepackage{color}
\pagestyle{empty}

% Color for the tickets
%\definecolor{ticket}{cmyk}{.4,0,1,0}%light green
%\definecolor{ticket}{cmyk}{0,.2,1,0}%deep yellow
%\definecolor{ticket}{cmyk}{.4,0,0,0}%ice blue
%\definecolor{ticket}{cmyk}{0,.6,.4,0}%deep pink
\definecolor{ticket}{cmyk}{0,0.42,1,0}%light browny orange


% Command for loops
\makeatletter
\let\WhileNum\@whilenum
\makeatother

% Command for adding zeros on the left of a number
\newcommand{\zeropadding}[1]{%
  \ifnum#1<10 000#1\else \ifnum#1<100 00#1\else \ifnum#1<1000 0#1\fi\fi\fi}

% Counters
% numpage = number of pages with tickets
% numticket = number of tickets per page
\newcounter{numpage}
\newcounter{numticket}
\renewcommand{\thenumticket}{\zeropadding{\arabic{numticket}}}

% Ticket dimensions
\newlength{\ticketheight}
\newlength{\ticketwidth}
\setlength{\ticketheight}{1.80in}
\setlength{\ticketwidth}{3.8in}

% Box on the left of the ticket: text and graphics
\newsavebox{\leftbox}
\sbox{\leftbox}%
  {\parbox[c][\ticketheight][c]{0.45\ticketwidth}%
    {\centering {\sffamily\bfseries\LARGE BONNE\\ RANDONNÉE~!} \\[2pt]
     \scriptsize C.P. 772, \\VAL-D’OR, QC, \\J9P 2G3 \\
   819-825-4398 \\[5pt]
      \includegraphics[width=0.45\ticketwidth,%
        height=0.45\ticketheight,keepaspectratio]{ski_new_half}}}

% Boxed box on the right of the ticket
\newbox{\rightbox}
\sbox{\rightbox}{\setlength{\fboxrule}{3pt}\setlength{\fboxsep}{3pt}%
  \framebox[\ticketheight]{\parbox{0.43\ticketwidth}{\footnotesize \raggedright
La pratique du ski de fond comporte des risques et dangers
inhérents. Le détenteur accepte d'assumer seul l'entière
responsabilité de tous dommages de toute nature qu'il pourrait
subir ou causé à l'autrui et accepte de dégager et d'indemniser
le Club de ski de fond de Val-d'Or à cet égard.}}}

% Command for printing each ticket
\newcommand{\ticket}[1]{\colorbox{ticket}%
  {\parbox[c][\ticketheight][c]{\ticketwidth}%
     {\enskip\rotatebox[origin=cc]{90}{\bfseries No. #1}\quad%
      \usebox{\leftbox}\hfill%
       \rotatebox[origin=cc]{90}{\usebox{\rightbox}}}}}

% Body of the document. Let's start printing
% 200 tickets = 20 pages x 10 tickets/page.

\begin{document}

\setcounter{numpage}{1}
\WhileNum{\value{numpage}<61}\do{%
  \setcounter{numticket}{\value{numpage}}
  \noindent
  \WhileNum{\value{numticket}<601}\do{%
     \ticket{\thenumticket}
     \bigskip
     \hfill%
     \addtocounter{numticket}{60}}%
  \newpage\stepcounter{numpage}}

\end{document}
Attachments
Pages from tickets_green.pdf
(50.81 KiB) Downloaded 348 times
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Numbered tickets for stacked printing

Post by Juanjo »

Good job! Thanks.

Just a final comment: is it "subir ou causé à l'autrui" or, instead, "subir ou causer à l'autrui"?
Post Reply