Initial Commit
[packages] / xemacs-packages / bbdb / tex / bbdb-cols.tex
1 %%% bbdb-cols.tex  -  multiple columns per page, multiple pages per sheet.
2
3 %%% Authors: Luigi Semenzato <luigi@paris.cs.berkeley.edu>
4 %%%          Boris Goldowsky <boris@cs.rochester.edu>
5 %%% Copyright (C) 1993 Boris Goldowsky
6 %%% Version: 3.92; 5Jan95
7
8 %%% Commentary:
9 %%%
10 %%% Put  \input bbdb-cols.tex 
11 %%% at the beginning of your TeX file.
12 %%% Then \twocol, \threecol, or \fourcol for multi-column output
13 %%% or \gridformat (4x3 grid of small credit-card-sized pages)
14 %%% or \quadformat{xsize}{ysize} for four 2-column pages per sheet.
15 %%% In any case you will need to put \endcol at the end of the
16 %%% document, before \bye.
17
18 %%% For instructions on using this format file with BBDB, see bbdb-print.el
19 %%% which should have come bundled with this file.  The complete bbdb-print
20 %%% package is also available via anonymous ftp at:
21 %%% /cs.rochester.edu:/pub/u/boris/bbdb-print.tar.gz
22
23 %%% This file is part of the bbdb-print extensions to the Insidious
24 %%% Big Brother Database, which is for use with GNU Emacs.
25 %%%
26 %%% This program is free software; you can redistribute it and/or
27 %%% modify it under the terms of the GNU General Public License as
28 %%% published by the Free Software Foundation; either version 1, or
29 %%% (at your option) any later version.
30 %%%
31 %%% This program is distributed in the hope that it will be useful,
32 %%% but WITHOUT ANY WARRANTY; without even the implied warranty of
33 %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
34 %%% General Public License for more details.
35 %%%
36 %%% You should have received a copy of the GNU General Public License
37 %%% along with GNU Emacs; see the file COPYING.  If not, write to
38 %%% the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
39
40
41 \newdimen\colshsize      \colshsize=\hsize
42 \newdimen\columngutter   \columngutter=.2in     % space between columns
43
44 \newbox\columnA  \newbox\columnB  \newbox\columnC
45
46 \newdimen\FULLHSIZE
47 \newdimen\FULLVSIZE  
48 \newbox\quadrantbox
49 \newbox\firstquadrant \newbox\secondquadrant
50 \newbox\thirdquadrant \newbox\fourthquadrant
51 \newbox\row \newbox\page
52
53 \def\columnbox{\leftline{\pagebody}}
54
55 \def\colsline{\hbox to \colshsize}
56
57 \newcount\NROW \NROW=3          % for grid format. are these really variables
58 \newcount\NCOL \NCOL=4          % that can be changed?  should they be set
59                                 % from lisp?  I'm not sure.
60 \newcount\rowindex \newcount\colindex
61
62 \def\onecol  % for consistency---or maybe one could use it for switching back.
63 {
64   \output={\shipout\vbox{\makeheadline\colsline{\columnbox}\makefootline}
65             \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
66   \def\endcol{}
67 }% end onecol
68
69 \def\twocol 
70 {
71   \advance\hsize by -\columngutter
72   \divide\hsize 2
73   \let\column=A
74   \output={\if A\column
75               \global\setbox\columnA=\columnbox \global\let\column=B
76           \else
77               \shipout\vbox{\makeheadline
78                             \colsline{\box\columnA\hfil\columnbox}
79                             \makefootline}
80               \advancepageno \global\let\column=A
81           \fi
82           \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
83  
84   \def\endcol
85   {
86     \vfill\supereject\if A\column \else\null\vfill\eject\fi
87   }
88
89 } % end twocol
90
91 \def\threecol
92 {
93   \advance\hsize -\columngutter
94   \advance\hsize -\columngutter
95   \divide\hsize 3
96   \let\column=A
97   \output={\if A\column 
98                   \global\setbox\columnA=\columnbox \global\let\column=B
99           \else \if B\column
100                   \global\setbox\columnB=\columnbox \global\let\column=C
101           \else
102                 \shipout\vbox{\makeheadline
103                               \colsline{\box\columnA\hfil\box\columnB
104                                         \hfil\columnbox}
105                               \makefootline}
106                   \advancepageno \global\let\column=A
107           \fi\fi
108           \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
109
110   \def\endcol
111   {
112     \if A\column
113       \null\vfill\eject\null\vfill\eject
114     \else\if B\column
115       \null\vfill\eject
116     \fi\fi
117     \vfill\supereject
118   }
119
120 } % end threecol
121
122 \def\fourcol
123 {
124   \advance\hsize -3\columngutter
125   \divide\hsize 4
126   \let\column=A
127   \output={\if A\column
128                   \global\setbox\columnA=\columnbox \global\let\column=B
129           \else \if B\column
130                   \global\setbox\columnB=\columnbox \global\let\column=C
131           \else \if C\column
132                   \global\setbox\columnC=\columnbox \global\let\column=D
133           \else
134              \shipout\vbox 
135              { \makeheadline 
136                \colsline{\box\columnA\hfil\box\columnB\hfil
137                          \box\columnC\hfil\columnbox}
138                \makefootline}
139              \advancepageno\global\let\column=A
140           \fi\fi\fi
141           \ifnum\outputpenalty>-20000 \else\dosupereject\fi
142   }
143
144   \def\endcol
145   {
146     \vfill\supereject
147     \if A\column \else\null\vfill\eject\fi
148     \if B\column \else\null\vfill\eject\fi
149     \if C\column \else\null\vfill\eject\fi
150   }
151
152 } % end fourcol
153
154 \def\quadformat#1#2
155 {
156   \FULLHSIZE=\hsize
157   \FULLVSIZE=\vsize
158
159   \colshsize=#1
160   \vsize=#2
161
162   \hsize=\colshsize   \advance\hsize by -.15in   \divide\hsize 2
163
164   \let\lr=L 
165   \let\quadrant=A 
166   \output={\if L\lr
167                   \global\setbox\columnA=\columnbox \global\let\lr=R
168           \else
169                   \global\setbox\quadrantbox=\vbox{\colsline
170                   {\box\columnA\hfil\columnbox}} \global\let\lr=L
171                   \quadrantformat
172           \fi
173           \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
174
175   \def\quadrantformat
176           {\if A\quadrant
177                   \global\setbox\firstquadrant=\box\quadrantbox
178                   \global\let\quadrant=B
179           \else \if B\quadrant
180                   \global\setbox\secondquadrant=\box\quadrantbox
181                   \global\let\quadrant=C
182           \else \if C\quadrant
183                   \global\setbox\thirdquadrant=\box\quadrantbox
184                   \global\let\quadrant=D
185           \else
186                   {\shipout
187                   \vbox to \FULLVSIZE
188                        {\FULLLINE{\box\firstquadrant\hfil\box\secondquadrant}
189                         \vfill
190                         \FULLLINE{\box\thirdquadrant\hfil\box\quadrantbox}}}
191                   \global\let\quadrant=A
192                   \advancepageno
193           \fi\fi\fi}
194
195   \def\FULLLINE{\hbox to \FULLHSIZE}
196
197   \def\endcol{\supereject\if R\lr \null\vfill\eject\fi}
198 } % end of quadformat
199
200 \def\grid
201 {
202   \def\rowspace{\vbox to 0.2in{}}
203   \def\colspace{\hbox to 0.2in{}}
204
205   \hsize=1.5in
206   \vsize=2.9in
207
208   \rowindex=0 \colindex=0
209
210   \setbox\row=\null \setbox\page=\null
211
212   \output={\global\advance\colindex by 1
213            \ifnum\colindex>\NCOL
214                   \global\colindex=1
215                   \global\setbox\page=\vbox{\box\page\rowspace\box\row}
216                   \global\setbox\row=\null
217                   \global\advance\rowindex by 1
218                   \ifnum\rowindex=\NROW
219                           \global\rowindex=1
220                           \shipout\box\page
221                           \global\setbox\page=\null
222                           \advancepageno
223                   \fi
224           \fi
225           \global\setbox\row=\hbox{\box\row\colspace\columnbox}}
226
227   \def\columnbox{\leftline{\pagebody}}
228
229   \def\endcol{\vfill\supereject
230               \ifnum\colindex=1\null\vfill\eject\fi}
231 } % end of grid.
232
233 %%% bbdb-cols.tex ends here.
234