How do I access the position of a node's label?

This is an extract of my code:

\node (secondsong) [matrix,draw, rounded rectangle,label={song}]{
\node (fstittel) {\_tittel};
\node (fstittelvar) [right=of fstittel, rectangle, draw] {Money''};
\node (fsartist) [below=2pt of fstittel] {\_artist};
\node (fsartistvar) [right=of fsartist, rectangle, draw] {Pink Floyd''};\\
};


I now want to make a rectangle around the label of my node, and make an arrow into the secondsong box. How do I do this?

I tried \path[draw, -latex'] (secondsong.label) -> (secondsong); to draw the arrow, but there is no such thing as a .label variable for a node.

Is this possible out of the box, or do I need to make my own custom node, positioned above my box?

• You should provide an MWE (complete but small document) which demonstrate your problem. – Zarko Oct 22 '19 at 14:03
• I added a couple of screenshots. Nevertheless, the question is quite simple: How can I access the position of the label of a node? – mazunki Oct 22 '19 at 14:09
• well, meantime one "good soul" offer you service "I will do this instead of you" ... – Zarko Oct 22 '19 at 14:10

Welcome! You can give the label a name and a style.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows,positioning,shapes.misc}
\begin{document}
\begin{tikzpicture}
\node (secondsong) [matrix,draw, rounded rectangle,
label={[name=song, rounded rectangle,draw,yshift=1em]:song}]{
\node (fstittel) {\_tittel};
\node (fstittelvar) [right=of fstittel, rectangle, draw] {Money''};
\node (fsartist) [below=2pt of fstittel] {\_artist};
\node (fsartistvar) [right=of fsartist, rectangle, draw] {Pink Floyd''};\\
};
\path[draw, -latex'] (song) -- (secondsong);
\end{tikzpicture}
\end{document}


Let me mention that you could also use a pin.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows,positioning,shapes.misc}
\begin{document}
\begin{tikzpicture}[every pin edge/.style={latex'-}]
\node (secondsong) [matrix,draw, rounded rectangle,
pin={[rounded rectangle,draw]above:song}]{
\node (fstittel) {\_tittel};
\node (fstittelvar) [right=of fstittel, rectangle, draw] {Money''};
\node (fsartist) [below=2pt of fstittel] {\_artist};
\node (fsartistvar) [right=of fsartist, rectangle, draw] {Pink Floyd''};\\
};
\end{tikzpicture}
\end{document}


Or, if you want all the pins (in a scope, say), have a rounded rectangle border, use

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows,positioning,shapes.misc}
\begin{document}
\begin{tikzpicture}[every pin edge/.style={latex'-},every pin/.style={rounded rectangle,draw}]
\node (secondsong) [matrix,draw, rounded rectangle,
pin={above:song}]{
\node (fstittel) {\_tittel};
\node (fstittelvar) [right=of fstittel, rectangle, draw] {Money''};
\node (fsartist) [below=2pt of fstittel] {\_artist};
\node (fsartistvar) [right=of fsartist, rectangle, draw] {Pink Floyd''};\\
};
\end{tikzpicture}
\end{document}

• Ah, obviosuly. That makes sense. I didn't know you could nest information inside the label. – mazunki Oct 22 '19 at 14:12
• @mazunki Since Schrödinger's cat has help you, you should say thank you by accepting the answer and upvote it. – Sveinung Oct 22 '19 at 14:15
• I was waiting for the 5 minute cooldown. The answer is perfect. – mazunki Oct 22 '19 at 14:18