I want to produce instructional 3by5 index cards. It's easy enough to produce the cards one per page, but I want to print five copies of the same car on a single sheet of 8.5by11 card stock, where it is possible to produce five cards per page, two in portrait orientation on the left margin and three in landscape orientation on the right margin, at the top. Note that the back of the page has things reversed, with two cards in portrait orientation on the right margin and three cards in landscape orientation on the left margin, at the bottom. The orientation needs to be rotated for the landscape cards (the text should always appear in portrait mode) and small, very light cut marks should appear at the corners of the cards.

A sample card is appended to this message. The logo at the top of the front of the card, and the copyright notice at the bottom of the front of the card, must always appear in the same place. The text will usually include some program code, as the sample card shows, and possibly some math, a tabular environment, or even a small line-drawing of a data structure.

I am not particularly knowledgeable of LaTeX, using it mostly for simple things similar to what is shown below. I don't know where to start writing a macro to produce 5-up 3by5 cards. Can anybody help?

Many thanks,


% peasant multiplication



\begin{document} \begin{small}

\null \kern -\headheight \kern -\headsep \kern -\topskip \noindent

Copyright \copyright 2012 by Programming Praxis.
All rights reserved.
See http://programmingpraxis.com for more information.

\textbf{Peasant Multiplication}

When the Egyptians built the pyramids, they in­vented a method for multiplying two numbers using only halving, doubling, and addition. As an example, consider the product $83 \times 97 = 8051$:

83 &   97 &   97 \\
41 &  194 &  194 \\
20 &  388        \\
10 &  776        \\
 5 & 1552 & 1552 \\
 2 & 3104        \\
 1 & 6208 & 6208 \\ \cline{3-3}
   &      & 8051

The algorithm starts by writing the two numbers to be multiplied at the head of two columns. Then repeatedly halve the number in the left col­umn, ignoring any remainder, and double the number in the right column, writing the new numbers below their predecessors, until the left column reaches one. Finally, in a third column, the number in the second column is copied whenever the number in the first column of the same row is odd, and the numbers in the third column are summed, giving the product. The algorithm works using binary arithmetic: $97 \times 1 + 97 \times 2 + 97 \times 16 + 97 \times 64 = 8051$, where $1 + 2 + 16 + 64 = 83$ correspond to the positions of the odd numbers in the first column.

It is easy to operate the algorithm by hand using piles of pebbles in pairs. It is also easy to pro­gram the algorithm in a binary computer, where halving and doubling are trivial. In fact, in their internal microcode, most modern computers use exactly this algorithm to multiply two numbers.

A program to implement peasant multiplication performs the addition as it goes instead of wait­ing until the end:

function peasant(left, right)
  prod := 0
  while (left > 0)
    if (left is odd)
      prod := prod + right
    left := halve(left)
    right := double(right)
  return prod

It is amazing, and humbling, to think that mod­ern computers owe a four-thousand year old debt to those ancient mathematicians.

\end {small} \end{document}

EDIT: Thanks for the reference to flashcards, but it doesn't do what I want. I want continuous formatting, not a separate front and back. And I want five cards, not four, because I expect to make lots of cards, which means I have to rotate the text.

I'm thinking about somehow formatting a single card, front and back, using a 3by5 page size, capturing the output in PostScript, and using PostScript to print the 5-up cards. But I don't know enough about PostScript, either.

Any suggestions are welcome.


I recently wanted to do something similar: produce a5 cards but printed on a4 paper, with the a5 pages lining up so that page 2 was on the back of page 1 and so forth. The package pgfpages is almost what I wanted to do this, but it can only deal with one physical page at a time.

So I hacked it.

The result is a package which I've imaginatively called pgfmorepages (CTAN and github) which can deal with more than one physical page at a time. It has the same logic as pgfpages: it gathers a certain number of pages into a set of boxes and then deals them out onto physical pages in accordance with a template. The difference is that in the dealing out process, it can put them on more than one physical page.

So for your index cards, we gather in the first ten "logical" pages, and then place them on two physical pages so that they are in the right layout and so that page 2 is on the back of page 1, and so forth.

The relevant layout is already part of the package. Put that in the same directory as your file, a sample is:


\pgfpagesuselayout{5 index cards}[a4paper]


Note that the size of the index cards is set using the geometry package so that TeX thinks that the pages are the size of the index cards. The a4paper option to the layout says what the real page size is.

Compiling that, I get the following:

example of index card layout

  • When I try to run latex, I get the error pgfcore.sty not found. After some googling, I did sudo apt-get install pgf, but got several 404 not found errors. How do I get pdfcore.sty? – user448810 Jun 23 '12 at 13:05
  • I'm guessing you are on Debian or Ubuntu in which case your version of TeX is quite out of date. You should install the latest TexLive. If you'd rather uou can just install the latest TikZ/PGF. But you have to do it outside the package manager. Instructions found by searching this site. – Loop Space Jun 23 '12 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.