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:

  1. Load the xcolor package:
    \usepackage{xcolor}
  2. Load the ...

Get LaTeX Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.