3
$\begingroup$

I've noticed that wrapping a Graphic[] in Hyperlink[] causes weird things to happen when using Inset[] (which, in my case, is being automatically used by GraphicsGrid[] and Text[]). Here's a minimal-ish example where you great a white rectangle with a red border and a number in the middle. You then Inset[] that into some arbitrary position and, this is the important part, specify the new size.

If the Graphics[] object is embedded as-is, it works fine. If you instead try to embed Hyperlink[g], it just renders wrong. It's all cutoff.

g = Graphics[{White, EdgeForm[{Red, Thickness[Large]}], 
    Rectangle[{-1, -1}, {1, 1}], Inset[Style[1, Black, Bold]]}];
Inset[g, {1620, -180}, ImageScaled[{0.5`, 0.5`}], {360, 360}] // 
  Graphics;
Inset[Hyperlink[g, None], {1620, -180}, 
   ImageScaled[{0.5`, 0.5`}], {360, 360}] // Graphics;
{%%%, %%, %}

Output I get from the example code

The first image is the Graphics object itself, the second is the Inset[] results with just the graphics obejct, and the third is if I Hyperlink the graphics object. If I resize the Hyperlink-ed result enough, it eventually shows the border:

enter image description here

So I think what's happening is that the Hyperlink wrapper is causing the Graphics object to end up cropped, not scaled.

Can someone please see if they can reproduce this issue? If so, I'll try to report it as a bug.

$\endgroup$
2
  • $\begingroup$ Welcome to MMA SE! I've reproduced it, and I'm not sure why this is happening, but just wanted to mention a possible workaround: wrap HyperLink around the Inset instead of on the inside. To accomplish this without access to the explicit Inset, you could potentially define a wrapper innerlink with the following upvalue: Inset[innerlink[x_, y_], z___] ^:= Hyperlink[Inset[x, z], y]. Not sure if this works in general, though. $\endgroup$
    – thorimur
    Commented Mar 29, 2021 at 23:13
  • $\begingroup$ I tried that, unfortunately, Hyperlink[Inset[...]] produces a result in the exported PDF (I'm tyring to make a programmatic hyperlinked PDF year planner, so this is used to hyperlink from the date in a month calendar to that day's page later in the PDF) that doesn't work. No idea why it doesn't work, one would imagine that hyperlinking a higher level object should work better, but alas, here we are. Thanks for testing and confirming it isn't just me! I'll file a bug and update here accordingly if I get any response. $\endgroup$
    – Mike H
    Commented Mar 31, 2021 at 1:59

1 Answer 1

3
$\begingroup$

This has been fixed as of 12.3.1! The behaviour is now as expected.

All of the three considered layouts now behave as expected

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.