home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / texmf / inputs / latex / contrib / other / misc.lha / misc / wrapfig.sty (.txt) < prev   
LaTeX Document  |  1995-05-03  |  21KB  |  390 lines

  1. %  W R A P F I G . S T Y    ver 3.0  (May 4, 1995)
  2. %  Copyright (C) 1991,1992,1995 by Donald Arseneau   <asnd@Triumf.ca>
  3. %  These macros may be freely transmitted, reproduced, or modified,
  4. %  but not sold.  This notice must be left intact.
  5. %  Environments "wrapfigure" and "wraptable" place a figure or table
  6. %  at the side of the page and wrap text around it.
  7. %  \begin{wrapfigure}[12]{r}[34pt]{5cm} <figure> \end{wrapfigure}
  8. %                     --  -  ----  ---
  9. %  [number of narrow lines] {placement} [overhang] {width of figure}
  10. %  Placement is one of   r, l, i, o, R, L, I, O,  for right, left,
  11. %  inside, outside, (here / FLOAT).
  12. %  The figure sticks into the margin by `overhang', if given, or by the
  13. %  length \wrapoverhang, which is normally zero.
  14. %  The number of wrapped text lines is normally calculated from the height
  15. %  of the figure, but may be specified manually ("12" above).
  16. %  More detailed instructions are given below, following the definitions.
  17. %  Please direct any problem reports to asnd@Triumf.ca
  18. %%%%%  ----- Begin definitions ----- %%%%%
  19. \@ifundefined{c@WF@wrappedlines}{}{\endinput}
  20. \newdimen\wrapoverhang \wrapoverhang\z@
  21. \newdimen\WF@size
  22. \newcount\c@WF@wrappedlines % used globally
  23. \newbox\WF@box
  24. \newtoks\WF@everypar
  25. \newif\ifWF@float
  26. \let\@@parshape\parshape
  27. \let\WF@@everypar\everypar
  28. \def\wrapfigure{\def\@captype{figure}\@ifnextchar[\WF@wr{\WF@wr[]}}
  29. \def\wraptable{\def\@captype{table}\@ifnextchar[\WF@wr{\WF@wr[]}}
  30. \def\WF@wr[#1]#2{% first two args: #1=num lines, #2=placement
  31.   \xdef\WF@wfname{wrap\@captype\space}%
  32.   \ifvoid\WF@box\else \WFclear \WF@collision \fi
  33.   \xdef\WF@place{\string`\@car#2r\@nil}%
  34.   \ifnum\lccode\WF@place=\WF@place \global\WF@floatfalse
  35.     \else \global\WF@floattrue \WF@fltmes \fi
  36.   \ifx\parshape\WF@fudgeparshape \WF@collision \else
  37.    \ifx\par\@@par \ifnum\@@parshape>\z@\WF@conflict\fi \else \WF@conflict\fi
  38.   \fi \gdef\WF@wli{#1}%
  39.   \@ifnextchar[\WF@rapt{\WF@rapt[\wrapoverhang]}}
  40. \def\WF@rapt[#1]#2{% final two args: #1 = overhang,  #2 = width, 
  41.   \gdef\WF@ovh{#1}% hold overhang for later, when \width is known
  42.   \global\setbox\WF@box\vtop\bgroup \setlength\hsize{#2}\@parboxrestore}
  43. \def\endwrapfigure{\par\hrule\@width\hsize\@height\z@ % force width
  44.   \egroup % end the \vtop; width is known so now is "later"
  45.   \def\width{\wd\WF@box}\setlength\wrapoverhang{\WF@ovh}% 
  46.   \xdef\WF@ovh{\the\wrapoverhang}% save until wrapping
  47.   \ifdim\ht\WF@box>\topskip \ht\WF@box\z@ \fi % too much height, set flag.
  48.   \ifdim\ht\WF@box<.5\p@ % too tall (starts with \vbox) or too short
  49.    \global\setbox\WF@box\vtop{\vskip-1.4ex\unvbox\WF@box}\fi
  50.   \global\WF@size\dp\WF@box % box is guaranteed to have little height.
  51.   \global\advance\WF@size1.5\baselineskip \global\advance\WF@size\tw@\intextsep
  52.   \aftergroup\WF@startfloating % even when not really floating!
  53.   \ifWF@float\else \ifhmode
  54.      {\unskip \parfillskip\z@skip \par \vskip-\parskip}\aftergroup\noindent
  55.   \fi\fi \global\@ignoretrue}
  56. \let\endwraptable\endwrapfigure
  57. % Subvert \everypar to float fig.  Also for non-float.
  58. \def\WF@startfloating{%
  59.  \WF@everypar\expandafter{\the\everypar}\let\everypar\WF@everypar
  60.  \WF@@everypar{\ifx\parshape\WF@fudgeparshape \WF@fltmes\else
  61.   \ifx\par\@@par\ifnum\@@parshape=\z@\ifdim\hangindent=\z@
  62.     \setbox\z@\lastbox \begingroup
  63.     \@@par \WF@@everypar{}\WF@putfigmaybe
  64.     \endgroup % start wrapping
  65.     \ifvoid\z@\else\box\z@\fi % replace indentation
  66.   \else\WF@fltmes\fi\else\WF@fltmes\fi\else\WF@fltmes\fi\fi
  67.  \ifvoid\WF@box % figure was done--end floating:
  68.    \let\everypar\WF@@everypar \everypar\expandafter{\the\WF@everypar}%
  69.  \fi \the\everypar
  70. % Put fig here if it fits or if it can't float
  71. \def\WF@putfigmaybe{%
  72. \ifinner
  73.   \vskip-\parskip \global\WF@floatfalse
  74.   \let\pagetotal\maxdimen % kludge flag for "not top of page"
  75. \else % outer page
  76.   \@tempdima\pagedepth % save page depth
  77.    {\advance\parskip\@tempdima\vskip-\parskip}% back up to baseline
  78.    \penalty\interlinepenalty % update pg. parameters
  79.    \@tempdimb\pagegoal \advance\@tempdimb-\pagetotal % room left on page
  80.    \ifdim\@tempdimb<\z@ % \WF@info{Page overfull already;}%
  81.       \global\WF@floatfalse
  82.       \ifdim-\@tempdimb>\pageshrink \else \pagebreak \fi
  83.    \else
  84.       \ifdim\WF@size>\@tempdimb 
  85. %        \WF@info{Size \the\WF@size\space does not fit in \the\@tempdimb}%
  86.          \ifWF@float \dimen@.5\baselineskip \else \dimen@ 2\baselineskip\fi
  87.          \ifdim\pagestretch>\dimen@ \dimen@\pagestretch \fi
  88.          \ifdim\pagefilstretch>\z@ \dimen@\@tempdimb \fi
  89.          \ifdim\pagefillstretch>\z@ \dimen@\@tempdimb \fi
  90.          \advance\dimen@.5\baselineskip
  91.          \ifdim\dimen@>\@tempdimb % \WF@info{Page nearly full; can stretch}%
  92.             \global\WF@floatfalse \pagebreak
  93.          \fi
  94.       \else % \WF@info{Fits in \the\@tempdimb;}%
  95.          \global\WF@floatfalse
  96.    \fi\fi
  97.    \vskip\@tempdima\relax % (return erased page depth)
  98. \noindent
  99. \ifWF@float
  100.   \WF@fltmes
  101. \else % putting here;
  102.   \WF@info{Put \WF@wfname here:}%
  103.   {\ifodd\if@twoside\c@page\else\@ne\fi % assign l/r to i/o placement
  104.     \lccode`i`l\lccode`o`r\else \lccode`i`r\lccode`o`l\fi
  105.     \xdef\WF@place{\the\lccode\lccode\WF@place}}% twice to get only l or r
  106.   \hbox to\z@{% llap or rlap depending on {l} or {r}; calc effective width
  107.    \@tempdima\wd\WF@box \@tempdimb\WF@ovh
  108.    \advance\@tempdima-\@tempdimb \advance\@tempdima\columnsep
  109.    \@tempdimb\hsize \advance\@tempdimb-\@tempdima
  110.    \ifnum `l=\WF@place % fig on left
  111.     \hss % figure overlaps space to the left
  112.     \def\@tempa{\kern\columnsep}% position to left of the gap
  113.    \else  %  fig on right
  114.     \@tempdima\z@ % no left indentation
  115.     \kern\@tempdimb \kern\columnsep
  116.     \def\@tempa{\hss}% figure overlaps space to the right
  117.    \fi
  118.    \ifdim\@tempdimb<\hsize
  119.     \xdef\WF@wrapil{\the\@tempdima \the\@tempdimb}% indentation and length
  120.    \else
  121.     \xdef\WF@wrapil{\z@ \the\hsize}%
  122.    \fi
  123.    \ifdim\pagetotal=\z@ % \WF@info{Put \WF@wfname\space at top of p.\thepage}%
  124.     \global\advance\WF@size-\intextsep
  125.    \else % \WF@info{Putting \WF@wfname\space in middle of page}%
  126.     \setbox\WF@box\hbox{\lower\intextsep\box\WF@box}%
  127.    \fi \dp\WF@box\z@ \box\WF@box \@tempa
  128.   }% end \hbox to 0pt
  129.   \aftergroup\WF@startwrapping % after the \endgroup which immediately follows
  130. \def\WF@startwrapping{%
  131.  \ifx\WF@wli\@empty
  132.   {\advance\WF@size1.1\baselineskip
  133.   \divide\WF@size\baselineskip \global\c@WF@wrappedlines\WF@size}%
  134.  \else
  135.   \setcounter{WF@wrappedlines}{\WF@wli}\global\advance\c@WF@wrappedlines\@ne
  136.  \ifnum\c@WF@wrappedlines>\@ne
  137.   \let\parshape\WF@fudgeparshape \let\WF@pspars\@empty \let\WF@@par\par
  138.   \def\@setpar##1{\def\WF@@par{##1}}\def\par{\@par}\let\@par\WF@mypar
  139.   \xdef\WF@restoretol{\tolerance\the\tolerance\relax}\tolerance9999
  140.  \fi}
  141. \def\WF@mypar{\relax %% \WF@info{\the\c@WF@wrappedlines-1 lines to wrap}%
  142. \ifnum\c@WF@wrappedlines<\tw@ \WF@finale \par \else
  143.  \begingroup
  144. % Create \parshape command:
  145.  \@tempcnta\@ne \let\@tempb\relax \def\@tempc{}%
  146.  \@whilenum \@tempcnta<\c@WF@wrappedlines\do{% repeated indentation, length
  147.   \edef\@tempc{\@tempc\@tempb}\advance\@tempcnta\@ne
  148.  }\let\@tempb\WF@wrapil
  149.  \ifx\WF@pspars\@empty \else % use external `parshape' values to modify -
  150.   \let\WF@noil\WF@pspars     % my parshape
  151.   \afterassignment\@tempdimb \@tempdima\WF@pspars % a=ind, b=wid
  152.   \afterassignment\dimen@\advance\@tempdima\@tempb\advance\@tempdimb\dimen@
  153.   \advance\@tempdimb-\hsize
  154.   \def\@tempb{\@tempdima \@tempdimb}%
  155.  \fi \@@parshape \c@WF@wrappedlines \@tempc \WF@noil
  156.  \WF@@par % what the rest of LaTeX expects \par to be (usually \@@par)
  157.  \ifnum\@@parshape=\z@ \endgroup \let\WF@pspars\@empty % reset `parshape'
  158.  \else\endgroup\fi
  159.  \global\advance\c@WF@wrappedlines-\prevgraf \prevgraf\z@
  160.  \ifnum\c@WF@wrappedlines<\tw@ \WF@finale \fi
  161. \let\@@setpar\@setpar
  162. \def\WF@noil{\z@ \hsize}
  163. \let\WF@pspars\@empty
  164. \def\WF@fudgeparshape#1#2#3{\relax
  165.  \ifnum\c@WF@wrappedlines<\tw@ \WF@finale \parshape#1#2#3\else
  166.  \ifnum#1=\@ne
  167.   \begingroup
  168.    \@tempdima#2\@tempdimb#3\edef\@tempa{%
  169.    \def\noexpand\WF@pspars{\the\@tempdima \the\@tempdimb}}%
  170.   \expandafter\endgroup\@tempa
  171.  \else\WF@conflict\fi \fi}
  172. \def\WF@finale{\ifx\parshape\WF@fudgeparshape 
  173.  \let\@setpar\@@setpar \let\par\WF@@par
  174.  \WF@info{Finish wrapping text}%
  175.  \ifx\par\@@par \def\@par{\let\par\@@par\par}\else \let\@par\WF@@par \fi
  176.  \let\parshape\@@parshape
  177.  \parshape\ifx\WF@pspars\@empty \z@ \else \@ne \WF@pspars\fi
  178.  \WF@restoretol \fi}
  179. \newcommand{\WFclear}{\ifvoid\WF@box\else \vskip\bigskipamount \box\WF@box
  180.  \let\everypar\WF@@everypar \everypar\expandafter{\the\WF@everypar}%
  181.  \fi \WF@finale}
  182. \begingroup
  183.  \toks0={\let\everypar\WF@@everypar \everypar\expandafter{\the\WF@everypar}%
  184.    \let\parshape\@@parshape \let\@setpar\@@setpar }
  185.  \toks1=\expandafter{\@arrayparboxrestore}
  186.  \toks2=\expandafter{\clearpage}
  187.  \edef\@tempa{\def\noexpand\@arrayparboxrestore{\the\toks0 \the\toks1}%
  188.       \def\noexpand\clearpage{\noexpand\protect\noexpand\WFclear \the\toks2}}
  189.  \expandafter
  190. \endgroup\@tempa
  191. \def\WF@conflict{\WF@warning
  192.  {\WF@wfname used inside a conflicting environment}}
  193. \def\WF@collision{\WF@warning{Collision between wrapping environments}}
  194. \def\WF@fltmes{\ifWF@float \WF@info{\WF@wfname floats}%
  195.  \else \WF@warning{"Stationary" \WF@wfname forced to float}\fi}
  196. \let\WF@warning\@warning
  197. \let\WF@info\@gobble
  198. \@ifundefined{DeclareOption}{\endinput}{}
  199. \def\WF@warning{\PackageWarning{wrapfig}}
  200. \ProvidesPackage{wrapfig}[1995/05/04 \space  v 3.0]
  201. \DeclareOption{verbose}{\def\WF@info{\PackageInfo{wrapfig}}}
  202. \ProcessOptions
  203. \AtEndDocument{\WFclear}
  204. \endinput
  205. %%%%%  ----- End definitions ----- %%%%%
  206. %%%%%  ----- Begin Instructions ----- %%%%%
  207. W R A P F I G . S T Y  \ \  ver 3.0 \ \ (May 4, 1995)
  208. Copyright (C) 1991,1992,1995 by Donald Arseneau  (asnd@Triumf.ca)
  209. Wrapfig.sty provides the environments "wrapfigure" and "wraptable" for
  210. typesetting a narrow float at the edge of the text, and making the text
  211. wrap around it.  The "wrapfigure" and "wraptable" environments interact
  212. properly with the "\caption" command to produce proper numbering, but
  213. they are not regular floats like "figure" and "table", so (beware!) they
  214. may be printed out of sequence with the regular floats.  There are four
  215. parameters for "\begin{wrapfigure}", two optional and two required, plus
  216. the text of the figure, with a caption perhaps:
  217.    \begin{wrapfigure}[12]{r}[34pt]{5cm} <figure> \end{wrapfigure}
  218.                       ==  =  ====  ===
  219.    [number of narrow lines] {placement} [overhang] {width}
  220. Some idiosyncrasies:
  221.   - You must not specify a wrapfigure in any type of list environment or
  222.     or immediately before or immediately after one.  It is OK to follow
  223.     a list if there is a blank line ("\par") in between.
  224.   - If you put a wrapfigure in a parbox or a minipage, or any other type
  225.     of grouping, the text wrapping should end before the group does.
  226.   - It does work in two-column format, but are your figures that small?
  227.   - It may be out of sequence with regular floats.
  228.   - The hlines that may be printed above and below floats are ignored;
  229.     you must insert them manually if desired.
  230.   - "\linewidth" is not adjusted within the wrapped text (because it can
  231.     only be set for whole paragraphs at a time).
  232. \section{Placement and Floating}
  233. Parameter "#2" (required) is the figure placement code, but the valid
  234. codes are different from regular figures.  They come in pairs: an
  235. uppercase version which allows the figure to float, and a lowercase
  236. version that puts the figure ``exactly here''.
  237.   r  R  -  the right side of the text
  238.   l  L  -  the left side of the text
  239.   i  I  -  the inside edge--near the binding (if "[twoside]" document)
  240.   o  O  -  the outside edge--far from the binding
  241. You should specify one code only, not a list.  The figure or table must
  242. be on one side or the other; it cannot be in the middle with text on
  243. both sides.  The "i" and "o" options refer to the inside and outside of
  244. the whole page, not individual columns.
  245. The ability to float is somewhat restricted, and you will get best results
  246. by giving exact manual placement, but floating is more convenient while
  247. revising the document.  Any changes to the formatting can ruin your manual
  248. positioning so you should adjust the placement just before printing a
  249. final copy.  Here are some tips for good placement:
  250.   - The environment should be placed so as to not run over a page break.
  251.   - The environment must not be placed in special places like lists.
  252.   - Only plain text should wrap around the figure.  Section titles and
  253.     big equations are bad; lists are bad if the figure is on the left.
  254.     (These are legal, they just look poor.)  Small equations look fine.
  255.   - It is convenient to begin the environment between paragraphs, but if
  256.     you want placement in the middle of a paragraph, you must put the
  257.     environment between two words where there is a natural line break.
  258. When floating, \LaTeX\ tries to apply these rules.  More specifically,
  259. a floated wrapping environment will only begin...
  260.   - at the beginning of a paragraph,
  261.   - when there is enough room on the page, or it is possible to go on
  262.     the next page,
  263.   - if the `paragraph' is not in a section title or a list,
  264.   - if the paragraph is not wrapping around another figure,
  265.   - in the main text (not in a minipage etc.)
  266. It is possible that a non-floating wrapfigure will be forced to float
  267. when an earlier one is still being processed.  A warning will be written
  268. in that case.  You can have more information about the floating process
  269. written to the log file by specifying "\usepackage[verbose]{wrapfig}".
  270. If there is a lot of flexibility on a page, a floating wrapfigure may
  271. be placed badly; you must turn to manual placement.  A rare problem is 
  272. that floats and footnotes specified within the wrapping text can also
  273. cause bad formatting.
  274. \section {Sizing and optional overhang}
  275. Parameter "#4" (the second required parameter) is the width of the figure
  276. or table.  It is possible that the contents will be wider or narrower than
  277. this value (if you use a tabbing environment or "\hbox") and the wrapped
  278. text will use the greater of the specified and actual widths. \LaTeX\ will
  279. wrap surrounding text around the figure, leaving a gap of "\intextsep" at
  280. the top and bottom, and "\columsep" at the side, by producing a series of
  281. shortened text lines beside the figure.  The indentation (shortening) of
  282. the text is the figure width plus "\columnsep" minus overhang (if any; see
  283. below).
  284. \LaTeX\ calculates the number of short lines needed based on the height
  285. of the figure and the length "\intextsep".  You can override this guess
  286. by giving the first optional argument (parameter "#1") specifying the
  287. number of shortened lines (counting each displayed equation as 3 lines).
  288. This is particularly useful when the surrounding text contains extra
  289. vertical spacing that is not accounted for automatically.
  290. The second optional parameter ("#3") tells how much the figure should
  291. hang out into the margin. The default overhang is given by the length
  292. "\wrapoverhang", which is "0pt" normally but can be changed using
  293. "\setlength".  For example, to have all wrapfigures use the space
  294. reserved for marginal notes,
  295.     \setlength{\wrapoverhang}{\marginparwidth}
  296.     \addtolength{\wrapoverhang}{\marginparsep}
  297. When you do specify the overhang explicitly for a particular figure, you
  298. can use a special unit called "\width" meaning the width of the figure.
  299. For example, "[0.5\width]" makes the center of the figure sit on the
  300. edge of the text, and "[\width]" puts the figure entirely in the margin
  301. (and the adjacent text is indented by just "\columnsep").
  302. \section{Some Random Implementation Notes}
  303. Unfortunately, \LaTeX's system of setting "\everypar" and "\par" is
  304. unable to coexist peacefully with a wrapping environment, so I was
  305. forced to subvert the "\@setpar" mechanism and "\everypar".  ("\everypar"
  306. is already subverted once by NFSS.)  For simplicity, both floating and
  307. non-floating objects use "\everypar".
  308. When checking the room left on the page, remember that if there is less
  309. than "\baselineskip" the new paragraph will begin on the next page, even
  310. if there is no page stretch. If non-floating, I force a bad page break
  311. rather than have the figure hang into the bottom margin.
  312. Here are notes on various variables and some macros; what info they
  313. store and how they are used.
  314.   \WF@wli - number-of-wrapped-lines parameter, saved for start of wrapping.
  315.      Set globally by "\WF@wr" (set empty if no optional parameter given).
  316.      The floating mechanism ignores this and uses the real size.
  317.   \WF@ovh - margin overhang set globally by "\WF@rapt", saved until placing
  318.      figure (but not reset).  Actually, the setting is very tricky so that
  319.      the expected values are used when a figure floats. First, the expression
  320.      is saved without evaluation by "\WF@rapt" ("\begin{wrapfigure}") because
  321.      "\width" is still unknown.  Soon after that, "\endwrapfigure" executes
  322.      "\WF@ovh" to evaluate the overhang and save the result (so that changes
  323.      to "\wrapoverhang" while this figure is floating won't affect this
  324.      figure). Finally, it is used by "\WF@putfigmaybe" when printing the fig.
  325.   \WF@place - a macro that is used as a number, giving the placement code.
  326.      It might start out as "`I" and later be converted to "114" (r).
  327.   \WF@box - tested for void at "\begin{wrapfigure}", to avoid collisions,
  328.      and by "\everypar" after "\WF@putfigmaybe", to end floating.  Voided
  329.      globally when used by "\WF@putfigmaybe" (or by "\WF@wr" if an old
  330.      figure must be dumped prematurely).
  331.   \par - test if it is "\@@par" at "\begin{wrapfigure}" and in "\everypar"
  332.      to float past special environments.  It is set to "\@par" ("\WF@mypar")
  333.      by "\WF@startwrapping", and restored by an end-group (bad!) or by
  334.      "\WF@finale" (good).  It is protected from change by redefining
  335.      "\@setpar".
  336.   \parshape - set to "\WF@fudgeparshape" by "\WF@startwrapping", so
  337.      lists will continue wrapping; "\@@parshape" preserves the real
  338.      "\parshape" command, and it is restored by "\WF@finale" or
  339.      "\@parboxrestore". "\WF@putfig" may test if old wrapping is still in
  340.      progress with "\ifx\parshape\WF@fudgeparshape". "\@@parshape" is also
  341.      tested to float past lists and other wrapping environments.
  342.   \hangindent - tested to float past section titles etc.
  343.   \c@WF@wrappedlines - the number of shortened lines + 1; set globally by
  344.      "\WF@startwrapping" and decremented by "\par" ("\WF@mypar").  It is > 1
  345.      only when wrapping is incomplete.  "\WF@mypar" and "\WF@fudgeparshape"
  346.      test the number for calling "\WF@finale".  It may get stuck at some high
  347.      value if "\par" is restored by an end-group, (and wrapping is terminated
  348.      prematurely) so it is unwise to use this as a test for wrapping-complete.
  349.   \pagetotal - when putting a wrapfigure in a parbox, I assign (locally!)
  350.      "\let\pagetotal\maxdimen" to signal not-top-of-page and no floating.
  351.   \WF@pspars - the "\parshape" parameters as LaTeX sets them for lists
  352.      ("\WF@fudgeparshape"); when wrapping I test it and use it to modify my
  353.      own real params for the paragraph.  They are also used when "\parshape"
  354.      is restored after wrapping.
  355.   \WF@finale - is performed by "\par" when wrapping should end.  However,
  356.      that might happen inside a group (a list especially), so the subverted
  357.      versions of "\par", "\parshape" etc. will be reinstated when the group
  358.      ends.  Thus, they must themselves test "\c@WF@wrappedlines" < 2 to see
  359.      when wrapping is over, and if so, they should just do "\WF@finale" again.
  360. These are the tests to see if a floating wrapfigure will fit at a particular 
  361. spot.  These tests are performed at the beginning of every paragraph after 
  362. the figure, except in lists etc.  ("\pagegoal" - "\pagetotal" is the room 
  363. left on the page.) 
  364.   room_left := \pagegoal - \pagetotal
  365.   if  room_left < 0  then page overfull already: put figure (on next page)
  366.   else
  367.      if  figure_size > room_left  then does not fit
  368.         if  max(min_stretch, \pagestretch) + extra > room_left  
  369.            then page can stretch until full: put figure (at top of next page)
  370.         fi
  371.      else figure fits: put figure
  372.   fi fi
  373. Even if a wrapfigure is not floating, it will go through the same logic
  374. to generate a "\pagebreak", and maybe an underfull page, when the current
  375. page can stretch until full.  The "min_stretch" depends on whether it is
  376. floating or not: ".5\baselineskip" (floating) "2\baselineskip" (not). The 
  377. "extra" is ".5\baselineskip" in either case.  These values can be adjusted.
  378. There are some other `magic numbers' for floating that aren't really so 
  379. special, but you must change them together if you change them at all.
  380. To make floating wrapfigures float less and fit on pages more frequently,
  381. but not change the number of wrapped lines, decrease the "1.5" in
  382. "\global\advance\WF@size1.5\baselineskip" and increase the "1.1" in
  383. "\advance\WF@size1.1\baselineskip" by the same amount (and vice versa).
  384. To make more (or fewer) wrapped lines for the same size figure, without
  385. changing the floating, change "1.1" in "\advance\WF@size1.1\baselineskip" 
  386. unilaterally.
  387. %%%%%  ----- End Instructions ----- %%%%%
  388. Test file integrity:  ASCII 32-54, 55-126:  !"#$%&'()*+,-./0123456789
  389. :;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
  390.