# How to add border for an image?

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.

-

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}}%
}%

% ...
% or

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.

-
Thanks, \frame works better for me, because I don't need any margin between image and line. –  TheBug Jun 13 '11 at 20:15
I now programmed a frame option for \includegraphics. It will be released with the next package update of adjustbox. –  Martin Scharrer Jul 22 '11 at 8:16
Pleasen i ask if it's possible to have rounded border corners? and how ? thank you. –  researcher Sep 8 '12 at 11:49
@researcher: For rounded corners you need to use TikZ or PS-Tricks. See also How to draw frame with rounded corners around box. –  Martin Scharrer Sep 8 '12 at 12:16

You need more fancy frame? The settings that you can adjust:

\fboxrule=4pt%border thickness

and

\fcolorbox{red}{yellow}{\includegraphics[width=0.5\linewidth]{foobarbaz}}

\documentclass[demo]{article}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{blindtext}

\fboxrule=4pt%border thickness

\begin{document}

\blindtext

\begin{figure}[hbtp]
\centering
\fcolorbox{red}{yellow}{\includegraphics[width=0.5\linewidth]{foobarbaz}}
\caption{This is a black box for demo purpose.}
\label{fig:foobarbaz}
\end{figure}
\blindtext
\end{document}
-
Thanks for such complete example, it will help me with my next experiments. –  TheBug Jun 14 '11 at 15:26