4

Firstly and fore-mostly I am a complete new comer to the world of LaTeX and so please do bear with me. I will try to be as accurate as I can but if you need any more info please let me know.

All I want is to figure out how to import a graphic into LaTeX (MacTeX).

I am using the following in my code:

\documentclass[10pt,a4paper,draft]{report}
\usepackage{graphicx}

Then in my document section I'm using

\begin{figure}
\includegraphics[width = 50mm]{Name.jpg}
\caption{Label}
\end{figure}

Once I compile the document, the area for the picture has been allocated but there is no image, I have tried .png and .pdf files also.

I know that this is a very simple question and I hope there is a simple solution but I cannot find anything on the net about this (which may mean I'm being dim).

Also I'm using Latexian but I have tried 4 different editors and it doesn't work in any.

7
  • In order to include a JPG image, you cannot compile using latex. You need to compile with a different compiler - pdflatex, for example.
    – Werner
    Commented Feb 16, 2012 at 7:29
  • Are you specifying the draft option with \documentclass?
    – egreg
    Commented Feb 16, 2012 at 9:09
  • 2
    You should always make small but complete examples like the one of Peter instead of sending code snippets. This will avoid that you left out important informations (like "are you using draft or not?"). You should also look in the log-file if there are errors or messages. If you don't understand the log: make it available on the net (remove confidential informations like your name if necessary but let everything else untouched). Commented Feb 16, 2012 at 11:07
  • Thank you everybody, It was in fact, that I was using the draft tag (this was automatically added to the preamble using a wizard). I apologise for not including the full code I was using. I was trying to be as specific as possible (due to the big ugly warning I got prior to posting the question) but unfortunately this back-fired. I do however know this for the future and will always try to include as much as I can. I suspect that as I become more acquainted with this very nice piece of software I will become more efficient at portraying my difficulties. Thanks again, your help is much apprecia
    – DazBaldwin
    Commented Feb 16, 2012 at 19:00
  • As suggested below I have now added the \documentclass that was causing the issue, when draft was changed to final, all worked
    – DazBaldwin
    Commented Feb 16, 2012 at 21:15

1 Answer 1

7

In the same directory where I have the file with the code below I have the file EiffelTowerNight.jpg. Typesetting the code below with pfdlatex results in the image being produced:

enter image description here

Notes:

  • If you add the demo option to the graphicx package as in \usepackage[demo]{graphicx} then this will be displayed as

    enter image description here

  • If you use the draft option to the class as in \documentclass[draft]{article}, then this will be displayed as:

    enter image description here

Code:

\documentclass{article}
\usepackage{graphicx}

\begin{document}
\begin{figure}
    \centering
    \includegraphics[width = 50mm]{EiffelTowerNight.jpg}
    \caption{Label}
\end{figure}
\end{document}
4
  • I believe that if you leave the file extension off (.jpg, .pdf, etc), assuming you have the appropriate versions of your image file available, both the latex and pdflatex compilers will search for their 'preferred' image format and insert the image. I have done this successfully but do not have the TeX code on hand. Drop me a response if you'd like me to dig it up. Commented Feb 16, 2012 at 14:06
  • 1
    In view of the OP's comment, would you add the information about the draft option in \documentclass, that can be countermanded calling graphics with the final option?
    – egreg
    Commented Feb 16, 2012 at 19:07
  • let me know if you want anything else adding
    – DazBaldwin
    Commented Feb 16, 2012 at 21:15
  • @egreg: Added two failure modes: draft option for \documentclass and demo option for graphicx. Commented Feb 17, 2012 at 0:32

You must log in to answer this question.

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