How to add border for an image?
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.
I've found that \frame{\includegraphics{image}}
command works for my case.
You need more fancy frame? The settings that you can adjust:
\fboxsep=10mm%padding thickness
\fboxrule=4pt%border thickness
and
%\fcolorbox{bordercolor}{paddingcolor}{image}
\fcolorbox{red}{yellow}{\includegraphics[width=0.5\linewidth]{foobarbaz}}
\documentclass[demo]{article}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{blindtext}
\fboxsep=10mm%padding thickness
\fboxrule=4pt%border thickness
\begin{document}
\blindtext
\begin{figure}[hbtp]
\centering
%\fcolorbox{bordercolor}{paddingcolor}{image}
\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}