Is it possible to set default size of linked images?

I find myself, more often than not, changing the width of all images to 0.5par. Is it possible to set this to the default size when importing images?

I currently use this function to quickly insert images. How can I adapt it to also set the default image width to 0.5par.

(define (make-figure-without-caption)
  (insert-go-to
    '(center "") '(0 0))
  (choose-file make-link-image "Load image" "image"))

I think a start for getting what you want might be the following: the function make-image takes as arguments the width, height and x- and y-coordinates of an image

(make-image file_path #t "0.5par" "" "" "")

—where file_path is the path to an image in your system and I left blank height and x-y-coordinates—links into the document an image of the size you want

I got it looking at Edit/Modify/edit_text.cpp

The next step is to combine it with the file chooser, which I haven’t yet figured out how-to :slight_smile:

Besides, I did not understand whether there is a connection between this and Automatic image width for folds (e.g. TikZ) works, but is overridden by 0.618par default

Thanks. I played a bit with it, but couldn’t make it to work. What we need is a function to return the link, not make an image.

BTW, is there a shortcut to toggle the equation number?

I may try in the next days, I do not promise that I will be able to make any progress. I think make-image can return the link depending on the value of its second argument (I did not check again before writing this post, I hope the memory is correct!).

For

please take a look at this post https://texmacs.github.io/notes/docs/menu-shortcuts.html and let me know if it helps (numbering a formula can be done through a contextual menu so I think the post is relevant).

How about this?

(tm-define (make-link-image l)
  (apply make-image (cons* (url->delta-unix (car l)) #t '("0.5par" "" "" ""))))

The shortcut to toggle equation number is Ctrl-# for me.

2 Likes

Thanks for the reply. What is l in (make-link-image l). I tried it as shown below, but it didn’t do the trick.

(define (make-figure-without-caption)
  (insert-go-to
    '(center "") '(0 0))
  (apply make-image (cons* (url->delta-unix (car (choose-file make-link-image "Load image" "image"))) #t '("0.5par" "" "" ""))))

You have to combine it with the file chooser :slight_smile:

(define (make-figure-without-caption)
  (insert-go-to
    '(center "") '(0 0))
  (choose-file make-link-image "Load image" "image"))

where make-link-image is the one redefined as @jeroen suggested.

It is the argument that choose-file will insert into make-link-image, that is the path of the file you have chosen (I am guessing it without having been able to follow the function definitions in the source code, but I am confident).

1 Like

Thanks. Somehow, I didn’t read the name of the procedure make-link-image!

Unrelated questions:

  1. Do you know where I can get appimages of older releases of texmacs? The current one for arch is really slow (even slow to start on a very fast nvme ssd). I tried the same release for ubuntu on a docker container and it ran fine.
  2. Why does texmacs consume so much cpu when it’s idle? I use a tiling windows manager. I have texmacs open multiple documents as individual windows. A single instance consumes 2% CPU (on an 8 thread machine) when idling. This is even worse when you open more than one document.

Could you please open new threads for the “unrelated” questions? That makes it easier to read the forum.
For your second question I won’t have an answer, but I think we can find other discussions on the topic, and for the first I’m able to find old versions but not appimages (where do you get the one for the current version?).

Here: https://download.opensuse.org/repositories/home:/slowphil:/texmacs-devel/

Nice. I would try asking the owner of that repository.