Preview-ref not work for linked figures

The preview-ref package works for inserted image but not for linked image in a figure. It shows a big question mark:


Using linked image is preferred because it can be updated when the image is modified.

BTW, Iā€™d like to customize the background color and zoom level of the tooltip. I looked up the definition of the package and find the relevant definition for preview-reference:

(tm-define (preview-reference body body*)
  (:secure #t)
  (and-with ref (tree-up body)
    (with (x1 y1 x2 y2) (tree-bounding-rectangle ref)
      (and-let* ((id (and (tree-atomic? body*) (tree->string body*)))
                 (tip (and id (ref-preview id))))
        (show-tooltip id ref tip "auto" "auto" "default" 0.6)))))

Then I looked up the definition of show-tooltip and find 0.6 should be related to the zoom level. But set the value to 1.0 is not 100% zoom level. I didnā€™t find a place to customize the background color.

Seems like a bug to me. I can only reproduce this if the image linked using a relative path, btw.

There are some notes on this b @mgubi on the blog, they can be of use in figuring this out.

This is not necessarily true for all use cases. When distributing documents, inserting images may be preferable.

1 Like

After reading the blog post by @mgubi, I find the definition of preview-balloon:

<assign|preview-balloon|<macro|body|<tabular|<tformat|<cwith|1|1|1|1|cell-hyphen|t>|<cwith|1|1|1|1|cell-background|<value|preview-bg-color>>|<twith|table-width|40em>|<twith|table-hmode|min>|<cwith|1|1|1|1|cell-lsep|1spc>|<cwith|1|1|1|1|cell-rsep|1spc>|<cwith|1|1|1|1|cell-bsep|1spc>|<cwith|1|1|1|1|cell-tsep|1spc>|<table|<row|<\cell>
  <arg|body>
</cell>>>>>>>

and managed to change the background color through preview-bg-color.

However, references and big formulas are often out of the preview box. I tried to change the table properties but it takes no effect.

I see the preview works if using absolute path. How to make absolute path the default when we insert the image through system file browser?

I see the preview works if using absolute path. How to make absolute path the default when we insert the image through system file browser?

This is not always what you want. Usually images are in the same directory as the document. I think is a problem of the preview package. Preview does not limit itself to show you the part of the document which is references, but essentially retypeset that part in the pop-up window (which is a separate document). It seems that at that stage the typesetter does not have access to the path of the original document, so cannot figure out where the image is. I think it should be fixable (and to be fixed).Preformatted text

1 Like

Indeed itā€™s dangerous to use absolute path.

I encountered another problem. Some pictures are cropped no matter what size I use, or I use it inside figure or not. But the exported (printed) pdf document displays the correct images.

No problem at all if inserting image not by link. My pictures are all in pdf format.

Probably there is something wrong in the conversion to bitmap of the PDF, can you file a bug in savannah (https://savannah.gnu.org/projects/texmacs) with one of problematic images? Thanks!

Filed the bug GNU TeXmacs - Bugs: bug #64397, Linked PDF images get cropped [Savannah]

BTW, the pdf is created in MATLAB by the ā€œexportgraphicsā€ command. The problem occurs only if I choose ā€˜imageā€™ as the value for the option ā€˜ContentTypeā€™ in this command. If I choose ā€˜vectorā€™, then the image is displayed correctly. Of course, the pdf opens correctly in any pdf viewer in both cases. The pdf file can become very large if I choose the ā€˜vectorā€™ option.

I canā€™t reproduce the issue here. Could you please tell us the OS, TeXmacs version and origin of the build (texmacs.org, distro repo, OBS, self-build, otherā€¦)

Apple M2 Max, OS 13.4.1 (22F82). TeXmacs 2.1.2, installed from the latest build in github.
Sometimes the images are not cropped but padded with more a big white space, and the issue can get fixed by restarting TeXmacs.

1 Like

I can reproduce the problem now. I turned on the debug menu and activate debug->convert. The error message says something like ā€œimage size blahblah in cache 1000x300ā€, which is wrong, because my image is 1000x400. My previous image in this Figure was 1000x300.

Once I closed and reopen the editor, the problem is gone. So the reason is the cache is not cleared after the image is changed? I tried update everything, but no luck. How do I clear cache manually?

BTW, the bug was closed by Joris. How can I reopen it?

I saw a menu item ā€œReset to openā€ under ā€œBugsā€ in the horizontal menu list at the top of the page. I would try that.

I tried that before, but it didnā€™t work. Clicking on that took me to the main page and the bug is still not shown.

I see. It may be that you need to be part of the TeXmacs group on Savannah to change the status of the bug item; I read it on https://savannah.gnu.org/project/memberlist.php?group=texmacs