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}] // 
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.

  • $\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 Mar 29 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 Mar 31 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.