# Border around includegraphics

Seems like the problem of border around includegraphics has already been brought up. But none of the solutions worked for me. Here's how my border looks like: And here's the code:

\documentclass{article}
\usepackage{graphicx}
\usepackage{xcolor}
\begin{document}
lsdfjgofgkogkof kgdpgokfdgkdfog pdkpgodkgpodkg pfgkdgkdpgkf dgod k fpgkfdgdpfgod fkgdfgpdokfgop dkgpodkgop dkg dpgdkf gdkpdkog\\
\fbox{\includegraphics[center,cfbox=blue 1pt 1pt,fbox,frame]{name.png}}\\
kfogkdfpogkdf kpfogkfdpogdkf opdfkgpofdkgpodf kpofdgkopfdkgpdfk gpdfokgodfpk gdfopkgpofdkgodpfk pdofgk dfpk dgpokfgdfopgkdpf kpofg podfkgd pfokpfdgkpodfg
\end{document}


I'd be even more grateful if you could add in the comment how to better center the image as well. The above is the closest I could get to centered image.

• I don't know why but center produces a shorter frame. – Ignasi Apr 26 '16 at 15:37

Just try this:

\fbox{\includegraphics[width=\textwidth,center,cfbox=blue 1pt 1pt,fbox,frame]{name.png}}


Put "width" as first option in your includegraphics.

Another idea is to change margins just for the image using package changepage, like this:

In preamble put:

\usepackage{changepage}

An then use it adjusting relative to previous margin:

\begin{adjustwidth}{-1cm}{-1cm}
\fbox{\includegraphics[center,cfbox=blue 1pt 1pt,fbox,frame]{name.png}}