General ⇒ Numbered tickets for stacked printing
Numbered tickets for stacked printing
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.
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
Numbered tickets for stacked printing
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}
See, for example, page 19 of the resulting document.
Re: Numbered tickets for stacked printing
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?
Numbered tickets for stacked printing
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}}}
Of course, add \usepackage{graphicx} to the preamble.
Good luck.
- Attachments
-
- Tickets.pdf
- (49.8 KiB) Downloaded 371 times
-
- Test image
- ctanlion.jpg (37.3 KiB) Viewed 8204 times
Numbered tickets for stacked printing
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.
Numbered tickets for stacked printing
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}
Good luck.
- Attachments
-
- Tickets.pdf
- (74.04 KiB) Downloaded 315 times
Re: Numbered tickets for stacked printing
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.
Re: Numbered tickets for stacked printing
It has been nice to help you.
Numbered tickets for stacked printing
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
Numbered tickets for stacked printing
Just a final comment: is it "subir ou causé à l'autrui" or, instead, "subir ou causer à l'autrui"?