3

Is it possible to make a reference as part of a graphic, which is included in a LaTeX document?
If so, what would be the preferred format for such a graphic (EPS, ...)?

Mockup:

Mockup

I'm using pdflatex for compiling.

1 Answers1

5

One way to do this would be to put the \includegraphics{...} inside of a TikZ node, and then put another node on top of the image with TikZ, where this node either contains the \ref{...} or the \label{...} command, depending on whether you want a reference or a label inside of the picture.

The code below for overlaying using TikZ with the \includegrpahics{...} is taken from this question on TeX.SX.

The varwidth package is used to put an enumerate environment inside of a TikZ node. See this answer for an explanation.

\documentclass{article}

\usepackage{tikz}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{varwidth}

\begin{document}

Here, we will reference a label that is set on top of the picture with \verb|tikz| (\ref{fig:1}).

\begin{figure}[h!]
\centering
\begin{tikzpicture}
    \node at (0,0) {\includegraphics[width=.6\textwidth]{example-image}};
    \node at (1.2,2) {\begin{varwidth}{2in}\begin{enumerate}[label={Fig.~\arabic*}]\item{Hi, let's reference this\label{fig:1}}\end{enumerate}\end{varwidth}};
\end{tikzpicture}
\end{figure}

Here, we will do the opposite of this; we will put the \verb|\ref{...}| inside the \verb|node|, as a reference to example 1:

\begin{enumerate}

    \item{\label{ex:1}Example 1}

\end{enumerate}

\begin{figure}[h!]
\centering
\begin{tikzpicture}
    \node at (0,0) {\includegraphics[width=.6\textwidth]{example-image}};
    \node at (1.2,2) {Look at example~\ref{ex:1}};
\end{tikzpicture}
\end{figure}

\end{document}

enter image description here

Adam Liter
  • 12,567