I think nowadays one should drop the extension for image files completely and do only \includegraphics{<file-name-sans-extension>}
. The used engine will pick up the right file acc. to the extensions described in \Gin@extensions
in .def
files provided by LaTeX support for color and graphics. If you use C-c C-c within AUCTeX, you can control the engine with Options for TeX Processors described in the manual.
A general approach to parse the argument of \includegraphics
over possible master and child files would be to use the built-in parser in AUCTeX. I suggest to write a style file for this purpose which can look like this:
;;; includegraphics-parser.el --- Dummy AUCTeX style to parse argument
;;; of \includegraphics
;;; Code:
;; Needed for auto-parsing.
(require 'tex)
(TeX-auto-add-type "includegraphics-parser" "LaTeX")
(defvar LaTeX-includegraphics-parser-regexp
'("\\\\includegraphics\\*?\\(?:\\[[^]]*\\]\\)?{\\([^}]+\\)}"
1 LaTeX-auto-includegraphics-parser)
"Matches the mandatory argument of \\includegraphics.")
(defun LaTeX-includegraphics-parser-auto-prepare ()
"Clear `LaTeX-auto-includegraphics-parser' before parsing."
(setq LaTeX-auto-includegraphics-parser nil))
(defun LaTeX-includegraphics-parser-auto-cleanup ()
"Search for \"eps\" in parsed arguments of \\includegraphics."
(when (string-match "\\.eps"
(mapconcat #'car (LaTeX-includegraphics-parser-list) "|"))
(message "Found eps file extension")
(sit-for 2)))
(add-hook 'TeX-auto-prepare-hook #'LaTeX-includegraphics-parser-auto-prepare t)
(add-hook 'TeX-auto-cleanup-hook #'LaTeX-includegraphics-parser-auto-cleanup t)
(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
(TeX-add-style-hook
"includegraphics-parser"
(lambda ()
;; Make sure graphicx.el is loaded
(TeX-run-style-hooks "graphicx")
;; Hook into AUCTeX parser
(TeX-auto-add-regexp LaTeX-includegraphics-parser-regexp))
LaTeX-dialect)
;;; includegraphics-parser.el ends here
Set the variable TeX-style-private
to a directory of your choice, e.g.:
(setq TeX-style-private "~/.emacs.d/mystyles")
and save includegraphics-parser.el
there.
Customize TeX-parse-self
to t
and restart Emacs.
Put something like this in your .tex file
\iffalse
\usepackage{includegraphics-parser}
\fi
and hit C-c C-n to reparse your file.