8

Hi I'm wondering how can I reference to current node name in execute at begin node property.

\node[execute at begin node = \command_which_uses_node_name_to_to_do_soething_draw_uml_component_symbol] (){Node-name};
3
  • 1
    Could you give a MWE.
    – rtzll
    Dec 27, 2012 at 19:56
  • @Meter: That's not an MWE. An MWE is a complete minimal example document, which saves people the work of having to come up with a test document themselves (because that part of answering questions is pretty boring).
    – Jake
    Dec 27, 2012 at 20:17
  • @Meter: Is anything missing from my answer?
    – Jake
    Jan 2, 2013 at 14:51

1 Answer 1

14

The node name is stored in \tikz@fig@name at the time the code in execute at begin node is executed.

Here's an MWE, which prints > \tikz@fig@name=macro: ->myname. into the .log file:

\documentclass{article} 
\usepackage{tikz}

\begin{document}

\makeatletter
\tikzset{
    teststyle/.style={
        execute at begin node=\show\tikz@fig@name   
    }
} 
\makeatother

\begin{tikzpicture}
\node (myname) [teststyle] {Text};
\end{tikzpicture}

\end{document}
2
  • 1
    Note: even if we know its future name, the node does not yet exist at that time (execute at begin node). Dec 28, 2012 at 8:32
  • This command fails if the node has no name. Any idea how to get the "identifier" of a node? (If possible matching the "\tikztotarget" name?)
    – tobiasBora
    Oct 17, 2021 at 21:22

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.