1

I'm trying to annotate a picture using tikz. Somehow though there's some behavior that I do not understand. I draw a decoration at the end of the annotation line that is no more than a circle. The decoration is defined by means of a tikzset. Nothing special so far. However there's a something causing the decoration to disappear when I try to annotate pictures with a given width of more than 7cm. Here's a (hopefully minimum) MWE of what I'm talking about, tested in Overleaf:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\tikzset{
    o/.style={
        shorten >=#1,
        decoration = {
            markings,
            mark={
                at position 1
                with {
                    \draw circle [radius=#1];   
                }
            }   
        },
        postaction = decorate,
    },
    o/.default=2pt
}

\begin{document}
  \begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0,0){
        \includegraphics[width=7cm]{frog}   %%% works with a picture width of 7cm
    };
    \begin{scope}[x={(image.south east)},y={(image.north west)}]
      \draw[o,>=stealth,shorten <= 2mm, line width=0.5mm] (-0.25,1.25) node {Frog} to[out=-90] (0.41,0.6);
    \end{scope}
  \end{tikzpicture}

  \begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (image) at (0,0,0){
      \includegraphics[width=8cm]{frog} %%% circle vanishes with a picture width of 8cm
    };
    \begin{scope}[x={(image.south east)},y={(image.north west)}]
      \draw[o,>=stealth,shorten <= 2mm, line width=0.5mm] (-0.25,1.25) node {Frog} to[out=-90] (0.41,0.6);
    \end{scope}
  \end{tikzpicture}
\end{document}

The first picture is set to a width of 7cm. There the circle at the end of the \draw is still drawn. In the second picture which width is set to 8cm (the only difference) the circle is not drawn anymore.

I'd really like to understand why this happens and how to circumvent/fix it.

1

I can't obtain circle on the end of line in any size of image. I didn't examine why but rather wrote new, to my opinion far simpler code for lines, which pointed frog in image. In it I use two libraries: arrows.meta for circle on the end of line and positioning for determine line coordinates:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning}

\tikzset{line/.style={-{Circle[open,length=#1]},shorten <= 2mm, line width=0.5mm},
         line/.default=5pt}

\begin{document}
  \begin{tikzpicture}
    \node[anchor=north west,inner sep=0] (image) at (0,0,0){
        \includegraphics[width=3cm]{example-image-a}};
    \coordinate[above left=0.25 and 1.25 of image]         (a);
    \coordinate[above left=0.25 and 1.25 of image.center]  (b);
    \draw[line] (a) node {Frog} to[out=-90] (b);
  \end{tikzpicture}

\bigskip
  \begin{tikzpicture}
    \node[anchor=north west,inner sep=0] (image) at (0,0,0){
      \includegraphics[width=8cm]{example-image-b}};
    \coordinate[above left=0.25 and 1.25 of image]         (a);
    \coordinate[above left=0.60 and 0.41 of image.center]   (b);
    \draw[line] (a) node {Frog} to[out=-90] (b);
  \end{tikzpicture}
\end{document}

which gives: enter image description here

  • Weird... Okay, I'll go on with this one. Thanks! – Hendrik Wiese Jan 18 '17 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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