3

I am trying to insert some ready image-pdf files to my LaTeX code but failed. My code is

\documentclass[a4paper,12pt]{book}
\usepackage{graphicx}
\graphicspath{{/Cathay/Desktop/build/Cathay1/}{C:\Users}}
\begin{figure}
\centering
\includegraphics[height=5cm]{Cathay1.pdf}
\caption{text}
\end{figure}
\end{document}

The pic didn't show up after I put this code. Instead, the text follows this code just disappeared. Could anyone tell me the right code for inserting this pdf?

4
  • What is the error you are getting? Oct 16, 2013 at 3:28
  • Sorry for being unclear---what is it that LaTeX says is wrong? It'll say something like ! ERROR ... (or something of the sort, errors typically begin with a !). Oct 16, 2013 at 3:32
  • 1
    Guess: Could you include/host the Cathay1.pdf image pdf file in the Q, if it's in proper condition (How was it generated by some external software ?) Oct 16, 2013 at 3:55
  • 2
    Did you forget the '\begin{document}' command?
    – Jesse
    Oct 16, 2013 at 6:19

3 Answers 3

4
  • In command \graphicspath{}, you must use slash (/) instead of backslash (\) to list directories. In your case, \graphicspath{{/Cathay/Desktop/build/Cathay1/}{C:/Users/}} is right.
  • You forget the \begin{document} command.
  • We need to know the ERROR you have just got, in order to understand what happened on your system more clearly.
1

To diagnose your problem, first disable \graphicspath, put the PDF image in the same directory in which your TeX input file exists, make sure you compile with pdflatex. What happens?

If you can get the desired output then there might be a problem in the path from which pdflatex attempted to retrieve the image. Make sure the path is accessible.

0

Use the command pdfcrop to reset your PDF file, just like this: pdfcrop Cathay1, then you will get a file named Cathay1-crop.pdf. The graphics will appear and everything will be Ok when using the file Cathay1-crop.pdf. By the way, the postfix .pdf can be ommitted in your figure environment.

You must log in to answer this question.

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