summaryrefslogtreecommitdiff
path: root/tex/bbdb-cols.tex
blob: b9a3d2b63f24b1d8ab0ce478508408579bf5f730 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
%%% multicol.tex  -  multiple columns per page, multiple pages per sheet.

%%% Authors: Luigi Semenzato <luigi@paris.cs.berkeley.edu>
%%%          Boris Goldowsky <boris@cs.rochester.edu>
%%% Copyright (C) 1993 Boris Goldowsky
%%% Version: 3.0; 21Mar94

%%% Commentary:
%%%
%%% Put  \input multicol.tex 
%%% at the beginning of your TeX file.
%%% Then \twocol, \threecol, or \fourcol for multi-column output
%%% or \gridformat (4x3 grid of small credit-card-sized pages)
%%% or \quadformat{xsize}{ysize} for four 2-column pages per sheet.
%%% In any case you will need to put \endcol at the end of the
%%% document, before \bye.

%%% This file is part of the bbdb-print extensions to the Insidious
%%% Big Brother Database, which is for use with GNU Emacs.
%%%
%%% The Insidious Big Brother Database is free software; you can redistribute
%%% it and/or modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 1, or (at your
%%% option) any later version.
%%%
%%% BBDB is distributed in the hope that it will be useful, but WITHOUT ANY
%%% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
%%% FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
%%% details.
%%%
%%% You should have received a copy of the GNU General Public License
%%% along with GNU Emacs; see the file COPYING.  If not, write to
%%% the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.


\newdimen\multicolhsize  \multicolhsize=\hsize
\newdimen\columngutter   \columngutter=.2in     % space between columns
\newdimen\pagegutter     \pagegutter=1in        % space between minipages

\newbox\columnA  \newbox\columnB  \newbox\columnC

\newdimen\FULLHSIZE
\newdimen\FULLVSIZE  
\newbox\quadrantbox
\newbox\firstquadrant \newbox\secondquadrant
\newbox\thirdquadrant \newbox\fourthquadrant
\newbox\row \newbox\page

\def\columnbox{\leftline{\pagebody}}

\def\multicolline{\hbox to \multicolhsize}

\newcount\NROW \NROW=3          % for grid format. are these really variables
\newcount\NCOL \NCOL=4          % that can be changed?  should they be set
                                % from lisp?
\newcount\rowindex \newcount\colindex

