[texhax] Wrapped images on the top/bottom of the page
Uwe Lueck
uwe.lueck at web.de
Sun Nov 21 12:18:29 CET 2010
"Martin Schröder" <martin at oneiros.de>, 20.11.2010 19:30:06
>2010/11/20 Андрей Лапшин <velisarus at gmail.com>:
>> I run into trouble. I have to make layout like this:
>> https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0B4RAQ8QLfjMkZWY5ZDIxMWUtYTNjYy00ZWQxLWI4MzktNjdkNjFhMzhlYjZk&hl=ru
>>
>> I'd like to ask experts: Is such image layout possible in LaTeX? Which
>> tools and packages should I use?
>
>It's HARD in LaTeX; wrapfig may help.
I have done such a thing for translation of Copernicus'
"De Revolutionibus" for his geometrical drawings.
It was attempted roughly to keep the original dimensions
(of his manuscript). The manuscript doesn't always "wrap"
(or even never), often a drawing was placed in the margin,
and often it was about as high as the entire text of the page.
It was decided to mimick/vary this by wrapping.
The difficulties now were
(i) placement of the figures had to be revised manually sometimes,
in order to have at least (if possible) a part of a geometrical proof
on the same spread as the figure illustrating it;
(ii) almost always it was impossible to place a figure
in the first line of a paragraph, as no paragraph nearby
was high enough.
Paragraphs were typically very long.
Therefore I usually placed figures at the top of a page
by moving them inside a paragraph to an appropriate line.
Sometimes I needed to modify the adjustment of section
titles and other paragraphs so a figure had enough
vertical space.
According to my memory, wrapfig etc. allow moving a figure
in a paragraph by determining a position in the text code
where a line break looks good. I considered this too messy
for revising positions. As it was a critical edition, I used
lineno.sty functionality to make a macro roughly saying
"place the figure after the nth line of the present paragraph".
I thought of measuring the appropriate number of lines
automatically, but didn't have the time for this.
And I couldn't afford to make a release of the respective
version of lineno.sty and that extra package.
Now I realize here that this could be made perhaps simpler
with Plain TeX, still not attempting automatical position.
I am sketching a very manual approach so you see what
would happen, I leave it to others to "wrap" this into a macro
that automates the operations so it has about two
parameters, one for "place after nth line", one for including
the figure (and a caption).
First, you set \parshape according to TeXbook p. 101
to make room for the figure. You determine k such that
k\baselineskip is sufficiently larger than the height of the
figure (plus the caption and its distance to the figure
-- with Copernicus' drawings the caption often could
be placed inside a rectangle spanned by the drawing).
Set m := n+k+1 and
\parshape = m i_1 l_1 ... i_m l_m
such that
i_j = 0pt and l_j = \linewidth
iff either j less than or equal to n, or j = m; otherwise
i_j = w and l_j = \linewidth - w
where w is sufficiently larger than the width of the figure.
Well this was for putting the figure to the left of the paragraph,
otherwise replace i_j = w by i_j = 0pt.
Second, start the paragraph with something like
\leavevmode\hbox to 0pt{%
\vtop to 0pt{%
\vskip n\baselineskip
[\hfil?]\hbox{[FIGURE+CAPTION]}[\hfil?%?]
\vss
}\hss
}
I used lineno.sty to replace that vertical placement by a
macro obeying something like
"place the figure here, if this is the nth line of the paragraph".
My present proposal may be simpler, the lineno approach,
on the other hand, can cope with single "vertically
oversized" lines.
I might send my package that performed some of these operations.
Don't worry, be happy!
Uwe.
More information about the texhax
mailing list