[Tex/LaTex] pdfLatex vs Latex>DVI>PS>PDF for EPS, PDF, PNG images (Texstudio)

epsgraphics

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?

Best Answer

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;
Related Question