\def\onecol  % for consistency---or maybe one could use it for switching back.
{
  \output={\shipout\vbox{\makeheadline\multicolline{\columnbox}\makefootline}
            \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
  \def\endcol{}
}% end onecol

\def\twocol 
{
  \advance\hsize by -\columngutter
  \divide\hsize 2
  \let\column=A
  \output={\if A\column
              \global\setbox\columnA=\columnbox \global\let\column=B
          \else
              \shipout\vbox{\makeheadline
                            \multicolline{\box\columnA\hfil\columnbox}
                            \makefootline}
              \advancepageno \global\let\column=A
          \fi
          \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
 
  \def\endcol
  {
    \vfill\supereject\if A\column \else\null\vfill\eject\fi
  }

} % end twocol

\def\threecol
{
  \advance\hsize -\columngutter
  \advance\hsize -\columngutter
  \divide\hsize 3
  \let\column=A
  \output={\if A\column 
                  \global\setbox\columnA=\columnbox \global\let\column=B
          \else \if B\column
                  \global\setbox\columnB=\columnbox \global\let\column=C
          \else
                \shipout\vbox{\makeheadline
                              \multicolline{\box\columnA\hfil\box\columnB
                                            \hfil\columnbox}
                              \makefootline}
                  \advancepageno \global\let\column=A
          \fi\fi
          \ifnum\outputpenalty>-20000 \else\dosupereject\fi}

  \def\endcol
  {
    \if A\column
      \null\vfill\eject\null\vfill\eject
    \else\if B\column
      \null\vfill\eject
    \fi\fi
    \vfill\supereject
  }

} % end threecol

\def\fourcol
{
  \advance\hsize -3\columngutter
  \divide\hsize 4
  \let\column=A
  \output={\if A\column
                  \global\setbox\columnA=\columnbox \global\let\column=B
          \else \if B\column
                  \global\setbox\columnB=\columnbox \global\let\column=C
          \else \if C\column
                  \global\setbox\columnC=\columnbox \global\let\column=D
          \else
             \shipout\vbox 
             { \makeheadline 
               \multicolline{\box\columnA\hfil\box\columnB\hfil
                             \box\columnC\hfil\columnbox}
               \makefootline}
             \advancepageno\global\let\column=A
          \fi\fi\fi
          \ifnum\outputpenalty>-20000 \else\dosupereject\fi
  }

  \def\endcol
  {
    \vfill\supereject
    \if A\column \else\null\vfill\eject\fi
    \if B\column \else\null\vfill\eject\fi
    \if C\column \else\null\vfill\eject\fi
  }

} % end fourcol

\def\quadformat#1#2
{
  \hsize=#1      \advance\hsize by -.15in \divide\hsize 2
  \vsize=#2
  \multicolhsize=#1
  \FULLHSIZE=#1  \multiply\FULLHSIZE 2 \advance\FULLHSIZE by \pagegutter
  \FULLVSIZE=#2  \multiply\FULLVSIZE 2 \advance\FULLVSIZE by \pagegutter
  \let\lr=L 
  \let\quadrant=A 
  \output={\if L\lr
                  \global\setbox\columnA=\columnbox \global\let\lr=R
          \else
                  \global\setbox\quadrantbox=\vbox{\multicolline
                  {\box\columnA\hfil\columnbox}} \global\let\lr=L
                  \quadrantformat
          \fi
          \ifnum\outputpenalty>-20000 \else\dosupereject\fi}

  \def\quadrantformat
          {\if A\quadrant
                  \global\setbox\firstquadrant=\box\quadrantbox
                  \global\let\quadrant=B
          \else \if B\quadrant
                  \global\setbox\secondquadrant=\box\quadrantbox
                  \global\let\quadrant=C
          \else \if C\quadrant
                  \global\setbox\thirdquadrant=\box\quadrantbox
                  \global\let\quadrant=D
          \else
                  {\shipout
                  \vbox to \FULLVSIZE
                       {\FULLLINE{\box\firstquadrant\hfil\box\secondquadrant}
                        \vfill
                        \FULLLINE{\box\thirdquadrant\hfil\box\quadrantbox}}}
                  \global\let\quadrant=A
                  \advancepageno
          \fi\fi\fi}

  \def\FULLLINE{\hbox to \FULLHSIZE}

  \def\endcol{\supereject\if R\lr \null\vfill\eject\fi}
} % end of quadformat

\def\grid
{
  \def\rowspace{\vbox to 0.2in{}}
  \def\colspace{\hbox to 0.2in{}}

  \hsize=1.5in
  \vsize=2.9in

  \rowindex=0 \colindex=0

  \setbox\row=\null \setbox\page=\null

  \output={\global\advance\colindex by 1
           \ifnum\colindex>\NCOL
                  \global\colindex=1
                  \global\setbox\page=\vbox{\box\page\rowspace\box\row}
                  \global\setbox\row=\null
                  \global\advance\rowindex by 1
                  \ifnum\rowindex=\NROW
                          \global\rowindex=1
                          \shipout\box\page
                          \global\setbox\page=\null
                          \advancepageno
                  \fi
          \fi
          \global\setbox\row=\hbox{\box\row\colspace\columnbox}}

  \def\columnbox{\leftline{\pagebody}}

  \def\endcol{\vfill\supereject
              \ifnum\colindex=1\null\vfill\eject\fi}
} % end of grid.

%%% multicol.tex ends here.