8

I just found the pin option to drawing, and it looks useful in some of the things I want to draw. How do I format it though? I've tried pin=[red]60:{Hey!} and I get the error Cannot parse this coordinate.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\begin{document}
\begin{tikzpicture}[node distance=2cm,>=latex, every node/.style={
    font=\sffamily\scriptsize
    },  
    circtext/.style={draw,circle,minimum size=8pt,inner sep=2pt},
    dot/.style={draw,circle,fill=black,minimum size=0.6mm,inner sep=0pt}
]
{
\node[rectangle, fill=green!10!white!90!black, minimum width=6cm, minimum height=3cm] at (2,0){};
\node[circtext, fill=yellow](A) at (0,0) {A};
\node[circtext, fill=yellow, right=of A](B){B};
\draw[->] (A) -- node[dot, pos=0.5, pin=[red]60:{Hey!}](C){}(B);
}
\end{tikzpicture}
\end{document}

enter image description here

The default style looks like it's a gray thin arrow, and I want to change it to a black thin dotted line with no arrow.


update: I figured out how to add style to the pin node:

pin={[red]60:Hey!}]

But I can't figure out how to change the linestyle though.

1 Answer 1

12

Aha, got it:

pin={[pin edge={edgestyles}, nodestyles]60:Hey!}]

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\begin{document}
\begin{tikzpicture}[node distance=2cm,>=latex, every node/.style={
    font=\sffamily\scriptsize
    },  
    circtext/.style={draw,circle,minimum size=8pt,inner sep=2pt},
    dot/.style={draw,circle,fill=black,minimum size=0.6mm,inner sep=0pt}
]
{
\node[rectangle, fill=green!10!white!90!black, minimum width=6cm, minimum height=3cm] at (2,0){};
\node[circtext, fill=yellow](A) at (0,0) {A};
\node[circtext, fill=yellow, right=of A](B){B};
\draw[->] (A) -- node[dot, pos=0.5, pin={[pin edge={black, dashed, -}, red]60:Hey!}](C){}(B);
}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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