我正在尝试使用以下语法将图形插入到我的 LaTeX 文件中:
\begin{figure}
\centering
\includegraphics [width=3in]{fig1.png}
\caption{Calculation of shortest path betweenness}
\label{Fig.3:Shortest path betweenness}
\end{figure}
以前我这样做是可行的,但这次我收到以下错误:
LaTeX Error: \begin{figure} on input line xxx ended by \end{document}
另外,将鼠标悬停在 Eclipse 中表示错误的红十字符号上,我看到了此消息
paragraph ended before Gin@iii was completed.
很明显,我必须\end{figure}
结束我的\begin{figure}
,所以我不明白为什么我仍然会收到那个错误。
有人能告诉我问题出在哪里吗?
编辑:添加更多调试细节。如果我删除“[width=3in]”,问题就消失了。以下是详细错误:
pdflatex> Runaway argument?
pdflatex> width=3in]{fig1.png} \caption {Caption} \label {Fig.1}
pdflatex> ! Paragraph ended before \Gin@iii was complete.
pdflatex> <to be read again>
pdflatex> \par
pdflatex> l.40
pdflatex>
pdflatex>
pdflatex> Underfull \vbox (badness 10000) has occurred while \output is active
pdflatex> (./document.bbl
pdflatex>
pdflatex> Package natbib Warning: Empty `thebibliography' environment on input line 3.
添加了示例代码:
\documentclass[10pt,psfig,letterpaper,twocolumn]{article}
\usepackage{geometry}
\usepackage{graphics}
\usepackage{setspace}
\usepackage{natbib}
\usepackage{verbatim}
\usepackage[scaled=0.9]{helvet}
\singlespacing
\paperwidth 8.5in
\paperheight 11in
\oddsidemargin 0in
\headsep 1.3cm
\geometry{left=0.75in,top=0.75in,right=0.75in,bottom=1in}
\textwidth 7in
\textheight 9.25in
\columnsep 0.4in
\footskip 0in
\renewcommand{\bibname}{REFERENCE}
\pagestyle{empty}
\begin{document}
\bibliographystyle{acm}
\title{\fontfamily{phv}\selectfont{\huge{\bfseries{Title here}}}} \author{
{\fontfamily{ptm}\selectfont{\large{\bfseries{author name}}}}\thanks{contact
info }}
\maketitle
\thispagestyle{empty}
\section*{\fontfamily{phv}\selectfont{\normalsize{\bfseries{Section name}}}}
\begin{figure}
\centering
\includegraphics[width=3in]{fig1.png}
\caption{Caption}
\label{Fig.1}
\end{figure}
\pagebreak[4]
\vspace*{5.52in}
\bibliography{ref}
\end{document}
答案1
问题似乎在于你加载
\usepackage{graphics}
代替
\usepackage{graphicx}
只有使用后一种声明,您才可以使用语法
\includegraphics[width=3in]{fig1.png}