Page Numbering – How to Determine Current Page Number

bookmarkspage-numbering

I am adding entries to bookmarks and I want one entry to point to a specific page. However, I don't want to provide it's number, because it may change depending on contents modification before that page. The command to add an entry using the bookmark package is:

\bookmark[page=X,level=0]

where X is the page number. How can I determine at compile time the current page number to replace X with it? I've tried using \thepage in X's place but it didn't work. In the package documentation I found out there are named actions to PrevPage, NextPage, FirstPage and LastPage but there is no CurrentPage. How to fix this?

Thanks.

Best Answer

Set a target on the page:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{bookmark}
\begin{document}
\bookmark[dest=mypage]{go to my page!}


page 1\newpage page 2 \newpage my page \hypertarget{mypage}{}
\newpage next page

\end{document}
Related Question