summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/sttools/midfloat.dtx
blob: ba2f7d58721f793fa69afbd730c2dc2053aeb5b6 (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
% \iffalse meta-comment
%
% Copyright (C) 2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
% ---------------------------------------------------------------------------
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
%
% This work consists of the files midfloat.dtx and midfloat.ins
% and the derived filebase midfloat.sty.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{midfloat.dtx}
%</driver>
%<*package>
%% Copyright (C) 1997-2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
%% http://www.vtex.lt/tex/download/macros/
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% PURPOSE:   Insert some material in full-width on double-column page.
%%
%</package>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{midfloat}
%<*package>
    [2012/05/29 v1.1 Insert some material in full-width on double-column page]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{midfloat}[2012/05/29]
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{midfloat.dtx}
  \PrintChanges
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{439}
%
% \CharacterTable
%  {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
%   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
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v1.0}{1997/10/01}{some names}
% \changes{v1.1}{2012/05/29}{Converted to DTX file}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
% \providecommand*{\url}{\texttt}
% \GetFileInfo{midfloat.dtx}
% \title{The \textsf{midfloat} package}
% \author{Sigitas Tolu\v{s}is \\ \url{sigitas@vtex.lt}}
% \date{\fileversion~from \filedate}
%
% \maketitle
%
% \section{Introduction}
%
%   It is denoted to place some material (from the left column)
%   in full-width at any place (but not at the top) on double-column 
%   page (|\twocolumn| mode). Existing text remains as it was before 
%   insert. Placement is restricted to one page. (It is some kind of
%   dbfloat intext).
%
% \section{Usage}
%
% \DescribeMacro{strip}
% Provides new environment:
%
%  \begin{verbatim}
%    \begin{strip}[<top strip stretch skip>/<bottom strip skip>] 
%      <wide onecolumn material> 
%    \end{strip}
%  \end{verbatim}
%
%   Puts |\vbox|\marg{wide onecolumn material} in full-width on
%   double-column page.
%
%   \medskip
%   Adds |\stripsep| glue before and after (by default: |15pt|).
%
%   \medskip
%   It can be problems with floats and footnotes. In the case of 
%   problems with footnotes it is possible to correct the situation
%   using commands |\footnotemark| and |\footnotetext|.
%
%   \medskip
%   Parameters \meta{top strip stretch skip} and \meta{bottom strip skip} are optional. 
%   By default \meta{top strip stretch skip}|=0pt| and \meta{bottom strip skip}|=0pt|.
%   The material on the right column under strip is stretched down 
%   by \meta{top strip stretch skip} and below strip is moved down by \meta{bottom strip skip}.
%
%
% \StopEventually{}
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{midfloat}[1997/10/01]
%    \end{macrocode}
%
%    \begin{macrocode}
\newif\if@vihproof \@vihprooftrue
\newtoks\juo@sar   \juo@sar={}
\@ifundefined{stripsep}{\newskip\stripsep \stripsep 15\p@}{}
\newskip\m@addvipersep \m@addvipersep\z@
\newskip\c@addvipersep \c@addvipersep\z@
\newdimen\ht@strip
\newdimen\right@cor
\newdimen\cor@height \cor@height=\z@
\newdimen\juo@pr
\newdimen\juo@ht
\newdimen\c@colht
\newbox\@viper
\newbox\@rightcolumn
\newcount\juo@sk
\def\@ca#1#2#3#4{}
%    \end{macrocode}
%
% \begin{macro}{\add@strip}
%    \begin{macrocode}
\def\add@strip#1#2#3#4{%
  \begingroup
    \xdef\ex@{\global\noexpand\juo@sar{\the\juo@sar\noexpand\@ca{#1}{#2}{#3}{#4}}}%
    \ex@
  \endgroup
  }
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\remove@strip}
%    \begin{macrocode}
\def\remove@strip#1{\ifx#1\@empty\global\juo@sk=0\else
   \global\advance\juo@sk by-1\expandafter\next@item\the #1\@@#1\fi}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\next@item}
%    \begin{macrocode}
\def\next@item \@ca #1#2#3#4#5\@@#6{\global #6={#5}\global\juo@pr=#1\global\juo@ht=#2%
\global\cor@height=#3\global\m@addvipersep=#4}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\strip}
%    \begin{macrocode}
\def\strip{\@ifnextsymb[{\@strip}{\@strip[0pt/0pt]}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@strip}
%    \begin{macrocode}
\def\@strip[#1/#2]{\global\@tempdima=#1\global\@tempdimb=#2%
  \global \setbox\@viper\vbox\bgroup%
        \hsize\textwidth
        \@parboxrestore
        \col@number \@ne
        \vrule height\topskip width0pt depth0pt
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\endstrip}
%    \begin{macrocode}
\def\endstrip{%
        \egroup
        \if@firstcolumn
                \ifdim\pagetotal>\z@
                        \vskip\stripsep
                        \global\ht@strip\pagegoal
                        \global\advance\ht@strip by-\pagetotal
                        \global\advance\ht@strip by-\stripsep
                        \global\advance\ht@strip by-\ht\@viper
                        \global\advance\ht@strip by-\stripsep
                        \global\juo@ht=\ht\@viper
                \else
                        \global\ht@strip\z@
                \fi
                \ifdim\ht@strip>\z@
                  \unvbox\@viper
                  \vskip\stripsep
                  \add@strip{\the\pagetotal}{\the\juo@ht}{\the\@tempdima}{\the\@tempdimb}%
                  \global\advance\juo@sk by1
                \else
                  \@latex@error{Strip needs more place!}\@ehc
                  \if@vihproof
                    \framebox[\columnwidth]{??? Strip ???}%
                  \fi
                \fi
        \else
          \@latex@error{Strip is used only on left column!}\@ehc
          \if@vihproof
            \framebox[\columnwidth]{??? Strip ???}%
          \fi
        \fi
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@outputdblcol}
%    \begin{macrocode}
\def\@outputdblcol{%
  \if@firstcolumn
    \global \@firstcolumnfalse
    \global \setbox\@leftcolumn \box\@outputbox
    \global\c@colht\@colht\global\c@addvipersep\z@
    \ifnum\juo@sk>0
        \remove@strip\juo@sar
        \global\@colht\the\juo@pr
        \ifdim\right@cor>\z@
                \global\advance\@colht by\right@cor
        \fi
        \global\advance\@colht by\cor@height
        \global\cor@height=0pt
    \fi
    \global \setbox\@rightcolumn \vbox{}%
  \else
    \ifdim\c@colht>\@colht
            \@tempdima\@colht
            \ifdim\@colht>\z@
            \global\setbox\@rightcolumn \vbox{%
                        \unvbox\@rightcolumn
                        \vbox to\@tempdima{%
                                \vskip\c@addvipersep\unvbox\@outputbox}%
                        \vskip\stripsep
                        \vrule height\the\juo@ht width 0pt depth 0pt
                        \vskip\stripsep
                        }%
            \global\c@addvipersep\m@addvipersep
            \else
            \global\setbox\@rightcolumn \vbox{%
                        \unvbox\@rightcolumn
                        \vrule height\the\juo@ht width 0pt depth 0pt
                        \vskip\stripsep
                        }%
            \fi
            \ifnum\juo@sk>0
                \remove@strip\juo@sar
                \global\@colht\the\juo@pr
                \global\advance\@colht by -\ht\@rightcolumn
                \global\advance\@colht by\cor@height
                \global\cor@height=0pt
            \else                             
                \global\advance\c@colht by-\ht\@rightcolumn
                \global\@colht\c@colht
            \fi
    \else
    \global \@firstcolumntrue
    \global\setbox\@outputbox\vbox to\ht\@leftcolumn{%
                        \unvbox\@rightcolumn
                        \vskip\c@addvipersep
                        \unvbox\@outputbox
                        }%
    \setbox\@outputbox \vbox {%
                         \hb@xt@\textwidth {%
                           \hb@xt@\columnwidth {%
                             \box\@leftcolumn \hss}%
                           \hfil
                           \vrule \@width\columnseprule
                           \hfil
                           \hb@xt@\columnwidth {%
                             \box\@outputbox \hss}%
                                             }%
                              }%
    \@combinedblfloats
    \@outputpage
    \begingroup
      \@dblfloatplacement
      \@startdblcolumn
      \@whilesw\if@fcolmade \fi
        {\@outputpage
         \@startdblcolumn}%
    \endgroup
    \global\juo@sk=0\global\juo@sar={}%
    \global\cor@height\z@\global\c@addvipersep\z@
    \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@cflt}
%    \begin{macrocode}
\def \@cflt{%
    \let \@elt \@comflelt
    \setbox\@tempboxa \vbox{}%
    \@toplist
    \global\right@cor\ht\@tempboxa
    \ifdim\right@cor>\z@
            \global\advance\right@cor by-\floatsep
            \global\advance\right@cor by\textfloatsep
    \fi
    \setbox\@outputbox \vbox{%
                             \boxmaxdepth \maxdepth
                             \unvbox\@tempboxa
                             \vskip -\floatsep
                             \topfigrule
                             \vskip \textfloatsep
                             \unvbox\@outputbox
                             }%
    \let\@elt\relax
    \xdef\@freelist{\@freelist\@toplist}%
    \global\let\@toplist\@empty
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@ifnextsymb}
%    \begin{macrocode}
\def\@ifnextsymb#1#2#3{%
  \let\reserved@d=#1%
  \def\reserved@a{#2}\def\reserved@b{#3}%
  \futurelet\@let@token\@ifnsymb}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@ifnsymb}
%    \begin{macrocode}
\def\@ifnsymb{%
  \ifx\@let@token\@sptoken
    \let\reserved@c\reserved@b
  \else
    \ifx\@let@token\reserved@d
      \let\reserved@c\reserved@a
    \else
      \let\reserved@c\reserved@b
    \fi
  \fi
  \reserved@c}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode} 
%\endinput 
%    \end{macrocode} 
%%
% \iffalse
%</package>
% \fi
%
% \Finale