[texhax] Problem about make a figure masked
Steve Schwartz
s.schwartz at imperial.ac.uk
Thu Feb 24 18:16:47 CET 2011
Jene,
On Wed, 2011-02-23 at 23:25 +0000, Paulga wrote:
> I have a sinusoidal wave figure showing the contour of polymer stress.
> When I place it into my pdf file I would like to put a masking layer
> on it so that only the part of contour between the top and bottom
> walls of the wave is visible, the area outside blank. But I cannot
> find any method how to achieve this. Any help would be appreciated.
> Thanks in advance.
I often do something similar to replace tiny graph labels with bigger
ones by masking out the originals and placing my own.
One solution is to use overpic and to draw the necessary blanking frame
with picture commands, e.g.:
\documentclass{article}
\usepackage{graphicx}
\usepackage{overpic}
\usepackage{pict2e}
\usepackage{color}
\begin{document}
Hello\par
\framebox{
\begin{overpic}[width=\textwidth,grid]{<image-file>}
\put(10,5){\linethickness{5\unitlength}\color{white}\line(1,0){40}}
\end{overpic}
}\par
Goodbye
\end{document}
Some comments/explanations:
I put the graphics in a framebox just so you can see the boundary
overpic takes all the same arguments as \includegrahpics, plus a few.
The grid option shows you a grid so you can easily place things, and
overpic scales a dimension to \unitlength, which makes it easy to place
things, decide thicknesses, etc., in a reasonably robust way.
I've drawn one line, colored white, to get you started. I guess your
mask would have 4 lines and obviously you need to adjust the position,
thickness, and orientation of each one to create the desired mask.
pict2e enables you to draw lines of arbitrary thickness
An alternative approach, if it is always the outer boundary of the image
you want to clip, is simply to use the graphicx capability to clip your
image or redefine the bounding box. If you wanted blank space around it,
you could put it inside a picture environment that was sized bigger than
your image.
HTH
Steve
--
+-------------------------------------------------------------------+
Professor Steven J Schwartz Phone: +44-(0)20-7594-7660
Head, Space & Atmospheric Physics Fax: +44-(0)20-7594-7772
The Blackett Laboratory E-mail: s.schwartz at imperial.ac.uk
Imperial College London Office: Huxley 6M67A
London SW7 2AZ, U.K. Web: www.sp.ph.ic.ac.uk/~sjs
+-------------------------------------------------------------------+
More information about the texhax
mailing list