My thesis contains many different types of images, namely EPS (from Matlab), PDF (from multiple sources), and PNG/JPEG photos. I am using Texstudio and graphix \includegraphics to import my images.

For several weeks, I have been using the 'default' Texstudio compile chain (pdfLatex), but started noticing that epstopdf package (which I use to import my EPS images) is clipping the right side of my images off. From my searching, it seems that this is a semi-known issue. Besides my images being clipped on the side, I have no other issues or compilation errors.

From my searching on this site and others, I changed my compiler from pdfLatex to Latex>dvips>ps2pdf. So far, this seems to work well for my EPS images, and does not crop my images. However, it won't compile when I try to include any other image format (PDF or PNG). When I try to compile and import PDF or PNG images, I receive an error: Cannot determine size of graphic...

From my searching, it seems that the Latex compiler cannot determine the image size, whereas the pdfLatex compiler can. However, pdfLatex does not create the DVI file needed for the DVI>PS>PDF chain.

I cannot figure out how to successfully compile my document and include all my image types. I really prefer to not have to manually enter in image sizes or trim margins for imported images.

What is the best/recommended approach to fix these issues?

  • 3
    no idea why epstopdf is clipping the image, it isn't a general problem. However there really is no need to rely on on-the-fly conversion, you can convert your eps to pdf using any tool (eg imagemagic convert) or anything else that can read the eps, and then include pdf rather than eps into the document Commented Feb 28, 2017 at 22:00
  • That's true...I can easily convert the eps to pdf manually using Illustrator or any tool. What I didn't mention is that I'm motivated to maintain on-the-fly conversion due to my Matlab>Thesis workflow. Currently, all I have to do is make changes in Matlab, re-run my script, and recompile my latex document and it all updates automatically. It's not a "must-have", but a "would-like-to-keep-it-this-way" thing.
    – Joshua
    Commented Feb 28, 2017 at 22:09
  • If you can make an eps available somewhere (dropbox or similar) perhaps we could see why it's being being clipped, perhaps the bounding box is wrong. Commented Feb 28, 2017 at 22:10
  • note if you use a commandline tool such as imagemagic (or even epstopdf) you can integrate that in to your script between matlab and the pdflatex run, but if the bounding box is wrong they may all clip the same way. Commented Feb 28, 2017 at 22:50
  • I've just realized that what I thought I was looking at as the bounding box in Illustrator was not correct. Using GSview, I see that epstopdf is cropping right at the bounding box, and Matlab is actually placing the bounding box "inside" the right-most border. So it seems to be a Matlab problem. Thanks for the info.
    – Joshua
    Commented Mar 1, 2017 at 0:53

1 Answer 1


For those who see this later:

It seems to be a relatively common issue where Matlab Figure > EPS file > Latex results in slightly cropped images in the final document. It appears that this is the fault of Matlab not correctly configuring the EPS bounding box when saving. In my case (Matlab R2015a), this happens whether "print" or "saveas" is used in Matlab.

I have found a solution that works for me: using the "-loose" switch on the print command. This instructs Matlab to have a "loose" bounding box which adds just the right amount of whitespace on each side. This is the exact line of code I use to save an EPS from the active figure:

print -depsc2 -loose myepsfile.eps;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .