General ⇒ Numbered tickets for stacked printing
Re: Numbered tickets for stacked printing
Any ideas?
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[letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[applemac]{inputenc}
\usepackage[french]{babel}
\usepackage[letterpaper, left=.25in, right=.2in, top=.27in, bottom=.1in]{geometry}
\usepackage{graphicx}
\usepackage{color}
\usepackage{calc}
\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\else#1\fi\fi\fi}
% Counters
% numpage = loop counter (page number)
% numticket = loop counter (ticket number)
% lastprintedticket = number of the last printed ticked. It should be a multiple of 10.
% numpagestoprint = number of pages that will be printed
% lastticket = number of the last ticket to be printed (in fact, that number + 1)
\newcounter{numpage}
\newcounter{numticket}
\renewcommand{\thenumticket}{\zeropadding{\arabic{numticket}}}
\newcounter{lastprintedticket}
\newcounter{numpagestoprint}
\newcounter{lastticket}
% 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 causer à 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 print the tickets.
% There are \value{numpagestoprint} pages in total, with 10 tickets per page,
% starting with ticket no. \value{lastprintedticked} + 1 up to ticket no.
% \value{lastticket} - 1.
\begin{document}
\typein[\answer]{Number of the last printed ticket (a multiple of 10):}
\setcounter{lastprintedticket}{\answer}
\typein[\answer]{Number of pages to be printed:}
\setcounter{numpagestoprint}{\answer}
\setcounter{numpage}{1}
\setcounter{lastticket}{\value{lastprintedticket}+10*\value{numpagestoprint}+1}
\stepcounter{numpagestoprint}
\WhileNum{\value{numpage}<\value{numpagestoprint}}\do{%
\setcounter{numticket}{\value{numpage}+\value{lastprintedticket}}
\noindent
\WhileNum{\value{numticket}<\value{lastticket}}\do{%
\ticket{\thenumticket}\bigskip\hfill%
\addtocounter{numticket}{\value{numpagestoprint}-1}}%
\newpage\stepcounter{numpage}}
\end{document}
- "letter" is not an option of \documentclass. I have written letterpaper
Since text is in french, I think it is better the french option of babel.
I load the calc package to do some arithmetics with counters. It is also possible to load the ifthen package. The \whiledo command defined there could replace the \WhileNum command.
I have added an \else clause in the definition of \zeropadding, needed for printing numbers greater that 999. If you plan to use numbers greater than 9999, you may find convenient to do more changes there.
There are three new counters.
I have put "causer" instead of "causé".
I have rewritten the body of the document. Now one has to provide the number of the last printed ticket and the number of page to be printed. These numbers are saved in the counters lastprintedticket and numpagestoprint. I assume you can compile in an interactive way. So, LaTeX starts processing; then it stops and ask you for the value of lastprintedticket; new stop waiting for the value of numpagestoprint; finally LaTeX completes compilation and builds the pdf. If you don't like this behaviour or you cannot use the TeX console, remove the \typein commands and replace \answer by suitable values.
* 1st run: lastprintedticket=0, numpagestoprint=60
* 2nd run: lastprintedticket=600, numpagestoprint=15
* 3rd run: lastprintedticket=750, numpagestoprint=5
That's all.
Re: Numbered tickets for stacked printing
Re: Numbered tickets for stacked printing
B.A.
Numbered tickets for stacked printing
ddenton wrote: You can ski for free anytime! Come we have lots of snow.
Thanks, but I have a very, very long journey to Quebec. See you.