2

I am a new-comer to latex, so I know that there may be a simple fix to this but I can't figure it out on my own. I'm using the following code to try to put a picture in my document.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[h]
     \centering
     \includegraphics[width=1\textwidth]{slide_20.jpg}
     \caption{Here is my image}
     \label{image-myimage}
\end{figure}
\end{document}

However, I keep getting this error:

! Package pdftex.def Error: File 'slide_20.jpg' not found.

I have saved the picture in the same folder as the .tex document. I'm working in TeXworks on a mac. I have tried it with multiple pictures and it never works.

  • Welcome to TeX SX! You don't even need to type the extension (unless there are files with the same name and another extension). Did you update recently? – Bernard Jul 12 '17 at 17:16
  • You should not use [h] as a placement specifier only! This might result in pretty bad placement especially with large figures. You should use something like [htbp] (only [h] most likely gets replaced by [ht] throwing a warning), but with big figures you should always include the [p] option, too. This way LaTeX tries to use h if that's not possible or results in very bad spacing it tries the next from the list and so on. p is necessary because if you use large figures it might happen that this one and all following figures are moved to the end of the document or chapter! – Skillmon Jul 12 '17 at 17:22
  • 1
    Also, if you intend to use the same placement specifier for all figures, you might as well set the default to the desired value. This is done with \makeatletter\renewcommand*{\fps@figure}{htbp}\makeatother. The same is possible for tables using \fps@table. – Skillmon Jul 12 '17 at 17:27
  • Are you sure you're using the correct extension? Perhaps the file is called *.jpeg and not *.jpg. Have you included the graphicx package in your preamble? We could help you more and better if you would post a complete MWE! – Skillmon Jul 12 '17 at 17:32
  • 1
    @Dr.ManuelKuehner That shouldn't be a problem, though. It usually works fine. (Spaces are different.) – cfr Jul 14 '17 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.