如何使用 miktex 将图像插入 Latex IEEE 文档?

如何使用 miktex 将图像插入 Latex IEEE 文档?

我希望将我的1.png图像包含到 LaTeX 文档中,但是在使用以下命令时出现错误:

\begin{figure}
\centering
    \includegraphics{1.png}
\caption{Figure 1: A picture of the same gull looking the other way! }
\label{fig:verticalcell}
\end{figure}

或者

\usepackage{graphicx}
\graphicspath{{../pdf/}{C:\Users\User\Desktop\IEEE_CS_Latex\1.png}}

这是我的路径:C:\Users\User\Desktop\IEEE_CS_Latex\1.png

更新:

\documentclass[conference]{IEEEtran}
\usepackage{graphicx}

\begin{figure}
\centering
    \includegraphics{\graphicspath{1.png}
\caption{Figure 1: A picture of the same gull looking the other way! }
\label{fig:verticalcell}
\end{figure}

更新2:

\begin{figure}[!t]
\centering
\includegraphics[width=2.5in]{1}
% where an .eps filename suffix will be assumed under latex, 
% and a .pdf suffix will be assumed for pdflatex; or what has been declared
% via \DeclareGraphicsExtensions.
\caption{Simulation Results}
\label{fig_sim}
\end{figure}

更新3: 在此处输入图片描述

更新4:

% *** GRAPHICS RELATED PACKAGES ***
%
\ifCLASSINFOpdf

\usepackage[pdftex]{graphicx}
% declare the path(s) where your graphic files are
\graphicspath{{../1/}{../png/}}
% and their extensions so you won't have to specify these with
% every instance of \includegraphics
\DeclareGraphicsExtensions{.png}
\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
% graphicx was written by David Carlisle and Sebastian Rahtz. It is
% required if you want graphics, photos, etc. graphicx.sty is already
% installed on most LaTeX systems. The latest version and documentation can
% be obtained at: 
% http://www.ctan.org/tex-archive/macros/latex/required/graphics/
% Another good source of documentation is "Using Imported Graphics in
% LaTeX2e" by Keith Reckdahl which can be found as epslatex.ps or
% epslatex.pdf at: http://www.ctan.org/tex-archive/info/
%
% latex, and pdflatex in dvi mode, support graphics in encapsulated
% postscript (.eps) format. pdflatex in pdf mode supports graphics
% in .pdf, .jpeg, .png and .mps (metapost) formats. Users should ensure
% that all non-photo figures use a vector format (.eps, .pdf, .mps) and
% not a bitmapped formats (.jpeg, .png). IEEE frowns on bitmapped formats
% which can result in "jaggedy"/blurry rendering of lines and letters as
% well as large increases in file sizes.
%
% You can find documentation about the pdfTeX application at:
% http://www.tug.org/applications/pdftex

答案1

一般来说,在 LaTeX 中包含图形时你应该:

  • 不提供文件扩展名(将自动尝试已知扩展名的范围)
  • 仅使用相对路径,最好不要在加载图形的地方这样做
  • 使用斜线作为路径甚至在 Windows 上

对于图形位于同一目录(文件夹)的常见情况,这意味着事情通常很简单

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
  \centering
  \includegraphics{1}
  \caption{Some figure}
\end{figure}
\end{document}

其中figure需要环境来允许浮动和字幕(但不需要“在此处”插入图形:常见的误解)。

另一个常见情况是在主文档目录的子目录中有图形:类似于figures,,graphics...:

\documentclass{article}
\usepackage{graphicx}
\graphicspath{{figures/}}
\begin{document}
\begin{figure}
  \centering
  \includegraphics{1}
  \caption{Some figure}
\end{figure}
\end{document}

请注意,\graphicspath在序言中使用了,并且每个路径都应包含在括号中,并/在末尾用于细分和。(并不是每个人都热衷于\graphicspath,但对于我所概述的每个文档图形目录的情况,我认为它效果很好)。

这些说明适用于大多数文档类别(少数奇怪的说明故意干扰此过程的某些部分,但总体而言,它们并不常见并且设计确实不太好!)。

答案2

% *** GRAPHICS RELATED PACKAGES ***
%
\ifCLASSINFOpdf
  \usepackage[pdftex]{graphicx}
  % declare the path(s) where your graphic files are
  \graphicspath{{../pdf/}{../jpeg/}}
  % and their extensions so you won't have to specify these with
  % every instance of \includegraphics
  \DeclareGraphicsExtensions{.pdf,.jpeg,.png}
\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

使用这些行。这些行在 IEEE 示例 LaTeX 文件中被注释。

答案3

解决方案是获取所需的图形而不是方框,以图形名称命名,非常简单:只需在“会议模式”中使用 IEEE 格式,即而\documentclass[conference]{IEEEtran}不是“草稿模式” \documentclass[draft]{IEEEtran}。我正在使用这种方式,它 100% 有效。

相关内容