8.2 Manipulating graphical objects in LaTeX
In the previous section we discussed how to load external graphic files and what LaTEX offers to hide or at least encapsulate system-dependent aspects of the loading process. After loading, such images are simply boxes without any inner structure to LaTEX. In this section we now look at general manipulation possibilities for boxes. The functions offered can be applied to any LaTEX box and not just to those holding an external image.
We start with the commands offered by the standard graphics and graphicx packages and discuss scaling, rotating, and similar operations. After a brief look at the rotating package we then examine the overpic package, which marries the \includegraphics mechanism with that of a LaTEX picture environment. This offers an easy, yet powerful, way to annotate images with text and line graphics, like arrows, etc. We conclude with an evaluation of the adjustbox package that provides box manipulation possibilities with a powerful and convenient key/value syntax.
8.2.1 Image and box manipulations with graphics and graphicx
In addition to the \includegraphics command, the graphics and graphicx packages implement a number of graphical manipulation commands. With the exception of the command, which supports a key/value syntax in the graphicx package, the syntax for these commands is identical in both packages.
8.2.2 overpic - Graphic annotation made easy
Sometimes there is a need to annotate a graphic with some text, mark some regions or point to areas with arrows, etc. This can be easily achieved by overlaying the graphic with a picture environment and then adding your annotations with a suitable set of commands. The difficulty with this approach is finding the correct coordinate values, and for this the overpic package by Rolf Niepraschk is a great help.
8.2.3 adjustbox - Box manipulation with a key value interface
When using graphicx, the commands \includegraphics and offer a key/value interface. However, the keys supported by are quite limited, and for other box commands no such interface is available at all, even though keys such a trim or clip could be useful occasionally.
This missing functionality is made available by Martin Scharrer’s adjustbox package. The present section covers only the more important aspects of the package; further detail can be found in the extensive documentation [178].
The main command offered is , which can act as a replacement for all standard box commands, such as , , etc.; the color box commands, such as \colorbox; the graphics box commands, e.g., , ; and probably further commands offered by other packages. Mimicking as well as extending these commands is done by supplying the right set of keys.