0

I have tried the following code with various alterations to the positioning index:

\begin{figure}[!ht]
\includegraphics[width=5cm,trim={0 0cm 0 0cm},clip]{Img/CustomerDevelopment.pdf}
\centering
\caption{The figure shows an example of how a customer changes the policies affiliated with the company and how that changes his segment over his first 3 years.}
\label{fig:CustomerDevelopment}
\end{figure}

However, whatever I do my figure will always go to the end of the chapter and I would like them to stay near the text. If I open the PDF-document in Adobe Reader and save it as a .png that I then import in LaTeX it works perfectly. I would like the PDF-format though seeing as I want to be able to zoom in on the figures.

Does anyone know how to solve this so I can use .pdf?

I've included an image below using the \fbox{ command to illustrate the issue.

enter image description here

pir
  • 301
  • 2
  • 10
  • 1
    [!ht] prevents latex putting the figure on a float page so makes it going to the end of the document more likely. You should always include p. The format has no bearing on the float positioning so presumably your pdf file makes an image of greater height than the png. – David Carlisle Jun 19 '14 at 18:44
  • Thanks. I've now tried p and setting the width of the image to 1cm with keepaspectratio = true. However, it is now a really small figure, but still at the end of the chapter. – pir Jun 19 '14 at 18:49
  • put \fbox{} around the includegraphics to show you the extend of tehe image, it is probably taller than you expect – David Carlisle Jun 19 '14 at 19:04
  • Using \fbox{} I find that the image height is roughly 1/10 of the page height. Therefore, I guess that the height is not the issue :) – pir Jun 19 '14 at 19:29
  • The height is the only issue as that is the only feature of the includegraphics that affects the float position. The height when you include the pdf must be different from the height when you include the png – David Carlisle Jun 19 '14 at 19:46
  • I've tried to illustrate the issue in the orignal post. The box around the image created by the new command is quite small. When opening the pdf in my pdf-viewer the dimensions stated are also quite small. Also, I've tried setting the height directly in LaTeX. What else can I do to examine the issue further? – pir Jun 19 '14 at 19:55
  • Your fbox shows that the bounding box in your pdf file is all wrong. Presumably if you did the same with the png file the box would be close around the image. and the float would be considerably less tall – David Carlisle Jun 19 '14 at 20:01
  • Yes, the bounding box is close around the image for the png. However, with the [p] option the png image is also moved to the end of the chapter. Does this tell you something that can narrow down the issue? Would it help if I tried to upload my preamble? – pir Jun 19 '14 at 20:09
  • well simplest is to fix the pdf file that you are including – David Carlisle Jun 19 '14 at 20:35
  • Hmm.. it doesn't seem possible even with other pdf-printer. Sadly, I think I will stick to png-files. – pir Jun 19 '14 at 21:48
  • well no need for pngs you can correct manually using the graphicx options eg actually use the trim argument to trim the spurious space or simply put \vspace*{1cm}before the\includegraphics` to account for the white space in the pdf file. – David Carlisle Jun 19 '14 at 22:08
  • I tried to use the trim argument, but I have to use XeLatex, which doesn't support it. I will try using vspace! – pir Jun 20 '14 at 08:04

0 Answers0