[Tex/LaTex] How to add border for an image

borderframedgraphicsincludegraphics

I use \includegraphics command to insert image to the document. But how can I add a border around this image w/o any margin between border lines and image?
It seems to be very easy, but I can't find it in the documentation.

Best Answer

You can add a frame around it by placing it inside a \fbox{...} command.

\fbox{\includegraphics[options]{image}}

The distance can be set by changing the \fboxsep length and the line width with the \fboxrule length, e.g. to draw a tight 1pt thick rule around the image use:

{%
\setlength{\fboxsep}{0pt}%
\setlength{\fboxrule}{1pt}%
\fbox{\includegraphics[options]{image}}%
}%

Using a recent version of my adjustbox package you can use:

\usepackage[export]{adjustbox}
% ...
\includegraphics[<your options>,frame]{image}% tight frame
% or 
\includegraphics[<your options>,fbox]{image}% Like normal \fbox

There is also cframe and cfbox for colored frames. All of these allow for multiple optional values, e.g. frame=<rule width>. See the manual for more information.

Related Question