Adding a frame to an image
You can add a simple frame to an image or to text by using the \frame{...}
, \framebox{...}
, or \fbox{...}
commands. However, this would give a simple box with thin black lines and a certain distance to the content. How about changing the color, line thickness, or distance? The classic way to do the latter is by changing the LaTeX lengths \fboxrule
and \fboxsep
. It's a bit laborious, especially when the lengths can vary. It can be made easier.
How to do it...
We will load the adjustbox
package. It provides several useful commands for modifying boxes. It implicitly loads the graphicx
package and exports its own features to the \includegraphics
command. Follow these steps:
Load the
xcolor
package:\usepackage{xcolor}
Load the
adjustbox
package with theexport
option:\usepackage[export]{adjustbox}
At the place in your document where the image is to be placed, use the
\includegraphics
command, like in the previous recipe. This time, add thecframe
option:\includegraphics...