About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Account
Latest news 2024-09-23: new blog post "Tales for Our Times: Raising Funds and Awareness for St Martins Housing Trust".


10.2 The ticket Package

The ticket package [23] (version 0.4b, 2010-11-30, at the time of writing) can be used to make labels, visiting cards, pins and flash-cards. The ticket settings can be specified in a ticket definition file (with the extension .tdf). This file can then be specified when you load the ticket package:

\usepackage[tdf-file⟩,⟨other options]{ticket}

where ⟨tdf-file⟩ is the filename without the .tdf extension.

In the ticket definition file, you can set up the ticket dimensions. Since this package uses the picture environment, described above, you can adjust the unit of measurement by changing the value of \unitlength in the definition file. Within this file you can also specify the number and layout of tickets using:

\ticketNumbers{num cols}{num rows}

where ⟨num cols⟩ and ⟨num rows⟩ are the number of tickets in the horizontal and vertical directions. The ticket dimensions are specified using:

\ticketSize{width}{height}

where the ⟨width⟩ and ⟨height⟩ are in terms of \unitlength. The distance between the tickets is specified using:

\ticketDistance{x-dist}{y-dist}

where ⟨x-dist⟩ and ⟨y-dist⟩ are the horizontal and vertical distances in terms of \unitlength. Note that you need to set \unitlength before using the above dimension commands.

For single use only, you can just put these settings in your document after you load the ticket package (without specifying the ⟨tdf-file⟩ in the package options).

In the document you can set up the default ticket content by redefining:

\ticketdefault

Since this is placed inside the picture environment, remember to use picture commands, such as \put. The default definition is:

\put ( 5, 5){Ticket....}

Example

Suppose each ticket should have a logo (stored in the image file logo.png) and departmental information:

\renewcommand*{\ticketdefault}{%
 \put (80,82) {\includegraphics[width=12mm]{logo}}
 \put (5,85) {\large\bfseries Secret Lab of Experimental Stuff}
}

(Remember to load the graphicx package.)

The actual ticket is displayed using

\ticket{content}

where ⟨content⟩ is additional content. You either need to have multiple \ticket commands for each ticket or place \ticket inside a loop. (Recall §2.7 Iteration.)

Example

Suppose I want to display a ticket with a name on it:

\ticket
{
  \put (49,30) {\makebox(0,0) {\Large\bfseries Polly Parrot}}
}

This will create a ticket with the default background (as given by \ticketdefault) and the name added to it.

The ticket package documentation suggests defining a wrapper command:

\newcommand*{\myticket}[1]{%
  \ticket
  {
    \put (49,30) {\makebox(0,0) {\Large\bfseries #1}}
  }%
}

Now you can do, for example,

\myticket{Polly Parrot}
\myticket{Mabel Canary}

The ticket package automatically sets the page style to empty. Package options are available to create marks or decorations around the tickets:

crossmark
Puts a cross at all four corners.
circlemark
Puts an unfilled circle at all four corners.
emptycrossmark
Like crossmark but only draws the parts of the marker that lie outside the ticket.
cutmark
Just adds cutmarks at the outer region.
boxed
Adds a frame around the ticket.

Example 50. Name Labels (ticket package)

This example creates a set of six name labels. I've used the geometry package to set up the paper margins and the lmodern package [39] to switch to the Latin Modern fonts. The graphicx package is required for the logo. I've used the sample logo dummy-logo.png, but you can replace this with another image if you like.

\documentclass[a4paper]{article}

% fonts and encodings
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[cutmark]{ticket}
\usepackage[margin=5mm]{geometry}
\usepackage{graphicx}

\setlength{\unitlength}{1mm}
\ticketNumbers{2}{3}
\ticketSize{98}{90}
\ticketDistance{4}{4}

\renewcommand*{\ticketdefault}{%
 \put (80,80) {\includegraphics[width=12mm]{dummy-logo}}
 \put (5,85) {\large\bfseries Secret Lab of Experimental Stuff}
 \put (5,75) {\large\scshape University of Somewhere}
 \put (45,30) {\makebox(0,0){\Large\itshape Culinary Experimental 
Research}}
}

\newcommand*{\myticket}[1]{%
  \ticket
  {
    \put (45,50) {\makebox(0,0) {\Large\bfseries #1}}
  }%
}

\begin{document}
\myticket{Polly Parrot}
\myticket{Mabel Canary}
\myticket{Zöe Zebra}
\myticket{José Arara}
\myticket{Dickie Duck}
\myticket{Fred Canary}
\end{document}

(You can download or view this document.) The resulting document is shown in Figure 10.2.

Figure 10.2: Name Labels (ticket package)
 
Image of tickets. The tickets are arrange in two columns and three rows, and have little marks at the corners.

╴╵ 
  Secret Lab of Experimental Stuff [Image of Logo]
  University of Somewhere
  Polly Parrot
  Culinary Experimental Research
 ╵╶
  Secret Lab of Experimental Stuff [Image of Logo]
  University of Somewhere
  José Arara
  Culinary Experimental Research
  

 
  Secret Lab of Experimental Stuff [Image of Logo]
  University of Somewhere
  Mabel Canary
  Culinary Experimental Research
 
  Secret Lab of Experimental Stuff [Image of Logo]
  University of Somewhere
  Dickie Duck
  Culinary Experimental Research
  

 
  Secret Lab of Experimental Stuff [Image of Logo]
  University of Somewhere
  Zöe Zebra
  Culinary Experimental Research
╴╷ 
  
  Secret Lab of Experimental Stuff [Image of Logo]
  University of Somewhere
  Fred Canary
  Culinary Experimental Research
 ╷╶
End of Image.

Exercise 27. Name Labels (Iteration)

Modify the document in Example 50 so that it uses an iteration method to display the tickets. You can use a comma-separated list with one of the etoolbox commands described in §2.7.2 Iterating Over a Comma-Separated List. (You can download or view a solution.) Alternatively load the names from the sample CSV or SQL data and iterate through the database, as described in §2.7.1 Iterating Through a Database. (You can download or view a solution for the CSV data.)


This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-07-4).

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs