Slightly convoluted as I generate my TikZ graphics with Emacs org-babel source blocks, but I've reproduced this problem in a .tex file (see below).
Following this post and many related ones, I've tried to insert hyperlinks to a TikZ diagram - specifically using a graph drawing algorithm and compiling with LuaLaTeX. However, the alias=sourcenode in the \tikzset argument seems to create the error Package pgf Error: No shape named 'sourcenode' is known.
The resulting .pdf seems to be look fine, with a functioning hyperlink to the right webpage. But I'd like to remove this compilation error and/or understand how it arises. I've tried many different versions of the LaTeX style, including e.g. \tikz [ ...] instead of wrapping \graph in a \begin{tikzpicture}[...] block, but the error persists.
Here's my minimal(-ish) reproducible example, where I compile with
Running `LaTeX' on `latex-q6CtLl' with
``lualatex --jobname=latex-q6CtLl -file-line-error
--synctex=1 -interaction=nonstopmode latex-q6CtLl.tex''
\documentclass{article}
\usepackage[usenames]{color}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows,backgrounds,calc,positioning}
\usetikzlibrary{arrows.meta,graphs,graphdrawing,quotes}
\usegdlibrary{trees,force}
\pagestyle{empty}
\begin{document}
\tikzset{
background rectangle/.style={fill=white},
hyperlink node/.style={
alias=sourcenode,
append after command={
let \p1 =(sourcenode.north west),
\p2=(sourcenode.south east),
\n1={\x2-\x1},
\n2={\y1-\y2} in
node [inner sep=0pt, outer sep=0pt,anchor=north west,at=(\p1)]
{\href{#1}{\phantom{\rule{\n1}{\n2}}}}
}
}
}
\begin{tikzpicture}[nodes={minimum height=1.5em, text depth=.2em, inner sep=0.5cm, draw=black!20, thick, fill=white, align=center}, >={Stealth[round,sep]}, rounded corners, semithick]
\graph[tree layout, grow'=-10, level distance=3cm, sibling distance=2cm,, edge quotes mid,]
{
a/"Linked node" [draw=red, hyperlink node=www.google.com],
b/"Ordinary node",
a -- b,
};
\end{tikzpicture}
\end{document}
Here is the error message:
./latex-q6CtLl.tex:29: Package pgf Error: No shape named `sourcenode' is known.

sourcenodecan't be found. You will need to either do this after the\graphor as alabel(which has special consideration by the library). – Qrrbrbirlbel Feb 17 '23 at 11:15