2

When there are many nodes each have different names like n1, n2, n3, c1, c2 ,c3 ... after a while I started to get lost which node has which name.

Hence, we can help grid help lines using \draw[help lines] (0,0) grid (8,5);.

Can we apply similiar approach for defined node names? like if a node's name is n1, can n1 show up next to node in slightly gray color and apply this for all the nodes in the tikzpicture?

alper
  • 1,389
  • Check the answer by @cfr at https://tex.stackexchange.com/questions/327269/how-could-i-show-tikz-node-names-in-the-output-e-g-in-a-label – lRadha Jul 21 '22 at 09:13

1 Answers1

5

This combines Andrew Stacey's answer to Every non-label node in TikZ.

You can also use my answer but Andrew's is safe for when PGF/TikZ updates.

Code

\documentclass[tikz]{standalone}
\tikzset{
  clear label/.style={prefix after command={[every non label/.style={}]}},
  every node/.style={every non label,clear label},
  every non label/.style={label={[font=\tiny,gray]:\tikzlastnode}}}
\begin{document}
\begin{tikzpicture}[]
\foreach \x in {A, ..., F}{
  \node[circle, draw] at (5*rand, 5*rand) {\x};
}

\node (abc) at (0,0) {x}; \end{tikzpicture}

\end{document}

enter image description here

Qrrbrbirlbel
  • 119,821