[texhax] Re: Layout problem with graphics
Nelson H. F. Beebe
beebe at math.utah.edu
Thu May 29 09:20:59 CEST 2003
Bill Purvis <bil at beeb.net> asks on Thu, 29 May 2003 06:18:55 +0100
about displaying images close to the page edge.
The question wasn't precise enough for me to be sure what is wanted,
but the basic idea is to get the picture into a box, lie to TeX about
its true size, and then get it into the margin.
Plain TeX's \llap and \rlap, and LaTeX's \makebox, allow the lie: they
let you create a box where the contents stick out on either side. By
suitable positioning of the box at the start or end of the line, you
can force it into the margin. Because the box has a nonzero height,
it will affect line positioning, which may not be what you want (see
below).
LaTeX's \marginpar provides another way to get (floating) material
into the margin.
Here is an example that should provide the needed clues to get what
you want:
% -*-latex-*-
\documentclass{article}
\usepackage[dvips]{graphicx}
\begin{document}
Blah blah blah blah blah blah blah blah blah blah blah.
Blah blah blah blah blah blah blah blah blah blah blah.
Blah blah blah blah blah blah blah blah blah blah blah.
\noindent
\makebox[0pt][r]{\fbox{\includegraphics[width=5mm]{golfer.eps}}}
Blah blah blah blah blah blah blah blah blah blah blah.
Blah blah blah blah blah blah blah blah blah blah blah.
\par
\hfill
\makebox[0pt][l]{\fbox{\includegraphics[width=5mm]{golfer.eps}}}
Blah blah blah blah blah blah blah blah blah blah blah.
Blah blah blah blah blah blah blah blah blah blah blah.
Blah blah blah blah blah blah blah blah blah blah blah.
Blah blah blah blah blah blah blah blah blah blah blah.
\marginpar{\fbox{\includegraphics[width=5mm]{golfer.eps}}}
\end{document}
If you want to position a picture without affecting line spacing, then
you need to create a zero-height box: try this:
\newcommand{\leftpic}[2]{%
\setbox0 = \hbox{\fbox{\includegraphics[width=#2]{#1}}\kern 2em}%
\dp0 = 0pt
\ht0 = 0pt
\noindent
\makebox[0pt][r]{\box0}%
\ignorespaces
}
and then write
\leftpic{golfer.eps}{5mm}
Blah blah blah blah blah blah blah blah blah blah blah.
Blah blah blah blah blah blah blah blah blah blah blah.
This might not do what you want if a page break falls at the start of
the paragraph.
On the other hand, if you want pictures that stick into the margin,
but also into the text, like this:
Blah blah blah blah blah blah blah blah blah blah blah.
Blah blah blah blah blah blah blah blah blah blah blah.
PPPPPPPP Blah blah blah blah blah blah blah blah blah blah
PPPPPPPP Blah blah blah blah blah blah blah blah blah blah
PPPPPPPP Blah blah blah blah blah blah blah blah blah blah
PPPPPPPP Blah blah blah blah blah blah blah blah blah blah
Blah blah blah blah blah blah blah blah blah blah blah.
Blah blah blah blah blah blah blah blah blah blah blah.
then you need a package that supports flowing text around
boxes: see, for example, the picinpar and wrapfig packages.
-------------------------------------------------------------------------------
- Nelson H. F. Beebe Tel: +1 801 581 5254 -
- Center for Scientific Computing FAX: +1 801 581 4148 -
- University of Utah Internet e-mail: beebe at math.utah.edu -
- Department of Mathematics, 110 LCB beebe at acm.org beebe at computer.org -
- 155 S 1400 E RM 233 beebe at ieee.org -
- Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe -
-------------------------------------------------------------------------------
More information about the texhax
mailing list