1

I'm trying to create a hyperlinked image with this MWE:

\documentclass{article}

\usepackage{graphicx}
\usepackage{hyperref}

\begin{document}
    \href{https://www.wikipedia.org/}{\includegraphics[scale=0.15]{img.png}} % For any img.png
\end{document}

When compiling with xelatex the link isn't produced on the image, but compiling it with pdflatex does make it clickable. Do I need to pass any special argument to the packages to make them work with xelatex or is it just an impossible task?

Thank you!

2
  • 2
    This is a known and long-standing (x)dvipdfmx bug, see sourceforge.net/p/xetex/bugs/25/#c0f5. Currently only pdf images are supported. Sep 18, 2020 at 22:46
  • I see, I just used convert on the image and can confirm it compiles with xelatex. Thanks for your help!
    – Groctel
    Sep 18, 2020 at 22:54

1 Answer 1

2

With a new dvipdfmx (e.g. dvipdfmx Version 20200902) it will work directly, the detection of link boxes has been improved. I got the new binary from w32tex.org and could already test it. It will be in the next texlive.

With older versions you can use \XeTeXLinkBox (defined by hyperref):

\href{https://www.wikipedia.org/}{\XeTeXLinkBox{\includegraphics[scale=0.15]{example-image.png}}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .