chiark / gitweb /
Correct typo emtpy -> empty
[flashcards] / flashcards.dtx
1 % \iffalse
2 %
3 %FlashCards LaTeX2e Class for Typesetting Double Sided Cards
4 %Copyright (C) 2000  Alexander M. Budge <ambudge@mit.edu>
5 %
6 %This program is free software; you can redistribute it and/or modify
7 %it under the terms of the GNU General Public License as published by
8 %the Free Software Foundation; either version 2 of the License, or
9 %(at your option) any later version.
10 %
11 %This program is distributed in the hope that it will be useful,
12 %but WITHOUT ANY WARRANTY; without even the implied warranty of
13 %MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 %GNU General Public License for more details.
15 %
16 %You should have received a copy of the GNU General Public License
17 %along with this program (the file COPYING); if not, write to the
18 %Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 %
20 %<*driver>
21 \def\filename{flashcards.dtx}
22 \def\fileversion{1.0.1}
23 \def\filedate{13 August 2010}
24 \def\docdate{16 March 2000}
25 %</driver>
26 %
27 %% \CharacterTable
28 %%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
29 %%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
30 %%   Digits        \0\1\2\3\4\5\6\7\8\9
31 %%   Exclamation   \!     Double quote  \"     Hash (number) \#
32 %%   Dollar        \$     Percent       \%     Ampersand     \&
33 %%   Acute accent  \'     Left paren    \(     Right paren   \)
34 %%   Asterisk      \*     Plus          \+     Comma         \,
35 %%   Minus         \-     Point         \.     Solidus       \/
36 %%   Colon         \:     Semicolon     \;     Less than     \<
37 %%   Equals        \=     Greater than  \>     Question mark \?
38 %%   Commercial at \@     Left bracket  \[     Backslash     \\
39 %%   Right bracket \]     Circumflex    \^     Underscore    \_
40 %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
41 %%   Right brace   \}     Tilde         \~}
42 %%
43 %
44 %<flashcards|sample|avery5371|avery5388>\NeedsTeXFormat{LaTeX2e}[1996/12/01]
45 %<flashcards>\ProvidesClass{flashcards}[2010/08/13 1.0.1 (matthew@debian.org)]
46 %<sample>\ProvidesFile{samplecards.tex}
47 %<avery5371>\ProvidesFile{avery5371.cfg}
48 %<avery5388>\ProvidesFile{avery5388.cfg}
49 %<flashcards>\RequirePackage{ifthen}
50 %<flashcards>\LoadClass{article}
51 %
52 %<*driver>
53 \documentclass{ltxdoc}
54 \newcommand{\flashcards}{\textsc{FlashCards}}
55 \begin{document}
56 \title{\flashcards
57   \thanks{Contains version \fileversion\ last revised \filedate}}
58 \author{Alexander M. Budge \\ \texttt{<ambudge@mit.edu>}}
59 \date{\docdate}
60 \maketitle
61 \DocInput{\filename}
62 \end{document}
63 %</driver>
64 %
65 % \fi
66 %
67 % \MakeShortVerb{\|}
68 %
69 % \changes{v1.0.1}{13 August 2010}{Bug-fix Release.}
70 % \changes{v1.0.0}{16 March 2000}{Full Release.}
71 % \changes{v0.1.1}{14 March 2000}{Second Pre-release.}
72 % \changes{v0.1.0}{12 March 2000}{First Pre-release.}
73 %
74 % \tableofcontents
75 %
76 % \section{Introduction}
77 %   The \flashcards\ class provides for the typesetting of flash
78 %   cards in \LaTeXe.  By flash card, I mean a two sided card which
79 %   has a prompt or a question on one side and the response or the
80 %   answer on the flip (back) side.  Flash cards come in many sizes
81 %   depending on the nature of the information they contain. In
82 %   particular, I like using both $3 \times 5''$ (index cards) and
83 %   $2 \times 3\frac{1}{2}''$ (business cards) which are available
84 %   in perforated sheets suitable for printing or copying onto.
85 %
86 %   In order to use this package effectively, you will need to
87 %   accurately configure |dvips| (or similar) for your printer.
88 %   \LaTeX\ provides a helpful |testpage.tex| for this purpose.
89 %
90 %
91 % \section{Using FlashCards}
92 %   \flashcards\ utilizes the standard \LaTeXe\ class interface. Your
93 %   document should be begin with:
94 %   \begin{center}
95 %     |\documentclass[|\textit{options}|]{flashcards}|
96 %   \end{center}
97 %   
98 % \subsection{Options}
99 %   \DescribeMacro{avery5371}
100 %   All documents should specify the paper type.  I have provided
101 %   the two that I use, business cards (Avery 5371 as well as Avery
102 %   5376, 5377, 5911, 8371, 8376, 8377, 8471 and 8373) and
103 %   \DescribeMacro{avery5388}
104 %   index cards (Avery 5388), but variants are easy to generate.  Please
105 %   refer to Section \ref{sec:paperconfig}  for the details of creating
106 %   your own configuration file for a particular type of paper.
107 %
108 %   \DescribeMacro{fronts}
109 %   If desired, you can typeset just the |fronts| of the cards or just
110 %   the |backs| of the cards.  Useful if your printer does not print
111 %   \DescribeMacro{backs}
112 %   two sides without your help, although |dvips| offers the same
113 %   functionality with odd/even switches (|-A| or |-B|, respectively).
114 %
115 %   \DescribeMacro{grid}
116 %   Useful for getting everything lined up as well as for examining
117 %   the cards as you create them, the |grid| option will draw lines
118 %   where the perforation will be.
119 %
120 %   \DescribeMacro{frame}
121 %   The |frame| option will frame the contents of the card with a thin
122 %   line.  There will be a uniform margin (see below for how to set it)
123 %   between the edge of the card and the frame. 
124 %
125 %   \DescribeMacro{dvips}
126 %   If you are using landscape oriented paper, you may want to use the
127 %   |dvips| option to send the right specials to |dvips| so that it
128 %   knows about the orientation without have to tell it from the
129 %   command line.  Warning: this option displaces my margins, if the
130 %   same happens to you, then you will want to avoid it or create a
131 %   special configuration for this case.  There must be some
132 %   alternative configuration file somewhere that gets used when this
133 %   option is specified for the |geometry| package.
134 %
135 % \subsection{Environment}
136 %   \DescribeEnv{flashcard}
137 %   The \flashcards\ class provideds the environment |flashcard|
138 %   for specifying the contents of each flash card.  The |flashcard|
139 %   environment has one required argument, which becomes the
140 %   contents of the front side of the card (the question or prompt).
141 %   The body of the environment then becomes the contents of the
142 %   back side of the card.  For example,
143 %   \begin{verbatim}
144 %     \begin{flashcard}{Dense Subset}
145 %       A subset $S$ of a normed space $B$ is called \emph{dense}
146 %       in $B$ if {\rm cl} $S$ = $B$.
147 %     \end{flashcard}
148 %   \end{verbatim}
149 %   will produce the front-back pair:
150 %   \begin{center}
151 %     \fbox{\parbox[t][1in][c]{2in}{%
152 %       \footnotesize\vspace*{\fill}\par
153 %       \centerline{\textbf{Dense Subset}}\par\vspace*{\fill}}}
154 %     \fbox{\parbox[t][1in][c]{2in}{%
155 %       \footnotesize\vspace*{\fill}\par\begin{center}%
156 %       A subset $S$ of a normed space $B$ is called \emph{dense}
157 %       in $B$ if {\rm cl} $S$ = $B$.\end{center}\par\vspace*{\fill}}}
158 %   \end{center}
159 %   This is not the end of the story, however, there are several
160 %   styles to choose from and an optional argument to the |flashcard|
161 %   environment.  These will be descibed next.
162 %
163 % \subsection{Styles}
164 %   By default, \flashcards\ uses the |plain| style for both the front
165 %   and back of the flash card.  The |plain| style centers the contents
166 %   horizontally and vertically.  The front contents are also set in
167 %   in large bold face, but this can be changed while setting the
168 %   style as described below.
169 %
170 %   \DescribeMacro{\cardfrontstyle}
171 %   The style of the front of the card can be conveniently selected
172 %   with the |\cardfrontstyle{|\textit{style}|}| command, where
173 %   \textit{style} can be one of |empty|, |plain|, or |headings|.
174 %   The |plain| style has already been described.  The |empty|
175 %   style does not center the contents horizontally nor vertically,
176 %   allowing for more generic usage. The |headings| style allows you to
177 %   set a running footer with
178 %   \DescribeMacro{\cardfrontfoot}
179 %   the |\cardfrontfoot{|\textit{text}|}| command, as well
180 %   as set a header for each card with an optional argument to
181 %   the |flashcard| environment.  For example,
182 %   \begin{verbatim}
183 %     \cardfrontstyle{headings}
184 %     \cardfrontfoot{Functional Analysis}
185 %     \begin{flashcard}[Definition]{Dense Subset}
186 %       A subset $S$ of a normed space $B$ is called \emph{dense}
187 %       in $B$ if {\rm cl} $S$ = $B$.
188 %     \end{flashcard}
189 %   \end{verbatim}
190 %   will produce the front-back pair:
191 %   \begin{center}
192 %     \fbox{\parbox[t][1in][c]{2in}{%
193 %       \footnotesize\textsc{Definition}\par\vspace*{\fill}\par
194 %       \centerline{\textbf{Dense Subset}}\par\vspace*{\fill}\par
195 %       \hspace*{\fill}\textsc{Functional Analysis}}}
196 %     \fbox{\parbox[t][1in][c]{2in}{%
197 %       \footnotesize\vspace*{\fill}\par\begin{center}%
198 %       A subset $S$ of a normed space $B$ is called \emph{dense}
199 %       in $B$ if {\rm cl} $S$ = $B$.\end{center}\par\vspace*{\fill}}}
200 %   \end{center}
201 %
202 %   You can also change the default formatting of the contents of the
203 %   front of the card by including the new formatting commands as an
204 %   optional argument to |\cardfrontstyle|.  For example, to set the
205 %   overall style to be |plain| (thus centering the contents of the
206 %   front of the card), as well as set the contents in a large
207 %   slanted face, you could issue the command:
208 %   \begin{center}
209 %     |\cardfrontstyle[\LARGE\slshape]{plain}|
210 %   \end{center}
211 %
212 %   \DescribeMacro{\cardbackstyle}
213 %   The style of the back of the card can be conveniently selected
214 %   with the |\cardbackstyle{|\textit{style}|}| command, where
215 %   \textit{style} can either be |empty| or |plain|. The |plain| style
216 %   has already been described.  The |empty| style does not center the
217 %   contents horizontally nor vertically, allowing for more generic
218 %   usage.
219 %
220 %   The default formatting can also be changed through an optional
221 %   argument in the same manner as for the front of the card.
222 %
223 % \subsubsection{Headings Styles}
224 %   \DescribeMacro{\cardfrontheadstyle}
225 %   The header and footer provided for the front of the card by the
226 %   |headings| style can be customized through two style commands.
227 %   \DescribeMacro{\cardfrontfootstyle}
228 %   The available styles for the header and footer are |left|,
229 %   |center| and |right|, which will place the contents of the
230 %   header or footer as advertized.  By default the header will be
231 %   |left| justified and the footer will be |right| justified.
232 %
233 %   Here as well, you can provide an optional argument to specify
234 %   the formatting of the header and footer, for example to have
235 %   the footer centered and set in a small italic face:
236 %   \begin{center}
237 %     |\cardfrontfootstyle[\small\itshape]{center}|
238 %   \end{center}
239 %
240 % \subsection{Lengths}
241 %   \flashcards\ has one length (in addition to the those discussed in
242 %   paper configuration below) which allows you to set the size of the
243 %   uniform margin around the contents of both the front and back of
244 %   the card.  For example, to set that uniform margin at $1/4''$, you
245 %   can do the following:
246 %   \begin{center}
247 %      |\setlength{\cardmargin}{0.25in}|
248 %   \end{center}
249 %
250 %
251 % \section{Sample Document}
252 %
253 %    \begin{macrocode}
254 %<*sample>
255 \documentclass[avery5388,grid,frame]{flashcards}
256
257 \cardfrontstyle[\large\slshape]{headings}
258 \cardbackstyle{empty}
259
260 \begin{document}
261
262 \cardfrontfoot{Functional Analysis}
263
264
265 \begin{flashcard}[Definition]{Norm on a Linear Space \\ Normed Space}
266
267   A real-valued function $||x||$ defined on a linear space $X$, where
268   $x \in X$, is said to be a \emph{norm on} $X$ if
269
270   \smallskip
271
272   \begin{description}
273     \item [Positivity]            $||x|| \geq 0$,
274     \item [Triangle Inequality]   $||x+y|| \leq ||x|| + ||y||$,
275     \item [Homogeneity]           $||\alpha x|| = |\alpha| \:  ||x||$,
276                                   $\alpha$ an arbitrary scalar,
277     \item [Positive Definiteness] $||x|| = 0$ if and only if $x=0$,
278   \end{description}
279
280   \smallskip
281
282   where $x$ and $y$ are arbitrary points in $X$.
283
284   \medskip
285
286   A linear/vector space with a norm is called a \emph{normed space}.
287 \end{flashcard}
288
289
290 \begin{flashcard}[Definition]{Inner Product}
291
292   Let $X$ be a complex linear space. An \emph{inner product} on $X$ is
293   a mapping that associates to each pair of vectors $x$, $y$ a scalar,
294   denoted $(x,y)$, that satisfies the following properties:
295
296   \medskip
297
298   \begin{description}
299     \item [Additivity]            $(x+y,z) = (x,z) + (y,z)$,
300     \item [Homogeneity]           $(\alpha \: x, y) = \alpha (x,y)$,
301     \item [Symmetry]              $(x,y) = \overline{(y,x)}$,
302     \item [Positive Definiteness] $(x,x) > 0$, when $x\neq0$.
303   \end{description}
304 \end{flashcard}
305
306
307 \begin{flashcard}[Definition]{Linear Transformation/Operator}
308
309   A transformation $L$ of (operator on) a linear space $X$ into a linear
310   space $Y$, where $X$ and $Y$ have the same scalar field, is said to be
311   a \emph{linear transformation (operator)} if
312
313   \medskip
314
315   \begin{enumerate}
316     \item $L(\alpha x) = \alpha L(x), \forall x\in X$ and $\forall$
317           scalars $\alpha$, and
318     \item $L(x_1 + x_2) = L(x_1) + L(x_2)$ for all $x_1,x_2 \in X$.
319   \end{enumerate}
320
321 \end{flashcard}
322
323
324 \end{document}
325 %</sample>
326 %    \end{macrocode}
327 %
328 % \section{Paper Configuration}
329 %   \label{sec:paperconfig}
330 %
331 %   A separate configuration file specifies the details of each
332 %   paper type.  You should be able to create a new configuration
333 %   file from the information the paper manufacturer provides
334 %   with the product.  Again, in order for this to work properly,
335 %   you must accurately configure your printer.  I recommend
336 %   using |testpage.tex| and reading the |dvips| (or similar)
337 %   documentation (|info dvips| on a typical \textsc{Linux}
338 %   installation).  Also, on my setup I have experienced variation
339 %   between portrait and landscape oriented papers.
340 %
341 %   There are seven parameters which must be set. The names should be
342 %   somewhat self explanatory.  I recommend making a copy of one of the
343 %   existing configuration files and modifying the copy as
344 %   necessary.
345 %
346 %   For example, a $5 \times 2$ business card stock that I have been
347 %   using has a $0.75''$ left and right margins and a $0.50''$ top margin
348 %   which offset an array of $2''$ high and $3.5''$ wide business cards
349 %   arranged in $5$ vertical rows and $2$ horizontal columns.  I use
350 %   the following configuration file:
351 %   \begin{verbatim}
352 %     \newcommand{\cardpaper}{letterpaper}
353 %     \newcommand{\cardpapermode}{portrait}
354 %     \newcommand{\cardrows}{5}
355 %     \newcommand{\cardcolumns}{2}
356 %     \setlength{\cardheight}{2.0in}
357 %     \setlength{\cardwidth}{3.5in}
358 %     \setlength{\topoffset}{0.50in}
359 %     \setlength{\oddoffset}{0.75in}
360 %     \setlength{\evenoffset}{0.75in}
361 %   \end{verbatim}
362 %   All four commands must be defined and all five lengths must be
363 %   specified.  If the array of cards is not centered left-to-right
364 %   on the paper, you should set |\oddoffset| to the left margin of
365 %   the front and |\evenoffset| to the right margin of the front.
366 %
367 %
368 % \StopEventually{}
369 %
370 % \section{Class Source}
371 %    The \LaTeXe\ source code follows. The flash cards are built up
372 %    in an array of save boxes which are flushed at the end of each
373 %    page and at the end of the document.
374 %
375 % \subsection*{Declare Booleans and Set Defaults}
376 %
377 %    \begin{macrocode}
378 %<*flashcards>
379 \newboolean{flashcards@dvips}\setboolean{flashcards@dvips}{false}
380 \newboolean{flashcards@grid}\setboolean{flashcards@grid}{false}
381 \newboolean{flashcards@frame}\setboolean{flashcards@frame}{false}
382 \newboolean{flashcards@fronts}\setboolean{flashcards@fronts}{true}
383 \newboolean{flashcards@backs}\setboolean{flashcards@backs}{true}
384 %    \end{macrocode}
385 %
386 % \subsection*{Declare Lengths}
387 %
388 %    \begin{macrocode}
389 \newlength{\cardheight}
390 \newlength{\cardwidth}
391 \newlength{\topoffset}
392 \newlength{\oddoffset}
393 \newlength{\evenoffset}
394 \newlength{\oddevenshift}
395 %
396 \newlength{\cardmargin}
397 \newlength{\cardinnerheight}
398 \newlength{\cardinnerwidth}
399 %    \end{macrocode}
400 %
401 % \subsection*{Declare and Process Options}
402 %
403 %    \begin{macrocode}
404 \DeclareOption{dvips}{
405   \setboolean{flashcards@dvips}{true}}
406 \DeclareOption{grid}{
407   \setboolean{flashcards@grid}{true}}
408 \DeclareOption{frame}{
409   \setboolean{flashcards@frame}{true}}
410 \DeclareOption{fronts}{
411   \setboolean{flashcards@backs}{false}}
412 \DeclareOption{backs}{
413   \setboolean{flashcards@fronts}{false}}
414 \DeclareOption*{
415   \InputIfFileExists{\CurrentOption.cfg}{}{
416     \typeout{Coudln't find \CurrentOption.cfg, using defualt.}
417     \OptionNotUsed}}
418 \ProcessOptions
419 \pagestyle{empty}
420 %<flashcards>\RequirePackage[\cardpaper]{geometry}
421 %    \end{macrocode}
422 %
423 % \subsection*{Setup Paper}
424 %
425 %    \begin{macrocode}
426 \setlength{\oddevenshift}{\oddoffset}
427 \addtolength{\oddevenshift}{-\evenoffset}
428 \addtolength{\oddoffset}{-\oddevenshift}
429 \addtolength{\evenoffset}{\oddevenshift}
430 \geometry{\cardpapermode,
431           \cardpaper,
432           top=\topoffset,
433           left=\oddoffset,
434           right=\evenoffset,
435           bottom=0.0in,
436           noheadfoot}
437 \ifthenelse{\boolean{flashcards@dvips}}{\geometry{dvips}}{}
438 %    \end{macrocode}
439 %
440 % \subsection*{Create Row/Column Counters}
441 %
442 %    \begin{macrocode}
443 \newcounter{flashcards@row}
444 \newcounter{flashcards@col}[flashcards@row]
445 %    \end{macrocode}
446 %
447 % \subsection*{Create Frame and Grid Commands}
448 %
449 %    \begin{macrocode}
450 \ifthenelse{\boolean{flashcards@grid}}
451  {\newcommand{\flashcards@gridbox}[1]{%
452               \setlength{\fboxsep}{0in}\fbox{#1}}
453   \addtolength{\cardwidth}{-2\fboxrule}
454   \addtolength{\cardheight}{-2\fboxrule}}
455  {\newcommand{\flashcards@gridbox}[1]{#1}}
456 %
457 \ifthenelse{\boolean{flashcards@frame}}
458  {\newcommand{\flashcards@beginframebox}{%
459     \begin{tabular}{|@{\hspace*{\fboxsep}}c@{\hspace*{\fboxsep}}|}%
460       \hline}%
461   \newcommand{\flashcards@endframebox}{\\ \hline
462     \end{tabular}}}
463  {\newcommand{\flashcards@beginframebox}{}%
464   \newcommand{\flashcards@endframebox}{}}
465 %    \end{macrocode}
466 %
467 % \subsection*{Create Save Boxes}
468 %
469 %    \begin{macrocode}
470 \whiledo{\value{flashcards@row} < \cardrows}{%
471   \stepcounter{flashcards@row}%
472   \whiledo{\value{flashcards@col} < \cardcolumns}{%
473     \stepcounter{flashcards@col}%
474     \expandafter\newsavebox
475       \csname flashcardFrontR\roman{flashcards@row}%
476               C\roman{flashcards@col}\endcsname%
477       \global\expandafter\setbox%
478         \csname flashcardFrontR\roman{flashcards@row}%
479                 C\roman{flashcards@col}\endcsname%
480         \hbox{\flashcards@gridbox{%
481           \parbox[t][\cardheight]
482                  [c]{\cardwidth}%
483                  {\rule{\cardwidth}{0pt}%
484                   \rule{0pt}{\cardheight}}}}%
485     \expandafter\newsavebox
486       \csname flashcardBackR\roman{flashcards@row}%
487               C\roman{flashcards@col}\endcsname%
488       \global\expandafter\setbox%
489         \csname flashcardBackR\roman{flashcards@row}%
490                 C\roman{flashcards@col}\endcsname%
491         \hbox{\flashcards@gridbox{%
492           \parbox[t][\cardheight]
493                  [c]{\cardwidth}%
494                  {\rule{\cardwidth}{0pt}%
495                   \rule{0pt}{\cardheight}}}}%
496   }
497 }
498 %    \end{macrocode}
499 %
500 % \subsection*{Initialize Row/Column Counters}
501 %
502 %    \begin{macrocode}
503 \setcounter{flashcards@row}{1}
504 \setcounter{flashcards@col}{1}
505 %    \end{macrocode}
506 %
507 % \subsection*{Internal Formatting Commands}
508 %
509 %    \begin{macrocode}
510 \newcommand{\flashcards@frontfoot}{}
511 %
512 \newcommand{\flashcards@ps@front@empty}[3]{\@gobble{#1}\@gobble{#2}%
513   \flashcards@format@front#3}
514 \newcommand{\flashcards@ps@front@plain}[3]{\@gobble{#1}\@gobble{#2}%
515   \vspace*{\fill}\par%
516   \begin{center}\flashcards@format@front#3\end{center}%
517   \par\vspace*{\fill}}
518 \newcommand{\flashcards@ps@front@headings}[3]{%
519   {\flashcards@ps@front@head{\flashcards@format@front@head#2}}\par%
520   \vspace*{\fill}\begin{center}\flashcards@format@front#3\end{center}%
521   \vspace*{\fill}%
522   {\flashcards@ps@front@foot{\flashcards@format@front@foot#1}\par%
523   \vspace*{\fboxsep}}%
524 }
525 %
526 \newcommand{\flashcards@ps@back@begin@empty}{\flashcards@format@back}
527 \newcommand{\flashcards@ps@back@end@empty}{}
528 \newcommand{\flashcards@ps@back@begin@plain}
529   {\vspace*{\fill}\center\flashcards@format@back}
530 \newcommand{\flashcards@ps@back@end@plain}{\vspace*{\fill}}
531 %
532 \newcommand{\flashcards@ps@front@head@left}[1]{#1}
533 \newcommand{\flashcards@ps@front@head@right}[1]{\hspace*{\fill}#1}
534 \newcommand{\flashcards@ps@front@head@center}[1]{\centerline{#1}}
535 %
536 \newcommand{\flashcards@ps@front@foot@left}[1]{#1}
537 \newcommand{\flashcards@ps@front@foot@right}[1]{\hspace*{\fill}#1}
538 \newcommand{\flashcards@ps@front@foot@center}[1]{\centerline{#1}}
539 %
540 \newcommand{\flashcards@ps@front}
541   {\flashcards@ps@front@plain}
542 \newcommand{\flashcards@ps@front@head}
543   {\flashcards@ps@front@head@left}
544 \newcommand{\flashcards@ps@front@foot}
545   {\flashcards@ps@front@foot@right}
546 \newcommand{\flashcards@ps@back@begin}
547   {\flashcards@ps@back@begin@plain}
548 \newcommand{\flashcards@ps@back@end}
549   {\flashcards@ps@back@end@plain}
550 %
551 \newlength{\flashcards@savelineskip}
552 \newcommand{\flashcards@lineskip@zero}
553   {\setlength{\flashcards@savelineskip}{\lineskip}%
554    \setlength{\lineskip}{0pt}}
555 \newcommand{\flashcards@lineskip@restore}
556   {\setlength{\lineskip}{\flashcards@savelineskip}}
557 %
558 \newcommand{\flashcards@format@front}
559   {\large\bfseries}
560 \newcommand{\flashcards@format@front@head}
561   {\normalsize\scshape}
562 \newcommand{\flashcards@format@front@foot}
563   {\normalsize\scshape}
564 \newcommand{\flashcards@format@back}{}
565 %
566 \setlength{\cardmargin}{0.035\cardwidth}
567 %    \end{macrocode}
568 %
569 % \subsection*{Internal Flushing Commands}
570 %
571 %    \begin{macrocode}
572 \newcommand{\flashcards@flush}
573   {\flashcards@flushfronts\flashcards@flushbacks}
574 %
575 \ifthenelse{\boolean{flashcards@fronts}}{%
576   \newcommand{\flashcards@flushfronts}{%
577     \flashcards@lineskip@zero%
578     \noindent\raggedright\par%
579     \setcounter{flashcards@row}{0}
580     \whiledo{\value{flashcards@row} < \cardrows}{%
581       \stepcounter{flashcards@row}%
582       \whiledo{\value{flashcards@col} < \cardcolumns}{%
583         \stepcounter{flashcards@col}%
584         \flashcards@gridbox{\usebox{%
585           \csname flashcardFrontR\roman{flashcards@row}%
586                   C\roman{flashcards@col}\endcsname}}%
587         \global\expandafter\setbox%
588           \csname flashcardFrontR\roman{flashcards@row}%
589                   C\roman{flashcards@col}\endcsname%
590           \hbox{\flashcards@gridbox{%
591             \parbox[t][\cardheight]
592                    [c]{\cardwidth}%
593                    {\rule{\cardwidth}{0pt}%
594                     \rule{0pt}{\cardheight}}}}%
595       }
596       \noindent\raggedright\par%
597     }
598     \clearpage%
599     \flashcards@lineskip@restore%
600     \setcounter{flashcards@row}{1}%
601     \setcounter{flashcards@col}{1}%
602   }
603 }{%
604   \newcommand{\flashcards@flushfronts}{}%
605 }
606 %
607 \ifthenelse{\boolean{flashcards@backs}}{%
608   \newcommand{\flashcards@flushbacks}{%
609     \flashcards@lineskip@zero%
610     \noindent\raggedright\par%
611     \setcounter{flashcards@row}{0}
612     \whiledo{\value{flashcards@row} < \cardrows}{%
613       \stepcounter{flashcards@row}%
614       \setcounter{flashcards@col}{\cardcolumns}
615       \whiledo{\value{flashcards@col} > 0}{%
616         \flashcards@gridbox{\usebox{%
617           \csname flashcardBackR\roman{flashcards@row}%
618                   C\roman{flashcards@col}\endcsname}}%
619         \global\expandafter\setbox
620           \csname flashcardBackR\roman{flashcards@row}%
621                   C\roman{flashcards@col}\endcsname%
622         \hbox{\flashcards@gridbox{%
623           \parbox[t][\cardheight]
624                  [c]{\cardwidth}%
625                  {\rule{\cardwidth}{0pt}%
626                   \rule{0pt}{\cardheight}}}}%
627         \addtocounter{flashcards@col}{-1}%
628       }
629       \noindent\raggedright\par%
630     }
631     \clearpage%
632     \flashcards@lineskip@restore%
633     \setcounter{flashcards@row}{1}%
634     \setcounter{flashcards@col}{1}%
635   }
636 }{%
637   \newcommand{\flashcards@flushbacks}{}%
638 }
639 %
640 \AtEndDocument{%
641   \ifthenelse{\value{flashcards@row} = 1}{%
642     \ifthenelse{\value{flashcards@col} = 1}{}{%
643   \flashcards@flush}}{\flashcards@flush}%
644 }
645 %    \end{macrocode}
646 %
647 % \subsection*{User Commands and Environments}
648 %
649 %    \begin{macrocode}
650 %
651 \newcommand{\cardfrontstyle}[2][]
652   {\renewcommand{\flashcards@ps@front}
653                 {\csname flashcards@ps@front@#2\endcsname}
654    \ifthenelse{\equal{#1}{}}{}{%
655      \renewcommand{\flashcards@format@front}{#1}}}
656 %
657 \newcommand{\cardbackstyle}[2][]
658   {\renewcommand{\flashcards@ps@back@begin}
659                 {\csname flashcards@ps@back@begin@#2\endcsname}
660    \renewcommand{\flashcards@ps@back@end}
661                 {\csname flashcards@ps@back@end@#2\endcsname}
662    \ifthenelse{\equal{#1}{}}{}{%
663      \renewcommand{\flashcards@format@back}{#1}}}
664 %
665 \newcommand{\cardfrontheadstyle}[2][]
666   {\renewcommand{\flashcards@ps@front@head}
667                 {\csname flashcards@ps@front@head@#2\endcsname}
668    \ifthenelse{\equal{#1}{}}{}{%
669      \renewcommand{\flashcards@format@front@head}{#1}}}
670 %
671 \newcommand{\cardfrontfootstyle}[2][]
672   {\renewcommand{\flashcards@ps@front@foot}
673                 {\csname flashcards@ps@front@foot@#2\endcsname}
674    \ifthenelse{\equal{#1}{}}{}{%
675      \renewcommand{\flashcards@format@front@foot}{#1}}}
676 %
677 \newcommand{\cardfrontfoot}[1]
678   {\renewcommand{\flashcards@frontfoot}{#1}}
679 %
680 \newenvironment{flashcard}[2][]{%
681   \setlength{\cardinnerwidth}{\cardwidth}%
682   \addtolength{\cardinnerwidth}{-2\cardmargin}%
683   \setlength{\cardinnerheight}{\cardheight}%
684   \addtolength{\cardinnerheight}{-2\cardmargin}%
685   \ifthenelse{\boolean{flashcards@fronts}}{%
686     \global\expandafter\setbox%
687       \csname flashcardFrontR\roman{flashcards@row}%
688               C\roman{flashcards@col}\endcsname%
689       \hbox{\begingroup\aftergroup}%
690         \begin{minipage}[t][\cardheight]
691                         [c]{\cardwidth}%
692           \begin{center}%
693             \flashcards@beginframebox%
694               \begin{minipage}[t][\cardinnerheight]
695                               [t]{\cardinnerwidth}%
696                 \flashcards@ps@front{\flashcards@frontfoot}{#1}{#2}%
697               \end{minipage}%
698             \flashcards@endframebox%
699           \end{center}%
700         \end{minipage}%
701       \endgroup%
702   }{\@gobble{#1}}%
703   \global\expandafter\setbox%
704     \csname flashcardBackR\roman{flashcards@row}%
705             C\roman{flashcards@col}\endcsname%
706     \hbox{\begingroup\aftergroup}%
707       \begin{minipage}[t][\cardheight]
708                       [c]{\cardwidth}%
709         \begin{center}%
710           \flashcards@beginframebox%
711             \begin{minipage}[t][\cardinnerheight]
712                             [t]{\cardinnerwidth}%
713                \flashcards@ps@back@begin%
714 }{%
715                \flashcards@ps@back@end%
716             \end{minipage}%
717           \flashcards@endframebox%
718         \end{center}%
719       \end{minipage}%
720     \endgroup%
721   \stepcounter{flashcards@col}%
722   \ifthenelse{\value{flashcards@col} > \cardcolumns}{%
723     \stepcounter{flashcards@row}%
724     \ifthenelse{\value{flashcards@row} > \cardrows}{%
725       \flashcards@flush%
726     }{%
727       \setcounter{flashcards@col}{1}%
728     }%
729   }{}%
730 }
731 %</flashcards>
732 %    \end{macrocode}
733 %
734 % \section*{Paper Types}
735 %   A separate configuration file specifies the details of each
736 %   paper type.
737 %
738 % \subsection*{Avery5371 Business Cards}
739 %   The $5 \times 2$ business card stock I have been using.  It goes
740 %   by many other names as well, depending on color and quantity.
741 %
742 %    \begin{macrocode}
743 %<*avery5371>
744 \newcommand{\cardpapermode}{portrait}
745 \newcommand{\cardpaper}{letterpaper}
746 \newcommand{\cardrows}{5}
747 \newcommand{\cardcolumns}{2}
748 \setlength{\cardheight}{2.0in}
749 \setlength{\cardwidth}{3.5in}
750 \setlength{\topoffset}{0.50in}
751 \setlength{\oddoffset}{0.75in}
752 \setlength{\evenoffset}{0.75in}
753 %</avery5371>
754 %    \end{macrocode}
755 %
756 % \subsection*{Avery5388 Index Cards}
757 %   Perforated index card stock.
758 %
759 %    \begin{macrocode}
760 %<*avery5388>
761 \newcommand{\cardpapermode}{portrait}
762 \newcommand{\cardpaper}{letterpaper}
763 \newcommand{\cardrows}{3}
764 \newcommand{\cardcolumns}{1}
765 \setlength{\cardheight}{3.0in}
766 \setlength{\cardwidth}{5.0in}
767 \setlength{\topoffset}{1.0in}
768 \setlength{\oddoffset}{1.75in}
769 \setlength{\evenoffset}{1.75in}
770 %</avery5388>
771 %    \end{macrocode}
772 %
773
774 \endinput
775
776 % \Finale