I want to make a macro by which I can jump into any page I want when clicking a designated object, like this:
\gotopage{3}{object selected}
%then goto the third page
The object may be text, graphic etc.
And I don't like putting a label at each page especially when there are many pages in an article.
How can I do this?
Here is an MWE and related figure to show my idea:
\documentclass{article}
\usepackage{calc,ifthen,eso-pic,picture,xparse,lastpage,refcount,tikz}
\AtBeginDocument{
\newcounter{totalpage}
\setcounter{totalpage}{\getpagerefnumber{LastPage}}
}
\begin{document}
\AddToShipoutPictureBG{\AtPageCenter{%
\put(0.5\paperwidth-0.5\marginparwidth,0.5\textheight) {%
\scalebox{0.7} {%
\begin{tikzpicture}[baseline=(current bounding box.north)]%
\foreach \i in {1,...,\thetotalpage}{%
\ifnum\value{page}=\i\relax%
\tikzset{pn/.style={fill=red,font=\bfseries}}
\else%
\tikzset{pn/.style={fill=gray,opacity=0.5}}%
\fi%
\path[radius=0.5cm,scale=1,text=white,pn](0,-\i) circle node[scale=1.5]{\i};
}%\foreach
\end{tikzpicture}%
}%\scalebox
}%put
}}
first page
\clearpage
second page
\clearpage
third page
\end{document}
UPDATED MWE:
\documentclass{article}
\usepackage{calc,ifthen,eso-pic,picture,xparse,lastpage,refcount,tikz,hyperref}
\AtBeginDocument{
\newcounter{totalpage}
\setcounter{totalpage}{\getpagerefnumber{LastPage}}
}
\begin{document}
\AddToShipoutPictureBG{\AtPageCenter{%
\put(0.5\paperwidth-0.5\marginparwidth,0.5\textheight) {%
\scalebox{0.7} {%
\begin{tikzpicture}[baseline=(current bounding box.north)]%
\foreach \i in {1,...,\thetotalpage}{%
\ifnum\value{page}=\i\relax%
\tikzset{pn/.style={fill=red,font=\bfseries}}
\else%
\tikzset{pn/.style={fill=gray,opacity=0.5}}%
\fi%
\hyperlink{page.\i}{%
\path[radius=0.5cm,scale=1,text=white,pn](0,-\i) circle node[scale=1.5]{\i};
}%\hyperlink
}%\foreach
\end{tikzpicture}%
}%\scalebox
}%put
}}
first page
\clearpage
second page
\clearpage
third page
\end{document}
\goto
macro? You leave\goto
undefined.