自动生成图片的引用是错误的

自动生成图片的引用是错误的

下面我为一些自动生成的图形生成标签

\usepackage{varioref}
\newcounter{figurecounter}\setcounter{figurecounter}{1}
\let\endF\endfigure
\renewcommand\endfigure{%
  \expandafter\label\expandafter{fig:item\thefigurecounter}\endF\stepcounter{figurecounter}}

For循环从文件夹创建图像

\newread\reader
\newcount\TotalFiles  


\makeatletter
\newcommand\IterateImages[2]{%
% #1: directory path with a trailing /
% #2: a list of file extensions: eps pdf jpg png
\immediate\write18{batch "#1" \jobname\space #2}
\openin\reader=\jobname.list\relax
\loop
    \read\reader to \filename
    \unless\ifeof\reader
    \filename@parse{\filename}
    %\section*{\filename}
    \begin{figure}[!htb]
    \begin{center}
            \includegraphics[scale=0.5]{"#1\filename@base"}
    \caption{{\bf This is a figure}
    \end{center}
    \end{figure}
    \endgraf
    \advance\TotalFiles1\relax
    \clearpage
\repeat
\closein\reader
}

调用附录中的for循环:

\appendix

\gdef\thesection{Appendix \Alph{section} -}
\section{List of figures}
\label{sec:app1}

\IterateImages{C:/Users/xxx/xx}{eps}

现在的问题是:调用时\vref{fig:item1}显示:

Figure Appendix A - on page 5

代替:

Figure 1 on page 5

有人知道如何解决这个问题吗??????? 使用 miktex、texlipse、win8、pdflatex

打电话时

\IterateImages{C:/Users/xxx/xx}{eps}

附录以外的图片编号正确

答案1

删除第一个代码块并使用:

\newread\reader
\newcount\TotalFiles  


\makeatletter
\newcommand\IterateImages[2]{%
% #1: directory path with a trailing /
% #2: a list of file extensions: eps pdf jpg png
\immediate\write18{batch "#1" \jobname\space #2}
\openin\reader=\jobname.list\relax
\newcounter{figurecounter}\setcounter{figurecounter}{1}
\loop
    \read\reader to \filename
    \unless\ifeof\reader
    \filename@parse{\filename}
    %\section*{\filename}
    \
    \vfill
    \begin{figure}[!htb]
    \begin{center}
            \includegraphics[scale=0.5]{"#1\filename@base"}
    \caption{{\bf text}
    \label{fig:item\thefigurecounter}
    \end{center}
    \end{figure}
    \vfill
    \
    \stepcounter{figurecounter}
    \endgraf
    \advance\TotalFiles1\relax
    \clearpage
\repeat
\closein\reader
}

相关内容