# LaTeX is putting a border around my figures

I'm trying to embed a few images in a figure, but LaTeX keeps putting a border around three of the sides. Is there any way for me to keep it from adding this border?

The code that I used to create this figure:

\begin{figure}
\centering
\subfloat[Top View]{\label{fig:pat1a}\includegraphics[width=0.5\textwidth]{pat1a}}
\subfloat[Isometric View]{\label{fig:pat1b}\includegraphics[width=0.5\textwidth]{pat1b}}
\caption{Diagrams from Patent Application 12/475,048}
\label{fig:pat1}
\end{figure}


I have included the following packages in my project:

• lineno
• microtype
• verbatim
• hyperref
• array
• graphicx
• subfig

If there's anything that I have to do in each specific figure to prevent this border from appearing, that's fine. However, if there's one configuration thing that I can do at the beginning of the document, that would be even better.

-
Welcome to TeX.sx! Please add a full but minimal working example (MWE) that illustrates your problem. We need to also know which packages you are using. A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it) or press CTRL+K. –  Martin Scharrer Nov 13 '11 at 21:38
Please make sure that all images are uploaded using the official stackexchange interface, i.e. the image icon on top of the text field (shortcut: CTRL+G). This ensures that all images are always accessible and do not expire. –  Martin Scharrer Nov 13 '11 at 21:38
Sorry about those formatting mistakes. I've added a list of all of the packages I am using. I'll get to work on a minimal working example now. –  Serplat Nov 13 '11 at 21:47
What package did you use to produce the images? What format are they in (raster, like BMP/PNG/JPG, or vector, like EPS/PDF)? –  Werner Nov 13 '11 at 21:50
They're just PNG images, but apparently they had a transparent border around them. See my answer below. –  Serplat Nov 13 '11 at 21:54

This could be because your images include the border already, before including them. If this is the case, you can trim and clip some of the edges of the included image using the trim=<lx> <ly> <ux> <uy>,clip option of \includegraphics. This trims <lx> from the left, <ly> from the bottom, <ux> from the right and <uy> from the top in big points bp. Here is a minimal example showing this effect:

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\begin{document}
\begin{figure}
\includegraphics[width=0.3\linewidth,trim=4 4 4 4,clip]{patent.png}
\caption{Diagram from Patent Application 12/475,048}
\end{figure}
\end{document}


The image on the left is used unadjusted from a capture of your images (showing the original border included), while the image on the right has been trimmed/clipped by 4bp on all 4 sides (removing the added border).

-

I figured it out. I'm posting the solution here in-case anyone else has similar issues.

I had saved the images directly out of PowerPoint using "Save as Picture" in the Right-Click menu. This apparently puts a small 1 pixel transparent border around the images.

I suppose LaTeX doesn't render this border transparently, so it was drawing the gray border instead. Cropping the image to remove this transparent border solved my issues.

-
The cropping can also be performed within LaTeX. See my answer on how to do this. –  Werner Nov 13 '11 at 21:57
Awesome, thanks. –  Serplat Nov 13 '11 at 22:01

This also happens when you're using \floatstyle{boxed}. If that's the case the solution is to return to plain style:

\floatstyle{plain}
\restylefloat{figure}


As described in Floatstyle how to come back to the default theme

-

draw a box outside of the figure

\begin{figure}
\centering
\subfloat[Top View]{\label{fig:pat1a}\includegraphics[width=0.5\textwidth]{pat1a}}
\setlength\fboxsep{0pt}% distance from figure
\setlength\fboxrule{0.75pt}% border thickness
\fbox{
\subfloat[Isometric View]{\label{fig:pat1b}\includegraphics[width=0.5\textwidth]{pat1b}}
}
\caption{Diagrams from Patent Application 12/475,048}
\label{fig:pat1}
\end{figure}

-