In my .profile-file I have a setting like:

export TEXINPUTS=$TEXINPUTS:/home/myuser/projects/images//
  • If I try to include an image by using (TeX-insert-macro "includegraphics"), auctex is in the directory where my current latex file is by default. However I want to be it by default in the directory /home/myuser/projects/images/.

  • If I include then an image from this dir it gives includes the whole path. But this isn't desired since I have set the TEXINPUTS variable. So how can I change this such that it only inserts the filename and not the whole (relative) path?

Edit As suggested by @giordano, setting LaTeX-includegraphics-read-file to LaTeX-includegraphics-read-file-TeX should make it work. However in this case the solution in https://emacs.stackexchange.com/a/14011/2323 doesn't work anymore. However I want both.

Edit 2 Maybe one could create a custom helm source for inserting images, which is called when I want to insert an image via auctex (don't see how to bind this). Here is what I tried so far, but it doesn't work:

(defun helm-image-select ()
  (helm :sources
      (helm-build-async-source "helm-image-select"
        (lambda ()
          (start-process "find-images" nil "find" "/home/myuser/projects/images/" "-iname" helm-pattern)) ;; doesn't seem to work, in particular no fuzzy search... should also take all path's from TEXINPUTS as base.
    :action '(("insert-image" . insert-image-action)

(defun insert-image-action (candidate)
(insert (format "%s" (helm-get-selection))) ;; should return only the filename without the path

As said above, I also don't know how to connect this to auctex (maybe alternatively, this could be executed if I expand a snipped for includegraphics).

Another problem with the approach above shows up in the case I don't want to add a pictures from a path known by $TEXINPUTS. In particular in this case the path has to be insert such that latex can find the image.

  • Which is the value of LaTeX-includegraphics-read-file for you? If it's LaTeX-includegraphics-read-file-relative the path will be always inserted as relative, otherwise if it's LaTeX-includegraphics-read-file-TeX it should respect TEXINPUTS value (and if it doesn't work automatically add your directory to TeX-macro-private variable).
    – giordano
    Sep 8, 2015 at 8:05
  • That would solve the problem, indeed, but it would break your solution to emacs.stackexchange.com/a/14011/2323. Any idea?
    – student
    Sep 8, 2015 at 11:17


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.