11

This question already has an answer here:

I am using LaTeX to make a manual. I would like to annotate an image with arrows pointing to parts of the image and a textual annotation outside of the image. Is there a simple way I can do this with TikZ or something similar?

an example of the kind of thing i want to do

The question is not answered already... the linked "duplicate" (which I had seen) doesn't describe drawing arrows with text annotations, which is what i asked about!

marked as duplicate by Werner, user31729, user13907, Symbol 1, jub0bs Apr 15 '15 at 15:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Welcome to TeX.SE. If the linked question doesn't answer you question please update the question and explain why. – Peter Grill Jun 24 '14 at 15:38
  • please see my update... "Drawing on an image with Tikz" doesn't talk about arrows or text annotation – olilarkin Jun 24 '14 at 22:43
  • Related/duplicate: Drawing on an image with TikZ – Werner Jun 24 '14 at 23:15
20

You can use Drawing on an image with TikZ to place and node and add any additional drawings to it. You can add text via a \node and then use \draw to draw the arrows to the appropriate place on the image:

enter image description here

Code:

\documentclass{article}
%\usepackage{showframe}
\usepackage{tikz}

\begin{document}
\noindent
\begin{tikzpicture}
\node [anchor=west] (note) at (-1,3) {\Large Note};
\node [anchor=west] (water) at (-1,1) {\Large Water};
\begin{scope}[xshift=1.5cm]
    \node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.7\textwidth]{../images/EiffelWide.jpg}};
    \begin{scope}[x={(image.south east)},y={(image.north west)}]
        \draw[red,ultra thick,rounded corners] (0.48,0.80) rectangle (0.55,0.95);
        \draw [-latex, ultra thick, red] (note) to[out=0, in=-120] (0.48,0.80);
        \draw [-stealth, line width=5pt, cyan] (water) -- ++(0.4,0.0);
    \end{scope}
\end{scope}
\end{tikzpicture}%
\end{document}
  • perfect - thankyou very much – olilarkin Jun 25 '14 at 9:25
10

As already suggested, you can annotate the different parts of the figure using TikZ. However, sometimes it might even better to use numbers to reference the different parts and explain them in the figure caption.

To easily get the precise relative positions (which is often quite tedious) and to generate LaTeX code automatically for such example as shown below, you could use the new web-based LaTeX Overlay Generator, which I built for such cases. This is just a small interactive tool, which helps you to find the right locations without using a manual grid-based approach.

Example

LaTeX Code

In the following the source code of a minimal working example generated by the LaTeX Overlay Generator.

\documentclass{article}

% remove "[demo]" if you want include actual image!!!
\usepackage[demo]{graphicx}

\usepackage{tikz}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LaTeX Overlay Generator - Annotated Figures v0.0.1
% Created with http://ff.cx/latex-overlay-generator/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\annotatedFigureBoxCustom{bottom-left}{top-right}{label}{label-position}{box-color}{label-color}{border-color}{text-color}
\newcommand*\annotatedFigureBoxCustom[8]{\draw[#5,thick,rounded corners] (#1) rectangle (#2);\node at (#4) [fill=#6,thick,shape=circle,draw=#7,inner sep=2pt,font=\sffamily,text=#8] {\textbf{#3}};}
%\annotatedFigureBox{bottom-left}{top-right}{label}{label-position}
\newcommand*\annotatedFigureBox[4]{\annotatedFigureBoxCustom{#1}{#2}{#3}{#4}{white}{white}{black}{black}}
\newcommand*\annotatedFigureText[4]{\node[draw=none, anchor=south west, text=#2, inner sep=0, text width=#3\linewidth,font=\sffamily] at (#1){#4};}
\newenvironment {annotatedFigure}[1]{\centering\begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0) { #1};\begin{scope}[x={(image.south east)},y={(image.north west)}]}{\end{scope}\end{tikzpicture}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

    \begin{figure}[h!t]

        \begin{annotatedFigure}
            {\includegraphics[width=1.0\linewidth]{black-demo.png}}
            \annotatedFigureBox{0.084,0.614}{0.394,0.804}{A}{0.084,0.614}%bl
            \annotatedFigureBox{0.222,0.284}{0.3743,0.4934}{B}{0.3743,0.4934}%tr
            \annotatedFigureBox{0.555,0.784}{0.6815,0.874}{C}{0.555,0.784}%bl
            \annotatedFigureBox{0.557,0.322}{0.8985,0.5269}{D}{0.8985,0.5269}%tr
        \end{annotatedFigure}

        \caption{\textbf{Lorum Ipsum Overview} -- Lorem ipsum dolor amet (A), consetetur (B) elitr, sed diam (C) nonumy eirmod invidunt ut labore (D).}
        \label{fig:teaser}

    \end{figure}

\end{document}
  • 1
    Welcome to TeX.SX! As far as possible you should try and make your answers self-contained, without deferring the real information to external links. – Andrew Apr 14 '15 at 12:51
  • Right! I've added the full source code for a minimal working example to generate the include figure. – f2cx Apr 15 '15 at 14:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.