\documentclass{article}\usepackage{graphicx}\usepackage{caption}\usepackage{subcaption}\usepackage{tikz}\usepackage{pgfplots}\usetikzlibrary{spy,calc}\usepackage{hyperref}\newif\ifblackandwhitecycle\gdef\patternnumber{0}\pgfkeys{/tikz/.cd,zoombox paths/.style={draw=orange,very thick},black and white/.is choice,black and white/.default=static,black and white/static/.style={draw=white,zoombox paths/.append style={draw=white,postaction={draw=black,loosely dashed}}},black and white/static/.code={\gdef\patternnumber{1}},black and white/cycle/.code={\blackandwhitecycletrue\gdef\patternnumber{1}},black and white pattern/.is choice,black and white pattern/0/.style={},black and white pattern/1/.style={draw=white,
Here’s an example of using the spy
library. I’ve written a couple of styles that can be used to create an array of magnficiations, with an arbitrary number of rows and columns, placed on any side of the original image, with specifiable gaps. The magnifications will take up the same space as the original image.
The image itself and the magnifications are subcaptionbox
es, which requires the subcaption
package. They are assigned labels of the form <figurename>-image
and <figurename>-zoom
, and can be referenced using \ref
and \subref
. If no figurename
is supplied as an option to the tikzpicture
, a default name of zoombox
will be assumed.
The center points of the magnifications are specified in relative coordinates: \zoombox{0,0}
would zoom in on the lower left corner, \zoombox{1,1}
on the upper right.
You can specify the zoom factor for the individual zoomboxes using the optional argument: \zoombox[magnification=5]{0.5,0.5}
would zoom in on the middle of the image, magnifiying 5x.
Boxes and magnifications can be drawn with a coloured frame using the optional argument [color code=<color>]
.
To display a grid over the original image to aid in placing the zoom points, use the option help grid
in the image node.
Instead of using colors, black and white dash patterns can be used with the option black and white
. This overrides color code
options. To automatically use a different dash pattern for every box, use black and white=cycle
.