f



Plain TeX macros for text-flowing-around-figures

Are there any public domain macros to do the 
title task?  More specifically:

texttexttexttexttexttexttexttexttexttexttext
texttexttexttexttexttexttexttexttexttexttext
texttexttexttexttexttexttexttexttexttexttext
texttexttexttexttexttexttexttexttexttexttext
texttexttexttext    -----------------------
texttexttexttext   |                       |
texttexttexttext   |   Figure box          |
texttexttexttext   |   inserted by         |
texttexttexttext   | \BoxedEPSF{ ...}      |
texttexttexttext   |                       |
texttexttexttext    ----------------------- 
texttexttexttext            label
texttexttexttext 
texttexttexttexttexttexttexttexttexttexttext
texttexttexttexttexttexttexttexttexttexttext
texttexttexttexttexttexttexttexttexttexttext
texttexttexttexttexttexttexttexttexttexttext

I wrote my own macros to do this, but they involve
fiddling with several dimens and picking the 
insertion spot. Also possible interaction with
footnotes, wide eqs, ejects, etc, often requires 
intervention. Coulnt find anything pertinent in eplain.

Note: I am not interested in LaTeX.

Thanks for any pointers.
0
carlos151 (336)
10/1/2003 8:24:31 PM
comp.text.tex 39029 articles. 3 followers. Post Follow

6 Replies
1094 Views

Similar Articles

[PageSpeed] 48

carlos@colorado.edu (Carlos Felippa) wrote:

[See subject]

> Note: I am not interested in LaTeX.

There are several LaTeX packages (see FAQ)
that solve your problem. You can look at them
and reimplement the technique used there in plain-TeX.

Yours sincerely
  Heiko <oberdiek@uni-freiburg.de>
0
oberdiek (2375)
10/1/2003 9:24:46 PM
Carlos Felippa wrote:
> I wrote my own macros to do this, but they involve
> fiddling with several dimens and picking the 
> insertion spot. Also possible interaction with
> footnotes, wide eqs, ejects, etc, often requires 
> intervention. Coulnt find anything pertinent in eplain.
> 
> Note: I am not interested in LaTeX.

Here is what I wrote (ages ago, I notice). I don't claim anything great 
about it, but it might give you or someone some ideas.

Ian Hutchinson.

% FIGFLOW:  plain TEX macro by Ian Hutchinson, 21 Oct 95.
% Make text flow round figure.
% Usage: \figflow{<width>}{<height>}{<[Figure+][Caption]>}
% at start of new paragraph. Figure top starts at insert.
% #1 figure width dimen. If negative, fig on right, else left.
% #2 figure height (including caption) dimen. (E.g.: 4 truein)
% #3 \special for figure if desired, then \vfill caption. (Both optional).
% Example: figflow{4 truein}{5 truein}{\epsfbox{figure.ps}\vfill Figure 1.}
% User is responsible for the figure fitting within the space defined.
% If figure won't fit on page, it is moved over the page break.
% If a new figflow starts before the old one is finished, a message is given
% and the second figure is skipped. Fix manually.
% Does not work for Latex.

\newdimen\pageremains\newdimen\pdepth
\newdimen\figwidth
\newdimen\figheight
\newcount\figlines
\newcount\flevel

\def\figflow#1#2#3{
\ifnum\flevel>0
\message{******Figure collision. Ignoring second figure.******}
\else
\figwidth=#1
\figheight=#2
\def\contents{#3}
% Put figure contents in an appropriate box.
\def\figure{\let\temp=\par \let\par=\plainpar
  \line{\overfullrule=0pt%  Avoid black box.
   \ifdim \figwidth<0pt \hsize=-\figwidth \hss\else \hsize=\figwidth\fi
   \advance \hsize by -10pt% Give a little extra hspace.
   \vbox to \figheight{\vfil\noindent\contents}
   \ifdim \figwidth>0pt \hss\fi
  } \vskip-\figheight
  \let\par=\temp%
}
\advance\figheight by \baselineskip
\divide\figheight by \baselineskip% convert height to lines.
\figlines=\figheight \multiply\figheight by \baselineskip
\begingroup\overfullrule=0pt% Turn off black box outside fig
\tolerance=1000% Allow more spaced out lines.
\flevel=1
% Store \par
\let\plainpar=\par
% Define new \par to process figures each paragraph.
\def\par{
  \ifnum\flevel=1
% We are starting a new figure. Set to look for enough room.
   \plainpar
% End the previous paragraph.
   \pageremains=\pagegoal \advance\pageremains by -\pagetotal
   \ifdim\pageremains<\figheight \message{Moving figure...}%keep looking
   \else
% Found the starting place. Store prevdepth. Remove glue. Place the figure.
      \pdepth=\prevdepth
      \nointerlineskip
      \figure
      \hangindent \figwidth \hangafter -\figlines \hfuzz 5 pt
      \flevel=2
      \prevgraf=0
      \figheight=\baselineskip% Removed parskip adjust.
   \fi
  \else
   \ifnum\flevel=2%level 2, making the figure.
    \ifdim\figheight<\parskip
       \advance\figlines -1 \advance\hangafter 1
       \advance\figheight\baselineskip
    \else
       \advance\figheight -\parskip%\message{else \the\figheight}
    \fi
    \hangcarrypar\relax% I don't know why, but this is needed.
   \fi
  \fi
}
\par
\vskip-\pdepth%Restore the prevdepth from the previous paragraph.
\fi
}
% Macros.
\def\endflow{\global\let\par=\plainpar\endgroup}% terminate main group.
\def\hangcarrypar{% Carry the hangindent to next par.
\edef\next{\hangafter=\the\hangafter\hangindent=\the\hangindent}
\plainpar\next
\edef\next{\prevgraf=\the\prevgraf}
\ifnum\prevgraf>0
   \ifnum\prevgraf>\figlines \endflow \flevel=0
   \else
     \message{FIGFLOW: line \the\prevgraf, of \the\figlines.}
     \leavevmode% Sets prevgraf to 0. So reset it using next.
     \next
   \fi
\fi
}

