[Tex/LaTex] How could you make an image a hyperlink to a section in a LaTeX document

graphicshyperreftables

I'm fairly new to latex and am currently working on a few articles as practice before I use it for more official documents. In my current document, I am attempting to make a table of icons (png images). Upon clicking on these icons, I want each of them to link to a different section of my document.

Using the hyperref and graphicx packages, I have managed to create links to sections and to add images to the document, but I am unsure of how to combine these, or if it is even possible and any help would be greatly appreciated.

\begin{center}
        \begin{tabular}{|c|c|c|c|c|c|}
        \hline
        \nameref{sec:a} & \nameref{sec:b} & \nameref{sec:c} & \nameref{sec:d} & \nameref{sec:e} & \nameref{sec:f}\\ \hline
        \nameref{sec:g} & \nameref{sec:h} & \nameref{sec:i} & \nameref{sec:j} & \nameref{sec:k} & \nameref{sec:l}\\ \hline
        \nameref{sec:m} & \nameref{sec:n} & \nameref{sec:o} & \nameref{sec:p} & \nameref{sec:q} & \nameref{sec:r}\\ \hline
        \nameref{sec:s} & \nameref{sec:t} & \nameref{sec:u} & \nameref{sec:v} & \nameref{sec:w} & \nameref{sec:x}\\
        \hline
        \end{tabular}
\end{center}

With that section of code I've managed to create text links to each section that display the section name. However, I was wondering if by some combination of \includegraphics, \ref, \href, or other commands I could present the image and have it link to the section instead of the text name of the section being shown as the link.

\href{sec:Aatrox}{\includegraphics{AatroxSquare.png}}

That was one of my thoughts but as it is not a link but rather a reference it did not go as planned. I'm unsure how to continue and would appreciate any advice/hints.

Best Answer

You should use \hyperref[<label>]{<stuff>}:

enter image description here

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\begin{document}
Take your pick:
  \hyperref[sec:A]{\includegraphics[height=\baselineskip]{example-image-a}}
  \hyperref[sec:B]{\includegraphics[height=\baselineskip]{example-image-b}}
  \hyperref[sec:C]{\includegraphics[height=\baselineskip]{example-image-c}}
\section{Section A}\label{sec:A}
\section{Section B}\label{sec:B}
\section{Section C}\label{sec:C}
\end{document}

If you want to link to an external URL when clicking on an image, then use \href[<options>]{<URL>}{<stuff>}:

enter image description here

\documentclass{article}

\usepackage{hyperref,graphicx}

\begin{document}

\href{http://tex.stackexchange.com}{\includegraphics{tex-se}}

\end{document}
Related Question