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 ()
(interactive)
(helm :sources
(helm-build-async-source "helm-image-select"
:candidates-process
(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.