未定义控制序列 \includegraphics

未定义控制序列 \includegraphics

我在 Mac OS X 中编写文本,一切正常,但是当我想在 Windows 7 环境中使用 Winedt 编译代码时,出现此错误:

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

我改为\/仍然出现错误。而且我还使用了包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}

答案1

你可以用以下代码替换整个代码块

\usepackage{graphicx}

并给出图像名称的路径

\includegraphics{pdf/image}

或者按如下方式使用该块:

\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

答案2

我遇到了同样的问题。我\usepackage在后面写了命令\begin{document},但出现了此错误。

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

才是正确的做法。

相关内容