Graphics, Figures & TablesImages as hyperlinks to URL (TexLive with XeTeX)

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
fru
Posts: 2
Joined: Thu May 08, 2014 8:14 pm

Images as hyperlinks to URL (TexLive with XeTeX)

Post by fru »

Hi everyone and congratulations for this amazing community. :!:

I'm a new member, but I keep visiting this forum for quite some time. Reading topics has helped me a lot to use LaTeX more effectively. So thank you!

To get to the point, I want to use in my document some images that are supposed to be acting as hyperlinks to a URL.
While searching, I found out that I can use \href inside a figure environment, as pointed out here. The example provided by 5gon12eder in that case, is exactly what I want to do, but it doesn't work like that when I try it.

Instead of the hole image being clickable and leading to the URL, I only get a tiny part of it (the bottom left corner) that is clickable.
To be more specific, here is a sample of LaTeX code and here is the produced PDF.
Notice that the bottom left corner of the image acts as a hyperlink, while the rest of it is not clickable.

Any help and suggestions are welcome.

Thank you very much in advance for you time.

Best regards,
Elias
There is no place like ~

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

fru
Posts: 2
Joined: Thu May 08, 2014 8:14 pm

Images as hyperlinks to URL (TexLive with XeTeX)

Post by fru »

Guys, my problem is now fixed, thanks to the answer here.
All I had to do is add this to the preamble:

Code: Select all

\ifxetex
  \usepackage{letltxmacro}
  \setlength{\XeTeXLinkMargin}{1pt}
  \LetLtxMacro\SavedIncludeGraphics\includegraphics
  \def\includegraphics#1#{% #1 catches optional stuff (star/opt. arg.)
    \IncludeGraphicsAux{#1}%
  }%
  \newcommand*{\IncludeGraphicsAux}[2]{%
    \XeTeXLinkBox{%
      \SavedIncludeGraphics#1{#2}%
    }%
  }%
\fi
There is no place like ~
Post Reply