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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
% \iffalse
%%
%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley
%% All rights reserved.
%%
%% Not for general distribution. In its present form it is not allowed
%% to put this package onto CD or an archive without consulting the
%% the authors.
%%
% \fi
%
% \begin{macrocode}
\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${
\ProvidesPackage{#2}[#4 #3 #5 #6]}
\@tempa$Id: xo-capt.dtx,v 1.13 2000/08/11 07:14:03 latex3 Exp $
% \end{macrocode}
%
% Ignore white space in this package.
% \begin{macrocode}
\IgnoreWhiteSpace
% \end{macrocode}
%
%
% \subsection{Modifying the caption command}
%
% \begin{macro}{\@caption}
% |\caption| just saves its main argument in a token register. It also
% has |\unskip| and |\ignorespaces| to cope with hmode.
% The format of the token register is:\\
% \marg{type}\marg{number}\marg{caption text}\marg{extra info}\\
% The \meta{type} is something like `figure', used to generate the
% relevant command names. \meta{number} is the fully expanded version of
% |\the|\ldots. The last group is unused by the current definition
% but extended packages may use it to pass extra information to the
% float handler, as required.
% \begin{macrocode}
\def\caption{\@dblarg{\@caption\float@type}}
\long\def\@caption#1[#2]#3{%
\unskip
% \end{macrocode}
% We use the old \LaTeX{} interface with |\addcontentsline| for the
% moment.\footnote{FIX!!}
% \begin{macrocode}
\addcontentsline{\csname toc@extension@#1\endcsname}{#1}
% \end{macrocode}
% The counter used is not |#1| but given by (|\foat@counter|) which
% should perhaps be passed along but isn't:
% \begin{macrocode}
{\protect\numberline{\csname the\float@counter\endcsname}
{\ignorespaces #2}}
\global\toks\@currbox{#3}
\ignorespaces
}
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Adding captions to float boxes}
%
% This should really be a template instance.
% Must \emph{copy} the float body in |\this@float@box|
% into |\this@captioned@float| adding the caption text.
% May use |\this@area|, |\this@area@col@number| and other information, to be
% determined \ldots
%
% \begin{macro}{\append@caption@to@float}
% Combine float body and caption of the current float (``this
% float'') and store it in |\this@captioned@float|.
% \begin{macrocode}
\def\append@caption@to@float{
\typeset@some@floatbox
\this@type\this@area
\this@float@box{\csname caption@\this@type\endcsname}
\this@usercnt\this@caption\this@span@number
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\append@here@caption@to@float}
% Combine float body and caption of the current here float and
% store it in |\this@captioned@float|.
% \begin{macrocode}
\def\append@here@caption@to@float{
\typeset@some@floatbox
\here@type{h\the\curr@col@count 1}
\here@float@box{\csname caption@\here@type\endcsname}
\here@usercnt\here@caption\here@span@number
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\typeset@this@float@and@caption}
% Combine float body and caption of the current float (``this
% float'') and output it into the current list.
% \begin{macrocode}
\def\typeset@this@float@and@caption{
\append@caption@to@float
\box\this@captioned@float
}
% \end{macrocode}
% \end{macro}
%
%
%
% \section{Some primitive templates for testing}
%
% prove of concept only --- not even prototype
%
%
% \begin{macro}{\typeset@some@floatbox}
% The macro |\typeset@some@floatbox| take 7 arguments as follows:
% \begin{description}
% \item[type] type of the float to be typeset
% \item[area] area in which to format the float
% \item[floatbody box] box register in which the body of the float
% is stored
% \item[caption heading] fixed text like ``Figure''
% \item[caption number] caption number of the float
% \item[caption text] caption text of the float
% \item[span count] span count (normally deducable from the area
% but\ldots
% \end{description}
% The first two arguments are used to decide which formatting
% instance to call, the remaining arguments are passed to that
% instance.
%
% The logic is (at the moment) as follows: if a template instance
% (type \texttt{buildfloat}) with the name
% \meta{type}|-|\meta{area}\footnote{The ``here'' areas are
% denoted as \texttt{h}\meta{col}\texttt{1}.}
% is defined then this instance is used,
% otherwise we look if there is an instance with just the name of
% the \meta{area}, otherwise we try an instance with the name
% \meta{type} and if this isn't defined either we try the instance
% named |default|.
% \begin{macrocode}
\def\typeset@some@floatbox#1#2{ % type area
\IfExistsInstanceTF{buildfloat}
{ #1 - #2 }
{\def\use@instance@named{#1 - #2}}
{
\IfExistsInstanceTF{buildfloat}
{ #2 }
{\def\use@instance@named{#2}}
{
\IfExistsInstanceTF{buildfloat}
{ #1 }
{\let\use@instance@named#1 } % we know this is a token
{\def\use@instance@named{default}}
}
}
\UseInstance{buildfloat}\use@instance@named
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macrocode}
% #1 body box
% #2 fixed text
% #3 counter value
% #4 caption
% #5 span number
\DeclareTemplateType{buildfloat}{5}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareTemplate{buildfloat}{centeredabove}{5}
{
body-caption-sep =l [10pt] \belowcaptionskip,
}
{
\DoParameterAssignments
\@parboxrestore
\hsize=#5\columnwidth
\global\setbox\this@captioned@float\vbox{
\sbox\@tempboxb{#2~ #3:~ #4}
\ifdim \wd\@tempboxb >\hsize
#2~ #3:~ #4\par
\else
\hb@xt@\hsize{\hfil\box\@tempboxb\hfil}%
\fi
\vskip\belowcaptionskip
\centerline{
\copy#1
}
\kern\z@
}
}
% \end{macrocode}
%
% \begin{macrocode}
\newbox\@tempboxb
% \end{macrocode}
%
% \begin{macrocode}
\DeclareTemplate{buildfloat}{centeredbelow}{5}
{
body-caption-sep =l [10pt] \abovecaptionskip,
}
{
\DoParameterAssignments
\@parboxrestore
\hsize=#5\columnwidth
\global\setbox\this@captioned@float\vbox{
\centerline{\copy#1}
\vskip\abovecaptionskip
\sbox\@tempboxb{#2~ #3:~ #4}
\ifdim \wd\@tempboxb >\hsize
#2~ #3:~ #4\par
\else
\hb@xt@\hsize{\hfil\box\@tempboxb\hfil}%
\fi
}
}
% \end{macrocode}
%
% \begin{macrocode}
\DeclareTemplate{buildfloat}{bottomright}{5}
{
body-caption-sep =l [10pt] \abovecaptionskip,
}
{
\DoParameterAssignments
\@parboxrestore
\hsize=#5\columnwidth
\global\setbox\this@captioned@float\vbox{
\@@line{\hss\vbox{\copy#1\kern0pt}
\rlap{
\hskip\abovecaptionskip
% \end{macrocode}
% rubbish as far as it goes: this should be turned into a real
% template probably using coffins
% \begin{macrocode}
\parbox[b]{\marginparwidth
+(#5\columnwidth-\wd#1)/2}{
\raggedright
#2~ #3:~ #4
}
}\hss
}
\kern0pt
}
}
% \end{macrocode}
%
%
%
% \subsection{Some test instances}
%
% \begin{macrocode}
\DeclareInstance{buildfloat}{default}{centeredabove}{}
\DeclareInstance{buildfloat}{figure}{centeredbelow}{}
\DeclareInstance{buildfloat}{t31}{bottomright}{}
\DeclareInstance{buildfloat}{t22}{bottomright}{}
\DeclareInstance{buildfloat}{t13}{bottomright}{}
% \end{macrocode}
%
% \endinput
\endinput
%
% $Log: xo-capt.dtx,v $
% Revision 1.13 2000/08/11 07:14:03 latex3
% added header
%
% Revision 1.12 2000/08/11 06:47:53 latex3
% untabify
%
% Revision 1.11 2000/07/19 15:55:53 latex3
% used \float@type rather than \@captype
% extended buildfloat template to 5 arguments
%
% Revision 1.10 2000/07/10 18:45:23 latex3
% some normalisation of caption attachment code -- needs more work
%
% Revision 1.9 2000/06/13 20:53:55 latex3
% docu update
% renamed template type builtfloat to buildfloat
%
% Revision 1.8 2000/05/03 20:16:59 latex3
% added more arguments to the caption template
%
% Revision 1.7 2000/05/03 20:03:59 latex3
% fixed typo in macro name
%
% Revision 1.6 2000/05/03 18:52:44 latex3
% enabling write of toc entries
% adding a prove of concept for caption templates
%
|