# Named boxes with links compatibility

I'm using xsavebox package for saving and using named boxes (I want the boxes to have names like X.1.3) and I want to make links to these boxes but they are not compatible with any kind of referencing. Any ideas?

\usepackage{xsavebox}
\usepackage{navigator}

\anchor{K.1.1}
\begin{xlrbox}{X.1.3}
\anchor{X.1.3}
\end{xlrbox}
...
\xusebox{X.1.3}


Using it gives an error:

pdfTeX error (ext4): link annotations cannot be inside an XForm.

• as the error says: links can't be inside an xform. So no it won't work. May 10 at 20:13

I've got this answer from Alexander Grahn, so I'm sharing it here. Alexander's Gitlab

\documentclass{article}
\usepackage{hyperref}

\newcommand\namedsbox[2]{%
\ifcsname#1\endcsname\else%
\expandafter\newsavebox\csname#1\endcsname%
\fi%
\expandafter\sbox\csname#1\endcsname{#2}%
}
\newcommand\usenamedbox[1]{\expandafter\usebox\csname#1\endcsname}

\begin{document}