How to keep figure names when exporting to latex?

When I export to latex, the names of all images in the in the output latex is changed to something like image-x.pdf. This makes it really hard to which image we’re talking about. I would like to keep the exported path to be exactly the same as the name of the image inside texmacs. For example, if the image’s path is ./figures/title.pdf, the exported image name should be the same. This is supposed to be the default behavior, but doesn’t seem to be the case. Is there a way I can fix this?

I looked at the preferences and there is nothing there; for this reason, I think one needs to look into the Scheme code and see how it exports figures, and how the exporting of the figures might be redefined.

But before trying that I would rather see if anyone else knows.

I did some grepping and arrived at the responsible function. I don’t know anything about scheme, but it seems that the function is checking if the figure was inserted through a URL (path), then use the URL, otherwise use a generic name.

(define (tmtex-as-eps name)
  (let* ((u (url-relative current-save-target (unix->url name)))
         (suffix (url-suffix u))
         (fm (string-append (format-from-suffix suffix) "-file")))
    (if (and (url-exists? u) (in? suffix (list "eps" "pdf" "png" "jpg")))
	(list 'includegraphics name)
        (receive (name-url name-string) (tmtex-eps-names)
          (convert-to-file u fm "postscript-file" name-url)
          (list 'includegraphics name-string)))))

I always link images (which means they always have a URL). So, we should expect the first part of the if statement to run. However, it seems that it only runs when the URL is given as a full path (relative to /), we get the expected latex code. This is not the way the link image dialog windows writes its URL. It writes its URLs as a relative path. Looking at the code above, it is calling a function url-relative which I assume is supposed to be retrieving the full path, but this doesn’t seem to be working.

As a temporary fix, I have replaced the above code with:

(define (tmtex-as-eps name)
  (list 'includegraphics name))

Hopefully, someone more knowledgable than me will look into in and fix it upstream.

1 Like

I think in the Savannah bug tracker one can post requests for enhancement too.

That platform looks so ancient that it will take me days to figure out what to do. I guess I’ll just write a script that replaces that section of the code every time I update texmacs.

Pls. check if this thread can help to redefine the local function tmtex-as-eps from outside the module (if there is away for that you would be able to place the redefinition in the local TeXmacs configuration files).

Moreover

First you need to login (make an account if you do not have one), then in the upper ribbon, in the drop-down menu under “Bugs”, you will get a “Submit new” item

By the way, good job!

The code of this function could be found in https://github.com/texmacs/texmacs/blob/1afa94326d8413be1e71cd59761a4cfa54bac9f6/src/Scheme/Glue/glue_basic.cpp#L6868