summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/sttools/midfloat.sty
blob: d9d11129ee72946b44b32ab97971e68b944bf73e (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
%% midfloat.sty
%% Copyright 1997 Sigitas Tolu\v sis
%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
%% e-mail sigitas@vtex.lt
%% http://www.vtex.lt/tex/download/macros/
%%
% This program can redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or (at your option) any later version.
%
% PURPOSE:   Insert some material in full-width on double-column page.
%
% SHORT DESCRIPTION:
%
%   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).
%
% Provides new environment:
%
%  \begin{strip}[#1/#2] ... \end{strip}
%  -----------------------------
%
%   Puts \vbox{...} in full-width on double-column page.
%   Parameters #1 and #2 are optional. 
%   By default #1=0pt and #2=0pt.
%   The material on the right column under strip is stretched down 
%   by #1 and below strip is moved down by #2.
%
%   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.
%
% \changes{1997/10/01}{some names}
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{midfloat}[1997/10/01]
%
\newif\if@vihproof \@vihprooftrue
\newtoks\juo@sar \juo@sar={}
\def\@ca#1#2#3#4{}
\@ifundefined{stripsep}{\newskip\stripsep\stripsep 15pt}{}
%
\newskip\m@addvipersep
\m@addvipersep\z@
\newskip\c@addvipersep
\c@addvipersep\z@
\newdimen\ht@strip
\newdimen\right@cor
\newdimen\cor@height \cor@height=0pt
\newdimen\juo@pr
\newdimen\juo@ht
\newbox\@viper
\newcount\juo@sk
\newdimen\c@colht
\newbox\@rightcolumn

\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}

\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}
\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}

\def\strip{\@ifnextsymb[{\@strip}{\@strip[0pt/0pt]}}
\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
}
\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
}
\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
}

\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
}

\def\@ifnextsymb#1#2#3{%
  \let\reserved@d=#1%
  \def\reserved@a{#2}\def\reserved@b{#3}%
  \futurelet\@let@token\@ifnsymb}
\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}

\endinput