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?

Graphics with borders

The code that I used to create this figure:

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

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.

  • 4
    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
  • 1
    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:

enter image description here

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

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).

| improve this answer | |

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.

| improve this answer | |
  • 8
    The cropping can also be performed within LaTeX. See my answer on how to do this. – Werner Nov 13 '11 at 21:57

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


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

| improve this answer | |

I got rid of the same type of borders created by PowerPoint during export via "Save as Picture" by: opening the image in Paint and saving. After that the images (.png) were ok in LateX.

| improve this answer | |
  • Worked very well when borders were being added to images within images. Thanks. – Ahmed Akhtar Apr 11 at 15:33

I was able to remove the borders on a .png file by simply exporting them from PowerPoint to a .pdf file. If you have this option, this may be easier than cropping the image.

| improve this answer | |

If you have multiple subfigures having this issue in a composite figure, the best way to solve it is to make those subfigures have transparent background. Then the final pdf compiled by LaTeX wouldn't have these boundaries (for each of the subfigures).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.