# undefined control sequence \includegraphics

I write my text in Mac OS X and every thing was fine but when I want compile my code with Winedt in Windows 7 Environment I got this error:

undefined control sequence \includegraphics[width=0.30/textwidth]{Hypercube}


I change \ to / but Still got the error. And also I use package graphicx.

% GRAPHICS RELATED PACKAGES
%
\ifCLASSINFOpdf
\usepackage[pdftex]{graphicx}
% declare the path(s) where your graphic files are
\graphicspath{{../pdf/}{../jpeg/}{./image/}}
% and their extensions so you won't have to specify these with
% every instance of \includegraphics
\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.jpg}
\else
% or other class option (dvipsone, dvipdf, if not using dvips). graphicx
% will default to the driver specified in the system graphics.cfg if no   % driver is specified.
% \usepackage[dvips]{graphicx}
% declare the path(s) where your graphic files are
% \graphicspath{{../eps/}}
% and their extensions so you won't have to specify these with
% every instance of \includegraphics
% \DeclareGraphicsExtensions{.eps}
\fi

\begin{figure}[htpb]
\label{Figure::Hypercube}
\begin{center}
\includegraphics[width=0.30/textwidth]{Hypercube}
\caption{a Hypercube with 8 nodes}
\end{center}
\end{figure}

• You need \textwidth since that refers to the width of the text block. /textwidth does not exist. – Werner Aug 14 '11 at 6:36
• @Werner I change it to \textwidth but got the same error! – Am1rr3zA Aug 14 '11 at 6:46
• @Am1rr3zA: put the \label{..} after the caption otherwise your reference will be wrong – user2478 Aug 14 '11 at 6:51
• You should provide a Minimal Working Example to make others to reproduce the problem. And don't change the error message, just copy it. – Leo Liu Aug 14 '11 at 9:24

use it this way:

\ifCLASSINFOpdf
\usepackage[pdftex]{graphicx}
% declare the path(s) where your graphic files are
\graphicspath{{../pdf/}{../jpeg/}{./image/}}
% and their extensions so you won't have to specify these with
% every instance of \includegraphics
\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.jpg}
\else
% or other class option (dvipsone, dvipdf, if not using dvips). graphicx
% will default to the driver specified in the system graphics.cfg if no   % driver is specified.
\usepackage[dvips]{graphicx}
% declare the path(s) where your graphic files are
\graphicspath{{../eps/}}
% and their extensions so you won't have to specify these with
% every instance of \includegraphics
% \DeclareGraphicsExtensions{.eps}
\fi


or even better, use for the complete above code only

\usepackage{graphicx}


and give the path with the image name

\includegraphics{pdf/image}

• it doesn't solve my problem. – Am1rr3zA Aug 14 '11 at 6:30
• then make a complete example and do not show only fragments of the code ... – user2478 Aug 14 '11 at 6:49
• @Am1rr3zA: Herbert's answer allows the compiler to switch between certain settings/options used by the graphicx package. This depends on whether you compile following a latex->dvips or pdflatex sequence. Which are you using? – Werner Aug 14 '11 at 6:58
• @Herbert I can't put all the code here, and also when I open the file with TeXWork everything is ok. I just have problem with WinWdt. – Am1rr3zA Aug 14 '11 at 6:59
• @Am1rr3zA: Then it is assumed that Hypercube has an extension .pdf, .jpeg, .png, .jpg and is located in the main .tex folder, or in ../pdf/, ../jpeg/, or image/. If this is the case, then undefined control sequence could refer to something else. Either way, as always, provide more context by means of an MWE. – Werner Aug 14 '11 at 7:07

I faced the same problem. I wrote the \usepackage command after the \begin{document}, which was giving this error.

\documentclass[a4paper,12pt]{article}
\usepackage{graphicx}
\graphicspath{ {images/} }
\begin{document}


is the right way.