0
hutch2980 (34)
10/1/2003 10:57:17 PM
 Ian Hutchinson <hutch@hutchinson.belmont.ma.us> writes:
>Carlos Felippa wrote:
>> I wrote my own macros to do this, but they involve
>> fiddling with several dimens and picking the 
>> insertion spot. Also possible interaction with
>> footnotes, wide eqs, ejects, etc, often requires 
>> intervention. Coulnt find anything pertinent in eplain.
>
>Here is what I wrote (ages ago, I notice). I don't claim anything great 
>about it, but it might give you or someone some ideas.

i know it's not the plain tex _way_ to share, but it seems to me that
such macros could usefully be made generally available.  any chance of
a copy for ctan?
-- 
Robin (the partially spineless) Fairbairns, Cambridge
0
rf53 (2582)
10/2/2003 10:10:34 AM
Robin Fairbairns wrote:
>  Ian Hutchinson <hutch@hutchinson.belmont.ma.us> writes:
> 
>>Carlos Felippa wrote:
>>
>>>I wrote my own macros to do this, but they involve
>>>fiddling with several dimens and picking the 
>>>insertion spot. Also possible interaction with
>>>footnotes, wide eqs, ejects, etc, often requires 
>>>intervention. Coulnt find anything pertinent in eplain.
>>
>>Here is what I wrote (ages ago, I notice). I don't claim anything great 
>>about it, but it might give you or someone some ideas.
> 
> 
> i know it's not the plain tex _way_ to share, but it seems to me that
> such macros could usefully be made generally available.  any chance of
> a copy for ctan?

Consider that the copy. Do with it what you will.

Ian Hutchinson.

0
hutch2980 (34)
10/3/2003 1:33:29 AM
carlos@colorado.edu (Carlos Felippa) wrote in message news:<6bd3575.0310021124.4d77b915@posting.google.com>...
> Ian Hutchinson <hutch@hutchinson.belmont.ma.us> wrote in message news:<3F7B5C8D.7070000@hutchinson.belmont.ma.us>...
> > Carlos Felippa wrote:
> > > I wrote my own macros to do this, but they involve
> > > fiddling with several dimens and picking the 
> > > insertion spot. Also possible interaction with
> > > footnotes, wide eqs, ejects, etc, often requires 
> > > intervention. Coulnt find anything pertinent in eplain.
> > > 
> > > Note: I am not interested in LaTeX.
> > 
> > Here is what I wrote (ages ago, I notice). I don't claim anything great 
> > about it, but it might give you or someone some ideas.
> > 
> > Ian Hutchinson.
> 
> <...>
> 
> Many thanks.  Let me try it, and will report results.  Since my book
> has about 100 such figures (about 1 every 5 pages), a more automated 
> flowaroundboxes would save quite a bit of fiddling.

Not good news. Tried it under TeXtures, using BoxedEPSF to insert pictures
of one chapter and works erratically. Figures sometimes appear, 
sometimes do not. Not surprising, considering that graphic insertion is 
not a standard part of TeX (BoxedEPSF doesnt do "scale into given box"; 
receives scaling as argument, creates box).  So I guess some 
"macrosurgery" may be required.  Not sure if I can spend that time 
during a busy semester ...

Note: TeXtures has good support for BoxedEPSF; it blends well with
BlueSky propietary methods for \special. It has very nice
fine-control over figure placement, critical in books. Those are 
the reasons I have preferred that insertion package.
0
carlos151 (336)
10/4/2003 6:41:36 PM
 carlos@colorado.edu (Carlos Felippa) writes:
>[of using ian hutchinson's figflow]
>Not good news. Tried it under TeXtures, using BoxedEPSF to insert pictures
>of one chapter and works erratically. Figures sometimes appear, 
>sometimes do not. Not surprising, considering that graphic insertion is 
>not a standard part of TeX (BoxedEPSF doesnt do "scale into given box"; 
>receives scaling as argument, creates box).  So I guess some 
>"macrosurgery" may be required.  Not sure if I can spend that time 
>during a busy semester ...

gosh.  i hadn't realised boxedepsf was so crude.  even epsf (the
trivial macros that come with dvips) manages scale-to-size

>Note: TeXtures has good support for BoxedEPSF; it blends well with
>BlueSky propietary methods for \special. It has very nice
>fine-control over figure placement, critical in books. Those are 
>the reasons I have preferred that insertion package.

no: boxedspsf was written for use with textures' specials, just like
the ancient, primitive, epsf was written for use with dvips' specials.
there's nothing magic about either arrangement (and every dvi driver
that produces postscript has the same sorts of specials).  of course,
the latex standard graphics package (also available with a helper
package for use with plain tex) will work with both dvips and textures
(and pdftex and dvipdfm as well as other proprietary tex distributions).
-- 
Robin (the partially spineless) Fairbairns, Cambridge
0
rf53 (2582)
10/4/2003 9:49:51 PM
Reply:

Web resources about - Plain TeX macros for text-flowing-around-figures - comp.text.tex

Resources last updated: 3/11/2016 7:45:56 PM