Q:

tikz in listing, multiple pages

I would like to add some tikz in the listing environment. When the code is not long (less than a page), there is not any problem with the position of tikz. 

But when the code is long, the tikz shows up on the wrong page.
A minimal example of long code is  as follows.
\documentclass{article}
\usepackage{tikz}
\usepackage{listings}
\usetikzlibrary{positioning}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

\begin{document}
a\\
a\\
a\\
a\\
a\\
a\\
a\\  
a\\
a\\
a\\
a\\
a\\
a\\
a\\  
a\\
a\\
a\\
a\\
a\\
a\\
a\\  
a\\
a\\
a\\
a\\
a\\
a\\
a\\ 
\begin{lstlisting}[escapechar= !]
a
a
a
a
a
a
THIS IS THE TEXT. !\tikzmark{a}!
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
\end{lstlisting}
\tikz[overlay,remember picture]{\node[fill=green, right=of a] (text) {\scriptsize \Huge HERE};}

\end{document}

How can i fix it.

A:

Most likely I am not interpreting your question correctly, but I'm wondering what is wrong with putting the annotation right after \tikzmark.
\documentclass{article}
\usepackage{tikz}
\usepackage{listings}
\usetikzlibrary{positioning}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

\begin{document}
a\\
a\\
a\\
a\\
a\\
a\\
a\\  
a\\
a\\
a\\
a\\
a\\
a\\
a\\  
a\\
a\\
a\\
a\\
a\\
a\\
a\\  
a\\
a\\
a\\
a\\
a\\
a\\
a\\ 
\begin{lstlisting}[escapechar= !]
a
a
a
a
a
a
THIS IS THE TEXT. !\tikzmark{a}! !\tikz[overlay,remember picture]{\node[fill=green, right=of a] (text) {\Huge HERE};}!
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
\end{lstlisting}
\end{document}

