auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] Not including the full path in \includegraphics


From: Mosè Giordano
Subject: Re: [AUCTeX] Not including the full path in \includegraphics
Date: Wed, 25 Jul 2018 22:05:16 +0200

Hi Kourosh,

2018-07-22 17:50 GMT+02:00 Kourosh Kalayeh <address@hidden>:
> Dear all,
>
> Sorry if my question is repeated. I was not able to find an answer on the
> Web and AUCTeX mailing list.
>
> I was wondering if there is anyway that I can tell AUCTeX to not to include
> a full path when using \includegraphics path.
>
> More specifically, below is my workflow;
> I usually use insert macro command (C-c Return) to add \includegraphics.
> AUCTeX then asks me for options and the path of the image that I want to
> include in my file. And it adds it with the full path with respect to the
> directory that my LaTeX file is in. I want AUCTeX to just use the image name
> in the inserted command. How can I achieve this?
> I have explicitly set the path to my figures by adding \graphicspath command
> in my preamble.

Add the following code to your init file:

--8<---------------cut here---------------start------------->8---
(defun mg-LaTeX-includegraphics-read-file-basename ()
  (file-name-base
   (read-file-name
    "Image file: " nil nil nil nil
    (lambda (fname)
      (or (file-directory-p fname)
      (string-match (LaTeX-includegraphics-extensions) fname))))))

(setq LaTeX-includegraphics-read-file
      'mg-LaTeX-includegraphics-read-file-basename)
--8<---------------cut here---------------end--------------->8---

This is adapted from `LaTeX-includegraphics-read-file-relative', it
returns the basename of file, without path and extension (which is
fine for LaTeX).

Bye,
Mosè



reply via email to

[Prev in Thread] Current Thread [Next in Thread]