Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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,

Phil

% peasant multiplication

\documentclass{article}
\usepackage[pdftex]{graphicx}
\usepackage{wrapfig}

\setlength{\textheight}{4.75in}
\setlength{\textwidth}{2.75in}
\pagestyle{empty}
\addtolength{\parskip}{+0.3\baselineskip}

\begin{document} \begin{small}

\null \kern -\headheight \kern -\headsep \kern -\topskip \noindent
  \includegraphics[width=2.75in]{ProgrammingPraxis.png}

\begin{figure}[b]\begin{minipage}{\textwidth}\tiny
Copyright \copyright 2012 by Programming Praxis.
All rights reserved.
See http://programmingpraxis.com for more information.
\end{minipage}\end{figure}

\begin{center}
\textbf{Peasant Multiplication}
\end{center}

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$:

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

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:

\begin{footnotesize}\begin{verbatim}
function peasant(left, right)
  prod := 0
  while (left > 0)
    if (left is odd)
      prod := prod + right
    left := halve(left)
    right := double(right)
  return prod
\end{verbatim}\end{footnotesize}

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.

share|improve this question
    
Some code here might be flexible enough, or at least give you a start: ctan.org/tex-archive/macros/latex/contrib/envlab, ctan.org/tex-archive/macros/latex/contrib/flashcards –  Ethan Bolker Jun 16 '12 at 20:48

1 Answer 1

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 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 package is very much at the experimental stage so use with caution - if things break, please let me know. You need the file pgfmorepages.sty from the TeX-SX launchpad directory. I've pre-installed the relevant layout for you. Put that in the same directory as your file, a sample is:

\documentclass{article}
\usepackage[paperheight=4.75in,paperwidth=2.75in]{geometry}
\usepackage{pgfmorepages}
\usepackage{lipsum}

\pgfpagesuselayout{5 index cards}[a4paper]

\begin{document}
\small
\lipsum[1-20]
\end{document}

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

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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