# Is this possible to fix this requirement (explain briefly in this question)?

My code is as follows:

\documentclass{book}
\usepackage{lipsum}

\begin{document}
blah blah blah blah blah blah

\lipsum[1-2]

\begin{figure}
\includegraphics{...eps}
\caption{caption text}
\end{figure}

\lipsum[3-4]

\begin{figure}
\includegraphics{...eps}
\caption{caption text}
\end{figure}

\end{document}


My requirement is, I need to extract the figure number with its corresponding output page number also with its file name to an external Word/Excel file, e.g.,

Figure 1              Page 1             test.eps


Is it possible either in LaTeX or through any external possibilities? Please advise...

If I understood correctly, this should do it:

\documentclass{book}
\usepackage{lipsum}
\usepackage{graphicx}

\newwrite\imgdetail
\immediate\openout\imgdetail\jobname.imd

\let\LTXincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{%
\write\imgdetail{\figurename\space\thefigure, Page \thepage, #2}%
\LTXincludegraphics[#1]{#2}%
}

\begin{document}
blah blah blah blah blah blah

\lipsum[1-2]

\begin{figure}
\includegraphics{example-image-a}
\caption{caption text}
\end{figure}

\lipsum[3-4]

\begin{figure}
\includegraphics{example-image-b}
\caption{caption text}
\end{figure}

\end{document}


We allocate a write stream with \newwrite\imgdetail and open a file named \jobname.imd with \immediate\openout\imgdetail\jobname.imd.

Assuming you want to record all occurrences of \includegraphics (which, bear in mind, may or may not appear in a figure environment), we save the definition of \includegraphics in \LTXincludegraphics and redefine it to write the information to the .imd file:

\let\LTXincludegraphics\includegraphics
\renewcommand\includegraphics[2][]{%
\write\imgdetail{\figurename\space\thefigure, Page \thepage, #2}%
\LTXincludegraphics[#1]{#2}%
}


this results, with the MWE, in a file containing:

Figure 1, Page 1, example-image-a
Figure 2, Page 2, example-image-b


Depending on your use case you might want to do this exclusively for figures inside a figure environment, then you might do something like this:

\makeatletter
\renewcommand\includegraphics[2][]{%
\def\@tempa{figure}%
\ifx\@currenvir\@tempa
\write\imgdetail{\figurename\space\thefigure, Page \thepage, #2}%
\fi
\LTXincludegraphics[#1]{#2}%
}
\makeatother


still it wouldn't work if, for instance, you used in a subfigure environment.

• Thanks, you understood the requirement exactly, and you are so great; very much pleaused with your solution and with very quick short time... thanks a lot... – MadyYuvi Oct 11 '18 at 13:20