# Page double counter problem: theHpage undefined

I have a problem with links placed by a package (glossaries-extra) inside the preamble of my thesis. In this preamble I want to use roman numbers (i,ii,iii,...) as pages. This is done by my class file as a new environment using the code:

\newenvironment{romanpages}
{
\cleardoublepage
\setcounter{page}{1}
\renewcommand{\thepage}{\roman{page}}
}
{
\cleardoublepage
\renewcommand{\thepage}{\arabic{page}}
\setcounter{page}{1}
}


So, if I understood correctly, it reset the counter to 1 and the hypperref package will go crazy when asked to point to a page in the roman environment (as the glossaries-extra package seems to do for its entry list).

At this point, googling around and reading the second answer to this question, I tried to add

\newcommand{\originaltheHpage}{\theHpage}
\renewcommand*{\theHpage}{pre.\arabic{page}}


inside the beginning call to the romanpages environment and

\renewcommand*{\theHpage}{\originaltheHpage}


inside the ending call of the same environment (so that, in my mind, the internal roman pages counter should have been different thanks to the "pre." before the number of the page itself).

Unfortunately, this didn't work and latex complain about the fact that the comand \theHpage is undefinied.

How can I solve my problem?

Thanks, Jacopo

EDIT: Here is a minimal (not) working code:

\documentclass{book}
\newenvironment{romanpages}
{
\cleardoublepage
\setcounter{page}{1}
\renewcommand{\thepage}{\roman{page}}
}
{
\cleardoublepage
\renewcommand{\thepage}{\arabic{page}}
\setcounter{page}{1}
}
%\usepackage[acronym]{glossaries}       %needed for acronyms/glossary
\usepackage[record=nameref,abbreviations,savenumberlist=true
%,indexcounter
]{glossaries-extra} %as before, option 4 or 5

% glossaries entries
\newacronym[see={DEF}]{ABC}{ABC}{First 3 alphabet letters}
\newacronym[see={ABC}]{DEF}{DEF}{Second alphabet triplet}

% glossaries setup

\renewcommand{\glossarysection}[2][]{}% to prevent a new section/chapter

\renewcommand*{\glsxtrpostdescgeneral}{%
\ifglshasfield{see}
{\glscurrententrylabel}
{, \glsxtrusesee{\glscurrententrylabel}}%
{}%28
\ifglshasfield{seealso}
{\glscurrententrylabel}
{ (\glsxtruseseealso{\glscurrententrylabel})}%
{}%
}

% glossaries style definitions
\newglossarystyle{table-short-long-desc}{%
% put the glossary in the itemize environment:
\renewenvironment{theglossary}%
{\begin{longtable}{lp{0.7\linewidth}l}}{\end{longtable}}%
% have nothing after \begin{theglossary}:
\renewcommand*{\glossaryheader}{\Large{Abbr.} & \Large{Description} & \Large{Pages} \tabularnewline}%
% have nothing between glossary groups:
\renewcommand*{\glsgroupskip}{}%
% set how each entry should appear:
\renewcommand*{\glossentry}[2]{%
\tabularnewline
%first line:
\textbf{\glsentryshort{##1}}%short form
& \textbf{\glossentryname{##1}} %long form
& %nothing
\tabularnewline % next line
%second line
% nothing
& \glossentrydesc{##1} % the description
\glsxtrpostdescgeneral
& ##2
%\glossaryentrynumbers
%\glsdisplaynumberlist{##1} %entries list
\tabularnewline
}%
% set how sub-entries appear:
\renewcommand*{\subglossentry}[3]{%
\glossentry{##2}{##3}
}%
}

\begin{document}
\begin{romanpages}
First page of preface. No abbreviations here.
\cleardoublepage
\printunsrtglossary[type=abbreviations, style=table-short-long-desc]
\cleardoublepage
\end{romanpages}
\chapter{Chapter 1}
\section{Test section}
The first letters of alphabet are \gls{ABC}
\end{document}


While preparing this example, I noticed that my problem appear only when using my custom abbreviation style (table-short-long-desc).

• (1) welcome, (2) as onways on this site, you are much much more likely to get help if you povide a full (but minimal) example instead of just dropping sniplets. That way our testing is much more accurate, and we don't have to guess details about your setup. – daleif Mar 26 '19 at 16:18

Ok, Actually, following Daleif suggestion, I tried to get a small portion of code that could reproduce the error.
Doing so for each block of code, allowed my to isolate the error, and at the end I could also be able to solve it myself.
The problem was that I wasn't setting a target point for each entry of the glossary.
This can be done by calling \glstarget inside the new definition of \glossentry.
In my case, I called it in line 61 of the previous example:

& \textbf{\glossentryname{##1}} %long form


that became

& \glstarget{##1}{\textbf{\glossentryname{##1}}} %long form