1

I'm new to LaTeX and currently trying to write myself a report template that I can use for future work.

Anyway, here is a MWE showing the error:

\documentclass[12pt,twoside,a4paper]{article}
\usepackage{graphicx}

\begin{document}
\begin{figure}[ht]
  \centering
  \includegraphics[width=\linewidth]{epsFig}
  \caption{This is where a caption would go. Include the image in the folder of the project, the image must have a .eps file format.}
  \label{fig:example}
\end{figure}
\end{document}

And the output ends up looking like this:

enter image description here

That is, there's not enough space on the previous page to place the image so it is moved on to the next page, but it ends up at the bottom left of the page covered by the caption.

The image was created using MatLAB, I use TexnicCentre with Miktex2.9. Can anyone help?

edit: The file extension for the image is .eps The image is at this link

5
  • 3
    Welcome to TeX.SX! Your example should be alright in terms of the code. In fact: when I run your example using \usepackage[demo]{graphicx} I (fortunately) don't get the figure misplaced as in your document. Hence, I think we need more context here. Are you really running only the given example as it stands? Is your MatLAB plot a pdf? Does it contain whitespace in the top and in the right?
    – Ruben
    Jul 20 '15 at 15:44
  • I'm almost sure that the problem is related with the bounding box of the image.
    – Sigur
    Jul 20 '15 at 15:51
  • @Ruben What I've included is only a small section of the full thing, I figured that I'd just include the relevant bits. The plot is a .eps, I've done some reading and problems with the file produce by MatLAB seems to be a common issue :(. Thanks for replying.
    – Gavin
    Jul 20 '15 at 17:21
  • @Gavin: Consider following these steps: How to fix EPS with incorrect bounding box? That is, you can include the single image as part of a standalone document with border=0pt. This should correct the bounding box, after which you can include the updated image as part of your original document.
    – Werner
    Jul 20 '15 at 17:38
  • clicked the wrong dupe obviously.
    – percusse
    Jul 20 '15 at 18:55
0

I have a solution, the problem is that I'm not particularly proud of it. Matlab appears to have a problem saving .eps files. The only way around this that I have found is to save a figure with a different extension (say, .png) and then convert to .eps using Inkscape or something similar.

1
  • It therefore seems like this problem is unrelated to TeX - LaTeX.
    – Werner
    Jul 20 '15 at 18:26

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