summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ncctools/source/nccfloats.dtx
blob: bcf55b5e2e4fff3fd42a5b3aa30de136c8d3cf40 (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
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
% \iffalse
%%
%% File: nccfloats.dtx Copyright (C) 2002--2006 by Alexander I. Rozhenko
%%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{nccfloats}
%<package>         [2006/01/07 v1.2 More Float Management (NCC)]
%
% \changes{v1.00}{2002/03/23}{This version is uploaded to CTAN}
% \changes{v1.01}{2002/05/17}{Handling of side floats improved}
% \changes{v1.1}{2004/12/05}{Width parameters can have units now}
% \changes{v1.1}{2004/12/05}{Documentation was prepared}
% \changes{v1.2}{2006/01/07}{Extend |\FloatStyle| syntax}
% \changes{v1.2}{2006/01/07}{Cover base floats with |\FloatStyle|}
% \changes{v1.2}{2006/01/07}{Introduce |\newminifloat| command}
%
%<*driver>
\let\makeindex\relax
\documentclass{ltxdoc}
\usepackage{desclist,nccfloats}
\GetFileInfo{nccfloats.sty}
\begin{document}
\title{The \textsf{nccfloats} package\thanks{This file
        has version number \fileversion, last
        revised \filedate.}}
\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
\date{\filedate}
\maketitle
\DocInput{nccfloats.dtx}
\end{document}
%</driver>
% \fi
%
% The standard \LaTeX\ floating environments, namely |figure|
% and |table|, allow user to place floating material in a
% document. But they do not introduce a style in which this
% material must be formatted. In this package, styles are
% joined with floats and mini-floats are introduced. Mini-floats
% are prepared at a mini-page and allow captions within.
% Basing on mini-floats, a number of service commands for
% figures and tables are defined. The ability to create
% other types of mini-floats is introduced with the
% |\newminifloat| command.
%
% \tableofcontents
%
% \section{Basic Commands}
%
% \DescribeMacro{\FloatStyle}
% The |\FloatStyle|\oarg{type}\marg{style} command sets a style for
% the float of the given \meta{type}. If the \meta{type} is omitted,
% the default style is specified. It will be applied to a float or
% mini-float if no specialized style was defined.
% This command is available in the preamble only.
%
% To specify the style of a mini-float and of service commands based on it,
% add the `|mini|' prefix to the float type. The default styles are
% \begin{quote}
%     |\FloatStyle{}|\\
%     |\FloatStyle[minifigure]{\footnotesize\centering}|\\
%     |\FloatStyle[minitable]{\footnotesize\centering}|
% \end{quote}
% This means that the formatting of floats prepared with standard
% |figure| and |table| environments does not changed, but service
% commands based on mini-figures and mini-tables use a special
% formatting with |\footnotesize| font and the centered alignment.
%
% \DescribeMacro\normalfloatstyle
% This command is applied inside floats or mini-floats to reset
% formatting style of subsequent floating material to the standard
% formatting with paragraph alignment and the normal font of
% normal size.
%
% \DescribeMacro{\minifig}
% \DescribeMacro{\minitabl}
% We start with the basic commands, namely |\minifig| and
% |\minitabl|. They prepare a material in a mini-page and allow
% using the |\caption| command in the body. Their syntax is
% similar to the |\parbox| command:
% \begin{quote}
% |\minifig |\oarg{pos}\oarg{height}\oarg{inner-pos}\marg{width}\marg{body}\\
% |\minitabl|\oarg{pos}\oarg{height}\oarg{inner-pos}\marg{width}\marg{body}
% \end{quote}
% The \meta{pos} is a vertical alignment parameter for
% mini-page (|t|, |b|, or |c|) with respect to
% surrounding text; the \meta{height} is a mini-page height
% required; the \meta{inner-pos} is a vertical alignment
% of text inside the mini-page (|t|, |b|, |c|, or |s|);
% and the \meta{width} is the mini-page width.
% The \meta{body} is prepared in the style specified by the
% |\FloatingStyle| command and can contain the |\caption| command inside.
%
% All other floating extension commands are based on
% these two commands.
%
% \section{Side Figures and Tables}
%
% For small figures and tables, it is preferable to insert them
% inside a text instead of using floating mechanism. The
% typographic rules usually require an illustrative material to
% occupy an outer side of page. In two-side mode, this means
% figure and tables should be on the right side if a page number is
% odd and on the left side if page number is even. In one-side
% mode, figures and tables must occupy the right side of page.
%
% \DescribeMacro{\sidefig}
% \DescribeMacro{\sidetabl}
% The following commands support such a placement:
% \begin{quote}
% |\sidefig|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{figure}\marg{text}\\
% |\sidefig*|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{figure}\marg{text}\\
% |\sidetabl|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{table}\marg{text}\\
% |\sidetabl*|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{table}\marg{text}
% \end{quote}
% We use the term \textit{mini-float} for the
% small illustrating material (figure or table), however
% taking into account that it is not a float at all. It is inserted in
% the main flow next to a paragraph box specified in the last
% parameter of above described commands.
%
% The no-star forms of above described commands place a mini-float
% next to the specified text on the outer side of page (to the
% right for odd page and to the left for even page). In two-column
% or one-side mode, mini-float is always posed to the right. The
% star-forms provide the reverse placement. By default, mini-float
% is vertically centered with respect to the text and the
% |\strut| command is inserted at the beginning and at the end
% of the \meta{text} to provide normal baseline
% distances of the first and last lines of the text from
% surrounding text lines.
%
% All parameters in square and round brackets are optional and mean
% the following:
% \begin{desclist}{}{}[\meta{pos}]
% \item[\meta{pos}] specifies mini-float alignment (|t|,
% |b|, or |c|; default is |c|) with respect to text
% box and can contain additional chars controlling the text body
% preparation: |j| means the last line of the text to be
% justified to the right and |n| means suppressing of struts
% insertion (they should be inserted manually if necessary);
%
% \item[$w_1$] is the width of mini-float; and
%
% \item[$w_2$] is the width of the text box.
% \end{desclist}
%
% You can omit units in the width parameters. In this case,
% the width value is considered as a multiple of |\unitlength|
% (similarly to the use of length dimensions in the picture environment).
%
% If both width parameters are absent, the width of both mini-float and
% text body is calculated as |(\linewidth-1.5em)/2|. If $w_2$ is absent,
% the text body width is calculated as |\linewidth-|$w_1$|-1.5em|.
%
% The placement of side-floats in the document consists in the following
% steps:
% \begin{enumerate}
% \item Decide where you want to insert a side-float;
% \item Insert a |\sidefig| or |\sidetabl| command after a word that finishes
%       the line before the supposed side-float position;
% \item Specify a width of float in its parameter and set the top alignment
%       as the \meta{pos} parameter (e.g.\ |\sidefig[t](|$w_1$|)|);
% \item Prepare the side-float in the first mandatory parameter of the command
%       (e.g.\ |\sidefig[t](|$w_1$|)|\marg{figure});
% \item Enclose enough text going after the command in braces;
% \item Translate the document;
% \item Find what part of the text is redundant in the \meta{text} parameter;
% \item Move it after the close brace;
% \item If the same paragraph continues after the close brace, add the |j|
%       letter to the \meta{pos} parameter. Also change the |t| alignment
%       to |c| alignment in the \meta{pos} parameter;
% \item Translate the document once more;
% \item If the side-float has a wrong placement (this can appear when paragraph
%       with a side-float begins at the end of page), insert the star after
%       the side-float command and translate the document once more.
% \end{enumerate}
%
% \DescribeMacro{\ifleftsidefloat}
% While preparing a side-float, it is sometimes necessary to
% provide conditional placement depending on the side a mini-float
% is posed. The command
% \begin{quote}
% |\ifleftsidefloat|\marg{left-clause}\marg{right-clause}
% \end{quote}
% provides this. It is useful in parameters of |\sidefig| or
% |\sidetabl| and processes \meta{left-clause} if the
% mini-float is posed to the left and \meta{right-clause}
% otherwise.
%
% Side-floats can be also used within floating environments to pos
% a caption near a figure or table.
%
% \section{Floating Figures and Tables}
%
% \DescribeMacro{\fig}
% \DescribeMacro{\tabl}
% The following commands envelop floating
% environments:
% \begin{quote}
% |\fig|\oarg{placement}|(|$w$|)|\marg{body}\\
% |\fig*|\oarg{placement}|(|$w$|)|\marg{body}\\
% |\tabl|\oarg{placement}|(|$w$|)|\marg{body}\\
% |\tabl*|\oarg{placement}|(|$w$|)|\marg{body}
% \end{quote}
% The \meta{placement} is a float placement parameter
% describing places where a float can appear. The default value is
% |ht| (here or at the top of page).
% The optional $w$ parameter defines a
% width of box occupied by the float (the width of nested
% |\minifig| or |\minitabl|). If it
% is omitted, the float has the maximum width equal to the
% |\linewidth|.
%
% The |\fig| and |\tabl| commands envelop the |figure|
% and |table| environments respectively. Their star-forms
% envelop |figure*| or |table*| environments respectively.
%
% \section{Two Floating Figures or Tables Side by Side}
%
% \DescribeMacro{\figs}
% \DescribeMacro{\tabls}
% The following commands place two figures or tables side by side.
% \begin{quote}
% |\figs|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2}\\
% |\figs*|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2}\\
% |\tabls|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2}\\
% |\tabls*|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2}
% \end{quote}
% The \meta{body1} is a body of the left figure or table and
% the \meta{body2} is a body of the right figure or table.
% Other parameters are optional. The meaning and default value of
% the \meta{placement} parameter is the same as described
% above. The $w_1$ and $w_2$ parameters are
% widths of left and right boxes. If
% they both are omitted, the left and right boxes will have the
% width equal to |(\linewidth-1em)/2|. If $w_2$
% is omitted, the right box will occupy the rest of horizontal space
% minus |1em|. If both parameters are specified, the rest
% space is inserted between boxes. If the total width of left and
% right floats exceeds the |\linewidth|, the floats will overlap
% at the middle (a negative horizontal space is inserted between them).
%
% In the |\tabls| command, boxes of the left and right bodies are
% top-aligned, but, in the |\figs| command, the bottom alignment is
% used. The star-forms of this commands are based on the |figure*|
% or |table*| environments respectively.
%
% \section{Declare a Mini-float and Service Commands}
%
% \DescribeMacro\newminifloat
% If a new type of float is introduced, the respective mini-float
% and service commands can be helpful for it. To prepare them, use
% the following declaration:
% \begin{quote}
% |\newminifloat|\marg{gen}\marg{type}\marg{placement}\marg{pos}
% \end{quote}
% Here \meta{gen} is a root for command names to be generated, \meta{type}
% is a float type, \meta{placement} is a default placement on the page,
% and \meta{pos} is a vertical alignment for pair of floats.
%
% This command declares 4 commands: |\mini|\meta{gen}, |\side|\meta{gen},
% |\|\meta{gen}, and |\|\meta{gen}|s|. For example, the commands
% described in previous sections are declared as follows:
% \begin{quote}
% |\newminifloat{fig}{figure}{ht}{b}|\\
% |\newminifloat{tabl}{table}{ht}{t}|
% \end{quote}
%
% \StopEventually{}
%
% \section{The Implementation}
%
% The package uses some commands of the |nccboxes| package.
% Load it here:
%    \begin{macrocode}
%<*package>
\RequirePackage{nccboxes}[2002/03/20]
%    \end{macrocode}
%
% \subsection{Float Style}
%
% \begin{macro}{\FloatStyle}
% |\FloatStyle|\oarg{type}\marg{style} specifies a style for
% a given float type.
%    \begin{macrocode}
\newcommand*{\FloatStyle}[2][]{%
  \expandafter\def\csname NCC@fltstyle@#1\endcsname{#2}}
\@onlypreamble\FloatStyle
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@setfltstyle}
% |\NCC@setfltstyle|\marg{prefix} applies a style for a
% float of |\@captype| type. While selection a style to be
% applied it adds the given \meta{prefix} to the float type.
%    \begin{macrocode}
\def\NCC@setfltstyle#1{%
  \edef\@tempa{NCC@fltstyle@#1\@captype}%
  \@ifundefined{\@tempa}{\NCC@fltstyle@}{\csname\@tempa\endcsname}%
}
%    \end{macrocode}
% We add this style with empty prefix to the |\@floatboxreset|
% hook which is applied at the end of preamble of a float.
%    \begin{macrocode}
\g@addto@macro\@floatboxreset{\NCC@setfltstyle{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalfloatstyle}
% Reset a float style to par-box formatting with normal font of the
% normal size.
%    \begin{macrocode}
\newcommand\normalfloatstyle{%
  \leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip
  \parfillskip\@flushglue \let\\\@normalcr
  \reset@font \normalsize
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{The Kernel}
%
% \begin{macro}{\NCC@minifloat}
% The base for mini-floats
% \begin{quote}
% |\NCC@minifloat|\oarg{pos}\oarg{height}\oarg{inner-pos}\marg{width}\marg{body}
% \end{quote}
% It finishes a mini-float with extra |\endgroup| command.
% A |\@captype| should be specified before it.
%    \begin{macrocode}
\newcommand*\NCC@minifloat[1][c]{%
  \@ifnextchar[{\NCC@mflt{#1}}{\NCC@@mflt{#1}\relax[s]}}
\def\NCC@mflt#1[#2]{%
  \@ifnextchar[{\NCC@@mflt{#1}{#2}}{\NCC@mflt{#1}{#2}[#1]}}
\long\def\NCC@@mflt#1#2[#3]#4#5{%
  \@iiiminipage{#1}{#2}[#3]{#4}\normalfloatstyle
  \NCC@setfltstyle{mini}#5\endminipage\endgroup
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@pair}
% The command
% \begin{quote}
% |\NCC@pair|\marg{c1}\marg{c2}\marg{def-dist}\marg{def-place}|*|\oarg{place}|(|$w_1$|)(|$w_2$|)|
% \end{quote}
% executes \meta{c1}\marg{place}|{|$w_1$|}{|$w_2$|}| if star is absent or
% \meta{c2}\marg{place}|{|$w_1$|}{|$w_2$|}| if star presents.
% Four first parameters are mandatory. Others a optional.
% The \meta{def-dist} parameter contains a default distance
% value. It is saved in the |\@tempdimc| register.
% The \meta{def-place} parameter contains the default value for
% the \meta{place} parameter. If the last one is omitted,
% the \meta{def-place} is used instead.
%    \begin{macrocode}
\def\NCC@pair#1#2#3#4{\setlength\@tempdimc{#3}%
  \@ifstar{\NCC@pair@{#2}{#4}}{\NCC@pair@{#1}{#4}}}
\def\NCC@pair@#1#2{\@ifnextchar[{\NCC@pair@@{#1}}{\NCC@pair@@{#1}[#2]}}
\def\NCC@pair@@#1[#2]{\def\@tempa{#1{#2}}%
  \@ifnextchar({\NCC@pair@@@}{\NCC@@pair()()}}
\def\NCC@pair@@@(#1){\@ifnextchar({\NCC@@pair(#1)}{\NCC@@pair(#1)()}}
\def\NCC@@pair(#1)(#2){\@tempa{#1}{#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@setwidth}
% The |\NCC@setwidth|\marg{register}\marg{width} command sets
% the given \meta{width} for the \meta{register}. If units
% in \meta{width} are omitted, the |\unitlength| unit is used.
% In other words, if \meta{width} is a real number, it is considered
% as a multiple of |\unitlength|.
%    \begin{macrocode}
\def\NCC@setwidth#1#2{\@defaultunits#1#2\unitlength\relax\@nnil}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@wcalc}
% The |\NCC@wcalc{|$w_1$|}{|$w_2$|}| calculates widths
% of left and right boxes in the |\@tempdima| and |\@tempdimb|
% registers. The distance between boxes must be specified in
% |\@tempdimc| register before the call. The algorithm:
% \begin{itemize}
% \item If $w_1$ is empty, |\@tempdima:=(\linewidth-\@tempdimc)/2|,
%       otherwise, |\@tempdima:=|$w_1$;
% \item If $w_2$ is empty, |\@tempdimb:=\linewidth-\@tempdima-\@tempdimc|,
%       otherwise, |\@tempdimb:=|$w_2$;
% \item If $w_2$ is nonempty,
%       |\@tempdimc:=\linewidth-\@tempdima-\@tempdimb|.
% \end{itemize}
%    \begin{macrocode}
\def\NCC@wcalc#1#2{%
  \if!#1!\@tempdima .5\linewidth \advance\@tempdima -.5\@tempdimc
  \else  \NCC@setwidth\@tempdima{#1}%
  \fi
  \if!#2!\@tempdimb \linewidth \advance\@tempdimb -\@tempdima
         \advance\@tempdimb -\@tempdimc
  \else  \NCC@setwidth\@tempdimb{#2}%
         \@tempdimc \linewidth \advance\@tempdimc -\@tempdima
         \advance\@tempdimc -\@tempdimb
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Side Floats}
%
% \begin{macro}{\ifleftsidefloat}
% This command is used in parameters of side-floats.
%    \begin{macrocode}
\newif\ifNCC@smfltleft
\newcommand{\ifleftsidefloat}{%
  \ifNCC@smfltleft
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@sidemfloat}
% The command
% \begin{quote}
% |\NCC@sidemfloat|\marg{command}|*|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{mini-float}\marg{text}
% \end{quote}
% is used for preparing a side-float. The \meta{command} parameter
% contains a |\mini|\meta{gen} command. The \meta{pos} parameter
% specifies vertical alignment and additional flags. The
% $w_1$ and $w_2$ parameters (if present) specify widthes of
% \meta{mini-float} and \meta{text} boxes. Starred version
% reverses the position of side-float and text boxes.
% The implementation of these commands is based
% on the |\NCC@pair| command that parses all optional
% parameters. Finally the |\NCC@smflt| command is
% executed.
%    \begin{macrocode}
\def\NCC@sidemfloat#1{%
  \NCC@smfltleftfalse
  \if@twocolumn \else
    \if@twoside
      \ifodd\c@page \else \NCC@smfltlefttrue \fi
    \fi
  \fi
  \NCC@pair{\NCC@smflt{#1}}%
    {\ifNCC@smfltleft \NCC@smfltleftfalse \else \NCC@smfltlefttrue\fi
     \NCC@smflt{#1}}%
    {1.5em}{}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@smflt}
% The command
% \begin{quote}
% |\NCC@smflt|\marg{command}\marg{pos}|{|$w_1$|}{|$w_2$|}|\marg{mini-float}\marg{text}
% \end{quote}
% prepares a side-float. The |\@tempdimc| register
% contains the default distance between the mini-float and text.
%    \begin{macrocode}
\long\def\NCC@smflt#1#2#3#4#5#6{%
%    \end{macrocode}
% Parse the \meta{pos} parameter. Create a |\NCC@|\meta{letter}
% command with empty content for every \meta{letter} from the \meta{pos}.
%    \begin{macrocode}
  \let\NCC@t\relax \let\NCC@b\relax \let\NCC@j\relax \let\NCC@n\strut
  \@tfor\@tempa :=#2\do {%
    \expandafter\let\csname NCC@\@tempa\endcsname\@empty}%
%    \end{macrocode}
% Define the vertical alignment letter in the |\NCC@c| command.
%    \begin{macrocode}
  \ifx\NCC@t\@empty \def\NCC@c{t}\else
   \ifx\NCC@b\@empty \def\NCC@c{b}\else
    \def\NCC@c{c}%
   \fi
  \fi
%    \end{macrocode}
% Define a justification hook in the |\NCC@j| command.
%    \begin{macrocode}
  \ifx\NCC@j\@empty \def\NCC@j{\parfillskip\z@skip}\fi
%    \end{macrocode}
% Define the text starting hook in the |\NCC@t| command.
% It will contain the |\parindent| setting command and
% the optional |\noindent| command.
%    \begin{macrocode}
  \edef\NCC@t{\parindent\the\parindent\ifvmode\else\noindent\fi}%
%    \end{macrocode}
% Complete the current paragraph and leave the horizontal mode.
%    \begin{macrocode}
  \ifvmode\else
    \unskip{\parfillskip\rightskip\par}\vskip -\parskip
  \fi
%    \end{macrocode}
% Prepare the side-float in |\@tempboxa|:
%    \begin{macrocode}
  \setbox\@tempboxa\vbox{\hsize\linewidth\noindent
%    \end{macrocode}
% Calculate widthes of left and right boxes and distance
% between them in |\@tempdima|, |\@tempdimb|, and |\@tempdimc|.
%    \begin{macrocode}
    \NCC@wcalc{#3}{#4}%
%    \end{macrocode}
% Conditionally put a side-float to the left:
%    \begin{macrocode}
    \ifNCC@smfltleft
      \jparbox{\Strut}[\NCC@c]\@tempdima{#1\@tempdima{#5}}%
      \nobreak\hskip\@tempdimc
    \fi
%    \end{macrocode}
% Put a text box:
%    \begin{macrocode}
    \jparbox{\NCC@n\Strut}[\NCC@c]\@tempdimb{%
      \everypar{\NCC@n\everypar{}}\NCC@t#6%
      \ifvmode \else \unskip\NCC@n\NCC@j\fi}%
%    \end{macrocode}
% Conditionally put a side-float to the right:
%    \begin{macrocode}
    \ifNCC@smfltleft \else
      \nobreak\hskip\@tempdimc
      \jparbox{\Strut}[\NCC@c]\@tempdima{#1\@tempdima{#5}}%
    \fi
  }%
%    \end{macrocode}
% Games with height and depth the |\@temboxa| allow us
% produce right line spacing with surrounding text.
%    \begin{macrocode}
  \@tempdima\dp\@tempboxa \advance\@tempdima\lineskip
  \dp\@tempboxa\@tempdima
  \@tempdima\ht\@tempboxa \advance\@tempdima -\ht\strutbox
  \noindent \raise-\@tempdima\box\@tempboxa
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Service Commands}
%
% \begin{macro}{\NCC@float}
% The command
% \begin{quote}
% |\NCC@float|\marg{type}\marg{def-place}|*|\oarg{placement}|(|$w$|)|\marg{body}
% \end{quote}
% is the envelope for a mini-float inside a float. The \meta{def-place}
% is the default placement specifier.
%    \begin{macrocode}
\def\NCC@float#1#2{\@ifstar{\NCC@flt{#1*}{#2}}{\NCC@flt{#1}{#2}}}
\def\NCC@flt#1#2{\@ifnextchar[{\NCC@flt@{#1}}{\NCC@flt@{#1}[#2]}}
\def\NCC@flt@#1[#2]{\begin{#1}[#2]\normalfloatstyle\centering
 \@ifnextchar({\NCC@@flt{#1}}{\NCC@@flt{#1}()}}
\long\def\NCC@@flt#1(#2)#3{%
  \if!#2!\@tempdima\linewidth \else \NCC@setwidth\@tempdima{#2}\fi
  \begingroup\NCC@minifloat[c]\@tempdima{#3}%
  \end{#1}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@floats}
% The command
% \begin{quote}
% |\NCC@floats|\marg{type}\marg{pos}\marg{def-place}|*|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\\
% |           |\marg{body1}\marg{body2}
% \end{quote}
% is the envelope for a pair of mini-floats inside a float. The implementation
% of these commands is based
% on the |\NCC@pair| command that parses all optional
% parameters. Finally the |\NCC@flts| command is
% executed.
%    \begin{macrocode}
\def\NCC@floats#1#2#3{%
  \NCC@pair{\NCC@@flts{#1}{#2}}{\NCC@@flts{#1*}{#2}}{1em}{#3}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@flts}
% The command
% \begin{quote}
% |\NCC@flts|\marg{type}\marg{pos}\marg{placement}|{|$w_1$|}{|$w_2$|}|\marg{body1}\marg{body2}
% \end{quote}
% prepares a pair of floats within \meta{type} environment.
% The \meta{pos} contains relative vertical alignment of floats.
% The $w_1$ and $w_2$ parameters (if present) specify widthes of
% floats. The |\@tempdimc| register contains the default distance
% between floats.
%    \begin{macrocode}
\long\def\NCC@@flts#1#2#3#4#5#6#7{%
  \begin{#1}[#3]\normalfloatstyle\NCC@wcalc{#4}{#5}%
    \begingroup\NCC@minifloat[#2]\@tempdima{#6}%
    \nobreak\hskip\@tempdimc
    \begingroup\NCC@minifloat[#2]\@tempdimb{#7}%
  \end{#1}%
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Declare a New Mini-float and Service Commands}
%
% \begin{macro}{\newminifloat}
% The command
% \begin{quote}
% |\newminifloat|\marg{gen}\marg{type}\marg{def-place}\marg{pos}
% \end{quote}
% declares a new mini-float and 3 service commands.
%    \begin{macrocode}
\newcommand*\newminifloat[4]{%
  \edef\@tempa{%
%    \end{macrocode}
% Prepare |\mini|\meta{gen} definition:
%    \begin{macrocode}
    \noexpand\newcommand\expandafter\noexpand\csname mini#1\endcsname{%
      \noexpand\begingroup\noexpand\def\noexpand\@captype{#2}%
      \noexpand\NCC@minifloat}%
%    \end{macrocode}
% Prepare |\side|\meta{gen} definition:
%    \begin{macrocode}
    \noexpand\newcommand\expandafter\noexpand\csname side#1\endcsname{%
      \noexpand\NCC@sidemfloat{%
        \expandafter\noexpand\csname mini#1\endcsname}}%
%    \end{macrocode}
% Prepare |\|\meta{gen} definition:
%    \begin{macrocode}
    \noexpand\newcommand\expandafter\noexpand\csname #1\endcsname{%
      \noexpand\NCC@float{#2}{#3}}%
%    \end{macrocode}
% Prepare |\|\meta{gen}|s| definition:
%    \begin{macrocode}
    \noexpand\newcommand\expandafter\noexpand\csname #1s\endcsname{%
      \noexpand\NCC@floats{#2}{#4}{#3}}%
  }%
%    \end{macrocode}
% Define all commands:
%    \begin{macrocode}
  \@tempa
}
\@onlypreamble\newminifloat
%    \end{macrocode}
% \end{macro}
%
% \subsection{Base Mini-floats and Defaults}
%
%    \begin{macrocode}
\newminifloat{fig}{figure}{ht}{b}
\newminifloat{tabl}{table}{ht}{t}
\FloatStyle{}
\FloatStyle[minifigure]{\footnotesize\centering}
\FloatStyle[minitable]{\footnotesize\centering}
%</package>
%    \end{macrocode}
\endinput